This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './src/api';
export * from './src/di';
export * from './src/diagnostics';
export * from './src/evaluation';
export * from './src/factory';
export * from './src/injectable_registry';
export * from './src/metadata';
export * from './src/debug_info';
export * from './src/references_registry';
export * from './src/schema';
export * from './src/util';
export * from './src/input_transforms';
export * from './src/jit_declaration_registry';

View File

@@ -0,0 +1,96 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/**
* Resolves and loads resource files that are referenced in Angular metadata.
*
* Note that `preload()` and `load()` take a `resolvedUrl`, which can be found
* by calling `resolve()`. These two steps are separated because sometimes the
* resolved URL to the resource is needed as well as its contents.
*/
export interface ResourceLoader {
/**
* True if this resource loader can preload resources.
*
* Sometimes a `ResourceLoader` is not able to do asynchronous pre-loading of resources.
*/
canPreload: boolean;
/**
* If true, the resource loader is able to preprocess inline resources.
*/
canPreprocess: boolean;
/**
* Resolve the url of a resource relative to the file that contains the reference to it.
* The return value of this method can be used in the `load()` and `preload()` methods.
*
* @param url The, possibly relative, url of the resource.
* @param fromFile The path to the file that contains the URL of the resource.
* @returns A resolved url of resource.
* @throws An error if the resource cannot be resolved.
*/
resolve(file: string, basePath: string): string;
/**
* Preload the specified resource, asynchronously. Once the resource is loaded, its value
* should be cached so it can be accessed synchronously via the `load()` method.
*
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to preload.
* @param context Information regarding the resource such as the type and containing file.
* @returns A Promise that is resolved once the resource has been loaded or `undefined`
* if the file has already been loaded.
* @throws An Error if pre-loading is not available.
*/
preload(resolvedUrl: string, context: ResourceLoaderContext): Promise<void> | undefined;
/**
* Preprocess the content data of an inline resource, asynchronously.
*
* @param data The existing content data from the inline resource.
* @param context Information regarding the resource such as the type and containing file.
* @returns A Promise that resolves to the processed data. If no processing occurs, the
* same data string that was passed to the function will be resolved.
*/
preprocessInline(data: string, context: ResourceLoaderContext): Promise<string>;
/**
* Load the resource at the given url, synchronously.
*
* The contents of the resource may have been cached by a previous call to `preload()`.
*
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to load.
* @returns The contents of the resource.
*/
load(resolvedUrl: string): string;
}
/**
* Contextual information used by members of the ResourceLoader interface.
*/
export interface ResourceLoaderContext {
/**
* The type of the component resource.
* * Resources referenced via a component's `styles` or `styleUrls` properties are of
* type `style`.
* * Resources referenced via a component's `template` or `templateUrl` properties are of type
* `template`.
*/
type: 'style' | 'template';
/**
* The absolute path to the file that contains the resource or reference to the resource.
*/
containingFile: string;
/**
* For style resources, the placement of the style within the containing file with lower numbers
* being before higher numbers.
* The value is primarily used by the Angular CLI to create a deterministic identifier for each
* style in HMR scenarios.
* This is undefined for templates.
*/
order?: number;
/**
* The name of the class that defines the component using the resource.
* This allows identifying the source usage of a resource in cases where multiple components are
* contained in a single source file.
*/
className: string;
}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3ClassDebugInfo } from '@angular/compiler';
import ts from 'typescript';
import { DeclarationNode, ReflectionHost } from '../../../reflection';
export declare function extractClassDebugInfo(clazz: DeclarationNode, reflection: ReflectionHost, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, rootDirs: ReadonlyArray<string>, forbidOrphanRendering: boolean): R3ClassDebugInfo | null;

View File

@@ -0,0 +1,37 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3DependencyMetadata } from '@angular/compiler';
import { ClassDeclaration, CtorParameter, ReflectionHost, UnavailableValue } from '../../../reflection';
export type ConstructorDeps = {
deps: R3DependencyMetadata[];
} | {
deps: null;
errors: ConstructorDepError[];
};
export interface ConstructorDepError {
index: number;
param: CtorParameter;
reason: UnavailableValue;
}
export declare function getConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): ConstructorDeps | null;
/**
* Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
* or into an `'invalid'` signal if they're not.
*
* This is a companion function to `validateConstructorDependencies` which accepts invalid deps.
*/
export declare function unwrapConstructorDependencies(deps: ConstructorDeps | null): R3DependencyMetadata[] | 'invalid' | null;
export declare function getValidConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): R3DependencyMetadata[] | null;
/**
* Validate that `ConstructorDeps` does not have any invalid dependencies and convert them into the
* `R3DependencyMetadata` array if so, or raise a diagnostic if some deps are invalid.
*
* This is a companion function to `unwrapConstructorDependencies` which does not accept invalid
* deps.
*/
export declare function validateConstructorDependencies(clazz: ClassDeclaration, deps: ConstructorDeps | null): R3DependencyMetadata[] | null;

View File

@@ -0,0 +1,63 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { FatalDiagnosticError } from '../../../diagnostics';
import { Reference } from '../../../imports';
import { HostDirectiveMeta, MetadataReader } from '../../../metadata';
import { PartialEvaluator, ResolvedValue } from '../../../partial_evaluator';
import { ClassDeclaration, ReflectionHost } from '../../../reflection';
import { DeclarationData, LocalModuleScopeRegistry } from '../../../scope';
import { InjectableClassRegistry } from './injectable_registry';
import { CompilationMode } from '../../../transform';
/**
* Create a `ts.Diagnostic` which indicates the given class is part of the declarations of two or
* more NgModules.
*
* The resulting `ts.Diagnostic` will have a context entry for each NgModule showing the point where
* the directive/pipe exists in its `declarations` (if possible).
*/
export declare function makeDuplicateDeclarationError(node: ClassDeclaration, data: DeclarationData[], kind: string): ts.Diagnostic;
/**
* Creates a `FatalDiagnosticError` for a node that did not evaluate to the expected type. The
* diagnostic that is created will include details on why the value is incorrect, i.e. it includes
* a representation of the actual type that was unsupported, or in the case of a dynamic value the
* trace to the node where the dynamic value originated.
*
* @param node The node for which the diagnostic should be produced.
* @param value The evaluated value that has the wrong type.
* @param messageText The message text of the error.
*/
export declare function createValueHasWrongTypeError(node: ts.Node, value: ResolvedValue, messageText: string): FatalDiagnosticError;
/**
* Gets the diagnostics for a set of provider classes.
* @param providerClasses Classes that should be checked.
* @param providersDeclaration Node that declares the providers array.
* @param registry Registry that keeps track of the registered injectable classes.
*/
export declare function getProviderDiagnostics(providerClasses: Set<Reference<ClassDeclaration>>, providersDeclaration: ts.Expression, registry: InjectableClassRegistry): ts.Diagnostic[];
export declare function getDirectiveDiagnostics(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, evaluator: PartialEvaluator, reflector: ReflectionHost, scopeRegistry: LocalModuleScopeRegistry, strictInjectionParameters: boolean, kind: 'Directive' | 'Component'): ts.Diagnostic[] | null;
export declare function validateHostDirectives(origin: ts.Expression, hostDirectives: HostDirectiveMeta[], metaReader: MetadataReader): ts.DiagnosticWithLocation[];
export declare function getUndecoratedClassWithAngularFeaturesDiagnostic(node: ClassDeclaration): ts.Diagnostic;
export declare function checkInheritanceOfInjectable(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, reflector: ReflectionHost, evaluator: PartialEvaluator, strictInjectionParameters: boolean, kind: 'Directive' | 'Component' | 'Pipe' | 'Injectable'): ts.Diagnostic | null;
interface ClassWithCtor {
ref: Reference<ClassDeclaration>;
isCtorValid: boolean;
isDecorated: boolean;
}
export declare function findInheritedCtor(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, reflector: ReflectionHost, evaluator: PartialEvaluator): ClassWithCtor | null;
/**
* Throws `FatalDiagnosticError` with error code `LOCAL_COMPILATION_UNRESOLVED_CONST`
* if the compilation mode is local and the value is not resolved due to being imported
* from external files. This is a common scenario for errors in local compilation mode,
* and so this helper can be used to quickly generate the relevant errors.
*
* @param nodeToHighlight Node to be highlighted in teh error message.
* Will default to value.node if not provided.
*/
export declare function assertLocalCompilationUnresolvedConst(compilationMode: CompilationMode, value: ResolvedValue, nodeToHighlight: ts.Node | null, errorMessage: string): void;
export {};

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { Reference } from '../../../imports';
import { PartialEvaluator, ResolvedValue } from '../../../partial_evaluator';
import { ClassDeclaration, Decorator } from '../../../reflection';
export declare function resolveEnumValue(evaluator: PartialEvaluator, metadata: Map<string, ts.Expression>, field: string, enumSymbolName: string, isCore: boolean): number | null;
/**
* Resolves a EncapsulationEnum expression locally on best effort without having to calculate the
* reference. This suites local compilation mode where each file is compiled individually.
*
* The static analysis is still needed in local compilation mode since the value of this enum will
* be used later to decide the generated code for styles.
*/
export declare function resolveEncapsulationEnumValueLocally(expr?: ts.Expression): number | null;
/** Determines if the result of an evaluation is a string array. */
export declare function isStringArray(resolvedValue: ResolvedValue): resolvedValue is string[];
export declare function isClassReferenceArray(resolvedValue: ResolvedValue): resolvedValue is Reference<ClassDeclaration>[];
export declare function isArray(value: ResolvedValue): value is Array<ResolvedValue>;
export declare function resolveLiteral(decorator: Decorator, literalCache: Map<Decorator, ts.ObjectLiteralExpression>): ts.ObjectLiteralExpression;

View File

@@ -0,0 +1,12 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3FactoryMetadata } from '@angular/compiler';
import { CompileResult } from '../../../transform';
export type CompileFactoryFn = (metadata: R3FactoryMetadata) => CompileResult;
export declare function compileNgFactoryDefField(metadata: R3FactoryMetadata): CompileResult;
export declare function compileDeclareFactory(metadata: R3FactoryMetadata): CompileResult;

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3DependencyMetadata } from '@angular/compiler';
import { ClassDeclaration, ReflectionHost } from '../../../reflection';
export interface InjectableMeta {
ctorDeps: R3DependencyMetadata[] | 'invalid' | null;
}
/**
* Registry that keeps track of classes that can be constructed via dependency injection (e.g.
* injectables, directives, pipes).
*/
export declare class InjectableClassRegistry {
private host;
private isCore;
private classes;
constructor(host: ReflectionHost, isCore: boolean);
registerInjectable(declaration: ClassDeclaration, meta: InjectableMeta): void;
getInjectableMeta(declaration: ClassDeclaration): InjectableMeta | null;
}

View File

@@ -0,0 +1,11 @@
/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ClassPropertyMapping, InputMapping } from '../../../metadata';
import { CompileResult } from '../../../transform';
/** Generates additional fields to be added to a class that has inputs with transform functions. */
export declare function compileInputTransformFields(inputs: ClassPropertyMapping<InputMapping>): CompileResult[];

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ClassDeclaration } from '../../../reflection';
/**
* Registry that keeps track of Angular declarations that are explicitly
* marked for JIT compilation and are skipping compilation by trait handlers.
*/
export declare class JitDeclarationRegistry {
jitDeclarations: Set<ClassDeclaration>;
}

View File

@@ -0,0 +1,27 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { LiteralArrayExpr, R3ClassMetadata } from '@angular/compiler';
import ts from 'typescript';
import { ClassMember, DeclarationNode, Decorator, ReflectionHost } from '../../../reflection';
/** Function that extracts metadata from an undercorated class member. */
export type UndecoratedMetadataExtractor = (member: ClassMember) => LiteralArrayExpr | null;
/**
* Given a class declaration, generate a call to `setClassMetadata` with the Angular metadata
* present on the class or its member fields. An ngDevMode guard is used to allow the call to be
* tree-shaken away, as the `setClassMetadata` invocation is only needed for testing purposes.
*
* If no such metadata is present, this function returns `null`. Otherwise, the call is returned
* as a `Statement` for inclusion along with the class.
*/
export declare function extractClassMetadata(clazz: DeclarationNode, reflection: ReflectionHost, isCore: boolean, annotateForClosureCompiler?: boolean, angularDecoratorTransform?: (dec: Decorator) => Decorator, undecoratedMetadataExtractor?: UndecoratedMetadataExtractor): R3ClassMetadata | null;
/**
* Recursively recreates all of the `Identifier` descendant nodes with a particular name inside
* of an AST node, thus removing any references to them. Useful if a particular node has to be
* taken from one place any emitted to another one exactly as it has been written.
*/
export declare function removeIdentifierReferences<T extends ts.Node>(node: T, names: string | Set<string>): T;

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { Reference } from '../../../imports';
import { DeclarationNode } from '../../../reflection';
/**
* Implement this interface if you want DecoratorHandlers to register
* references that they find in their analysis of the code.
*/
export interface ReferencesRegistry {
/**
* Register one or more references in the registry.
* @param references A collection of references to register.
*/
add(source: DeclarationNode, ...references: Reference<DeclarationNode>[]): void;
}
/**
* This registry does nothing.
*/
export declare class NoopReferencesRegistry implements ReferencesRegistry {
add(source: DeclarationNode, ...references: Reference<DeclarationNode>[]): void;
}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { SchemaMetadata } from '@angular/compiler';
import ts from 'typescript';
import { PartialEvaluator } from '../../../partial_evaluator';
export declare function extractSchemas(rawExpr: ts.Expression, evaluator: PartialEvaluator, context: string): SchemaMetadata[];

View File

@@ -0,0 +1,122 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { Expression, FactoryTarget, ParseSourceSpan, R3CompiledExpression, R3FactoryMetadata, R3Reference, Statement, WrappedNodeExpr } from '@angular/compiler';
import ts from 'typescript';
import { ImportedFile, ModuleResolver, Reference, ReferenceEmitter } from '../../../imports';
import { ForeignFunctionResolver, PartialEvaluator } from '../../../partial_evaluator';
import { ClassDeclaration, Decorator, Import, ImportedTypeValueReference, LocalTypeValueReference, ReflectionHost, TypeValueReference } from '../../../reflection';
import { CompileResult } from '../../../transform';
/** Module name of the framework core. */
export declare const CORE_MODULE = "@angular/core";
/**
* Convert a `TypeValueReference` to an `Expression` which refers to the type as a value.
*
* Local references are converted to a `WrappedNodeExpr` of the TypeScript expression, and non-local
* references are converted to an `ExternalExpr`. Note that this is only valid in the context of the
* file in which the `TypeValueReference` originated.
*/
export declare function valueReferenceToExpression(valueRef: LocalTypeValueReference | ImportedTypeValueReference): Expression;
export declare function valueReferenceToExpression(valueRef: TypeValueReference): Expression | null;
export declare function toR3Reference(origin: ts.Node, ref: Reference, context: ts.SourceFile, refEmitter: ReferenceEmitter): R3Reference;
export declare function isAngularCore(decorator: Decorator): decorator is Decorator & {
import: Import;
};
/**
* This function is used for verifying that a given reference is declared
* inside `@angular/core` and corresponds to the given symbol name.
*
* In some cases, due to the compiler face duplicating many symbols as
* an independent bridge between core and the compiler, the dts bundler may
* decide to alias declarations in the `.d.ts`, to avoid conflicts.
*
* e.g.
*
* ```
* declare enum ViewEncapsulation {} // from the facade
* declare enum ViewEncapsulation$1 {} // the real one exported to users.
* ```
*
* This function accounts for such potential re-namings.
*/
export declare function isAngularCoreReferenceWithPotentialAliasing(reference: Reference, symbolName: string, isCore: boolean): boolean;
export declare function findAngularDecorator(decorators: Decorator[], name: string, isCore: boolean): Decorator | undefined;
export declare function isAngularDecorator(decorator: Decorator, name: string, isCore: boolean): boolean;
export declare function getAngularDecorators(decorators: Decorator[], names: readonly string[], isCore: boolean): Decorator[];
/**
* Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
* lowest level form.
*
* For example, the expression "(foo as Type)" unwraps to "foo".
*/
export declare function unwrapExpression(node: ts.Expression): ts.Expression;
/**
* If the given `node` is a forwardRef() expression then resolve its inner value, otherwise return
* `null`.
*
* @param node the forwardRef() expression to resolve
* @param reflector a ReflectionHost
* @returns the resolved expression, if the original expression was a forwardRef(), or `null`
* otherwise.
*/
export declare function tryUnwrapForwardRef(node: ts.Expression, reflector: ReflectionHost): ts.Expression | null;
/**
* A foreign function resolver for `staticallyResolve` which unwraps forwardRef() expressions.
*
* @param ref a Reference to the declaration of the function being called (which might be
* forwardRef)
* @param args the arguments to the invocation of the forwardRef expression
* @returns an unwrapped argument if `ref` pointed to forwardRef, or null otherwise
*/
export declare function createForwardRefResolver(isCore: boolean): ForeignFunctionResolver;
/**
* Combines an array of resolver functions into a one.
* @param resolvers Resolvers to be combined.
*/
export declare function combineResolvers(resolvers: ForeignFunctionResolver[]): ForeignFunctionResolver;
export declare function isExpressionForwardReference(expr: Expression, context: ts.Node, contextSource: ts.SourceFile): boolean;
export declare function isWrappedTsNodeExpr(expr: Expression): expr is WrappedNodeExpr<ts.Node>;
export declare function readBaseClass(node: ClassDeclaration, reflector: ReflectionHost, evaluator: PartialEvaluator): Reference<ClassDeclaration> | 'dynamic' | null;
/**
* Wraps all functions in a given expression in parentheses. This is needed to avoid problems
* where Tsickle annotations added between analyse and transform phases in Angular may trigger
* automatic semicolon insertion, e.g. if a function is the expression in a `return` statement.
* More
* info can be found in Tsickle source code here:
* https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021
*
* @param expression Expression where functions should be wrapped in parentheses
*/
export declare function wrapFunctionExpressionsInParens(expression: ts.Expression): ts.Expression;
/**
* Resolves the given `rawProviders` into `ClassDeclarations` and returns
* a set containing those that are known to require a factory definition.
* @param rawProviders Expression that declared the providers array in the source.
*/
export declare function resolveProvidersRequiringFactory(rawProviders: ts.Expression, reflector: ReflectionHost, evaluator: PartialEvaluator): Set<Reference<ClassDeclaration>>;
/**
* Create an R3Reference for a class.
*
* The `value` is the exported declaration of the class from its source file.
* The `type` is an expression that would be used in the typings (.d.ts) files.
*/
export declare function wrapTypeReference(reflector: ReflectionHost, clazz: ClassDeclaration): R3Reference;
/** Creates a ParseSourceSpan for a TypeScript node. */
export declare function createSourceSpan(node: ts.Node): ParseSourceSpan;
/**
* Collate the factory and definition compiled results into an array of CompileResult objects.
*/
export declare function compileResults(fac: CompileResult, def: R3CompiledExpression, metadataStmt: Statement | null, propName: string, additionalFields: CompileResult[] | null, deferrableImports: Set<ts.ImportDeclaration> | null, debugInfo?: Statement | null, hmrInitializer?: Statement | null): CompileResult[];
export declare function toFactoryMetadata(meta: Omit<R3FactoryMetadata, 'target'>, target: FactoryTarget): R3FactoryMetadata;
export declare function resolveImportedFile(moduleResolver: ModuleResolver, importedFile: ImportedFile, expr: Expression, origin: ts.SourceFile): ts.SourceFile | null;
/**
* Determines the most appropriate expression for diagnostic reporting purposes. If `expr` is
* contained within `container` then `expr` is used as origin node, otherwise `container` itself is
* used.
*/
export declare function getOriginNodeForDiagnostics(expr: ts.Expression, container: ts.Expression): ts.Expression;
export declare function isAbstractClassDeclaration(clazz: ClassDeclaration): boolean;

View File

@@ -0,0 +1,8 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export { ComponentDecoratorHandler } from './src/handler';

View File

@@ -0,0 +1,15 @@
/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { TmplAstNode } from '@angular/compiler';
/**
* Analyzes a component's template to determine if it's using animate.enter
* or animate.leave syntax.
*/
export declare function analyzeTemplateForAnimations(template: TmplAstNode[]): {
hasAnimations: boolean;
};

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { Cycle } from '../../../cycles';
import { Reference } from '../../../imports';
/**
* Generate a diagnostic related information object that describes a potential cyclic import path.
*/
export declare function makeCyclicImportInfo(ref: Reference, type: string, cycle: Cycle): ts.DiagnosticRelatedInformation;
/**
* Checks whether a selector is a valid custom element tag name.
* Based loosely on https://github.com/sindresorhus/validate-element-name.
*/
export declare function checkCustomElementSelectorForErrors(selector: string): string | null;

View File

@@ -0,0 +1,161 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ConstantPool } from '@angular/compiler';
import ts from 'typescript';
import { CycleAnalyzer, CycleHandlingStrategy } from '../../../cycles';
import { DeferredSymbolTracker, ImportedSymbolsTracker, LocalCompilationExtraImportsTracker, ModuleResolver, ReferenceEmitter } from '../../../imports';
import { DependencyTracker } from '../../../incremental/api';
import { SemanticDepGraphUpdater } from '../../../incremental/semantic_graph';
import { IndexingContext } from '../../../indexer';
import { HostDirectivesResolver, MetadataReader, MetadataRegistry, ResourceRegistry } from '../../../metadata';
import { PartialEvaluator } from '../../../partial_evaluator';
import { PerfRecorder } from '../../../perf';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
import { ComponentScopeReader, LocalModuleScopeRegistry, TypeCheckScopeRegistry } from '../../../scope';
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../../transform';
import { TypeCheckContext } from '../../../typecheck/api';
import { ExtendedTemplateChecker } from '../../../typecheck/extended/api';
import { TemplateSemanticsChecker } from '../../../typecheck/template_semantics/api/api';
import { Xi18nContext } from '../../../xi18n';
import { InjectableClassRegistry, ReferencesRegistry, ResourceLoader } from '../../common';
import { ComponentAnalysisData, ComponentResolutionData } from './metadata';
import { ComponentSymbol } from './symbol';
import { JitDeclarationRegistry } from '../../common/src/jit_declaration_registry';
/**
* `DecoratorHandler` which handles the `@Component` annotation.
*/
export declare class ComponentDecoratorHandler implements DecoratorHandler<Decorator, ComponentAnalysisData, ComponentSymbol, ComponentResolutionData> {
private reflector;
private evaluator;
private metaRegistry;
private metaReader;
private scopeReader;
private compilerHost;
private scopeRegistry;
private typeCheckScopeRegistry;
private resourceRegistry;
private isCore;
private strictCtorDeps;
private resourceLoader;
private rootDirs;
private defaultPreserveWhitespaces;
private i18nUseExternalIds;
private enableI18nLegacyMessageIdFormat;
private usePoisonedData;
private i18nNormalizeLineEndingsInICUs;
private moduleResolver;
private cycleAnalyzer;
private cycleHandlingStrategy;
private refEmitter;
private referencesRegistry;
private depTracker;
private injectableRegistry;
private semanticDepGraphUpdater;
private annotateForClosureCompiler;
private perf;
private hostDirectivesResolver;
private importTracker;
private includeClassMetadata;
private readonly compilationMode;
private readonly deferredSymbolTracker;
private readonly forbidOrphanRendering;
private readonly enableBlockSyntax;
private readonly enableLetSyntax;
private readonly externalRuntimeStyles;
private readonly localCompilationExtraImportsTracker;
private readonly jitDeclarationRegistry;
private readonly i18nPreserveSignificantWhitespace;
private readonly strictStandalone;
private readonly enableHmr;
private readonly implicitStandaloneValue;
private readonly typeCheckHostBindings;
private readonly enableSelectorless;
private readonly emitDeclarationOnly;
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, metaReader: MetadataReader, scopeReader: ComponentScopeReader, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, scopeRegistry: LocalModuleScopeRegistry, typeCheckScopeRegistry: TypeCheckScopeRegistry, resourceRegistry: ResourceRegistry, isCore: boolean, strictCtorDeps: boolean, resourceLoader: ResourceLoader, rootDirs: ReadonlyArray<string>, defaultPreserveWhitespaces: boolean, i18nUseExternalIds: boolean, enableI18nLegacyMessageIdFormat: boolean, usePoisonedData: boolean, i18nNormalizeLineEndingsInICUs: boolean, moduleResolver: ModuleResolver, cycleAnalyzer: CycleAnalyzer, cycleHandlingStrategy: CycleHandlingStrategy, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, depTracker: DependencyTracker | null, injectableRegistry: InjectableClassRegistry, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, annotateForClosureCompiler: boolean, perf: PerfRecorder, hostDirectivesResolver: HostDirectivesResolver, importTracker: ImportedSymbolsTracker, includeClassMetadata: boolean, compilationMode: CompilationMode, deferredSymbolTracker: DeferredSymbolTracker, forbidOrphanRendering: boolean, enableBlockSyntax: boolean, enableLetSyntax: boolean, externalRuntimeStyles: boolean, localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null, jitDeclarationRegistry: JitDeclarationRegistry, i18nPreserveSignificantWhitespace: boolean, strictStandalone: boolean, enableHmr: boolean, implicitStandaloneValue: boolean, typeCheckHostBindings: boolean, enableSelectorless: boolean, emitDeclarationOnly: boolean);
private literalCache;
private elementSchemaRegistry;
private readonly undecoratedMetadataExtractor;
/**
* During the asynchronous preanalyze phase, it's necessary to parse the template to extract
* any potential <link> tags which might need to be loaded. This cache ensures that work is not
* thrown away, and the parsed template is reused during the analyze phase.
*/
private preanalyzeTemplateCache;
private preanalyzeStylesCache;
/** Whether generated code for a component can defer its dependencies. */
private readonly canDeferDeps;
private extractTemplateOptions;
readonly precedence = HandlerPrecedence.PRIMARY;
readonly name = "ComponentDecoratorHandler";
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
preanalyze(node: ClassDeclaration, decorator: Readonly<Decorator>): Promise<void> | undefined;
analyze(node: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<ComponentAnalysisData>;
symbol(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): ComponentSymbol;
register(node: ClassDeclaration, analysis: ComponentAnalysisData): void;
index(context: IndexingContext, node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): null;
typeCheck(ctx: TypeCheckContext, node: ClassDeclaration, meta: Readonly<ComponentAnalysisData>): void;
extendedTemplateCheck(component: ts.ClassDeclaration, extendedTemplateChecker: ExtendedTemplateChecker): ts.Diagnostic[];
templateSemanticsCheck(component: ts.ClassDeclaration, templateSemanticsChecker: TemplateSemanticsChecker): ts.Diagnostic[];
resolve(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, symbol: ComponentSymbol): ResolveResult<ComponentResolutionData>;
xi18n(ctx: Xi18nContext, node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): void;
updateResources(node: ClassDeclaration, analysis: ComponentAnalysisData): void;
compileFull(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>, pool: ConstantPool): CompileResult[];
compilePartial(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>): CompileResult[];
compileLocal(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<Partial<ComponentResolutionData>>, pool: ConstantPool): CompileResult[];
compileHmrUpdateDeclaration(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>): ts.FunctionDeclaration | null;
/**
* Determines the dependencies of a component and
* categorizes them based on how they were introduced.
*/
private resolveComponentDependencies;
/**
* Converts component dependencies into declarations by
* resolving their metadata and deduplicating them.
*/
private componentDependenciesToDeclarations;
/** Handles any cycles in the dependencies of a component. */
private handleDependencyCycles;
/** Produces diagnostics that require more than local information. */
private getNonLocalDiagnostics;
/**
* Locates defer blocks in case scope information is not available.
* For example, this happens in the local compilation mode.
*/
private locateDeferBlocksWithoutScope;
/**
* Computes a list of deferrable symbols based on dependencies from
* the `@Component.imports` field and their usage in `@defer` blocks.
*/
private resolveAllDeferredDependencies;
/**
* Collects deferrable symbols from the `@Component.deferredImports` field.
*/
private collectExplicitlyDeferredSymbols;
/**
* Check whether adding an import from `origin` to the source-file corresponding to `expr` would
* create a cyclic import.
*
* @returns a `Cycle` object if a cycle would be created, otherwise `null`.
*/
private _checkForCyclicImport;
private maybeRecordSyntheticImport;
/**
* Resolves information about defer blocks dependencies to make it
* available for the final `compile` step.
*/
private resolveDeferBlocks;
/**
* Inspects provided imports expression (either `@Component.imports` or
* `@Component.deferredImports`) and registers imported types as deferrable
* candidates.
*/
private registerDeferrableCandidate;
private compileDeferBlocks;
/** Creates a new binding parser. */
private getNewBindingParser;
}

View File

@@ -0,0 +1,117 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { LegacyAnimationTriggerNames, DeclarationListEmitMode, DeferBlockDepsEmitMode, R3ClassDebugInfo, R3ClassMetadata, R3ComponentMetadata, R3DeferPerBlockDependency, R3DeferPerComponentDependency, R3TemplateDependencyMetadata, SchemaMetadata, TmplAstDeferredBlock } from '@angular/compiler';
import ts from 'typescript';
import { Reference } from '../../../imports';
import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping } from '../../../metadata';
import { ClassDeclaration, Import } from '../../../reflection';
import { SubsetOfKeys } from '../../../util/src/typescript';
import { ParsedTemplateWithSource, StyleUrlMeta } from './resources';
import { HostBindingNodes } from '../../directive';
/**
* These fields of `R3ComponentMetadata` are updated in the `resolve` phase.
*
* The `keyof R3ComponentMetadata &` condition ensures that only fields of `R3ComponentMetadata` can
* be included here.
*/
export type ComponentMetadataResolvedFields = SubsetOfKeys<R3ComponentMetadata<R3TemplateDependencyMetadata>, 'declarations' | 'declarationListEmitMode' | 'defer' | 'hasDirectiveDependencies'>;
export interface ComponentAnalysisData {
/**
* `meta` includes those fields of `R3ComponentMetadata` which are calculated at `analyze` time
* (not during resolve).
*/
meta: Omit<R3ComponentMetadata<R3TemplateDependencyMetadata>, ComponentMetadataResolvedFields>;
baseClass: Reference<ClassDeclaration> | 'dynamic' | null;
typeCheckMeta: DirectiveTypeCheckMeta;
template: ParsedTemplateWithSource;
classMetadata: R3ClassMetadata | null;
classDebugInfo: R3ClassDebugInfo | null;
inputs: ClassPropertyMapping<InputMapping>;
inputFieldNamesFromMetadataArray: Set<string>;
outputs: ClassPropertyMapping;
/**
* Providers extracted from the `providers` field of the component annotation which will require
* an Angular factory definition at runtime.
*/
providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
/**
* Providers extracted from the `viewProviders` field of the component annotation which will
* require an Angular factory definition at runtime.
*/
viewProvidersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
resources: DirectiveResources;
/**
* `styleUrls` extracted from the decorator, if present.
*/
styleUrls: StyleUrlMeta[] | null;
/**
* Inline stylesheets extracted from the decorator, if present.
*/
inlineStyles: string[] | null;
isPoisoned: boolean;
legacyAnimationTriggerNames: LegacyAnimationTriggerNames | null;
rawImports: ts.Expression | null;
resolvedImports: Reference<ClassDeclaration>[] | null;
rawDeferredImports: ts.Expression | null;
resolvedDeferredImports: Reference<ClassDeclaration>[] | null;
/**
* Map of symbol name -> import path for types from `@Component.deferredImports` field.
*/
explicitlyDeferredTypes: R3DeferPerComponentDependency[] | null;
schemas: SchemaMetadata[] | null;
decorator: ts.Decorator | null;
/** Additional directives applied to the component host. */
hostDirectives: HostDirectiveMeta[] | null;
/** Raw expression that defined the host directives array. Used for diagnostics. */
rawHostDirectives: ts.Expression | null;
/** Raw nodes representing the host bindings of the directive. */
hostBindingNodes: HostBindingNodes;
/** Whether selectorless is enabled for the specific component. */
selectorlessEnabled: boolean;
/**
* Names of the symbols within the source file that are referenced directly inside the template.
* Used to reduce the amount of lookups when determining which dependencies to expose.
*/
localReferencedSymbols: Set<string> | null;
}
export interface ComponentResolutionData {
declarations: R3TemplateDependencyMetadata[];
declarationListEmitMode: DeclarationListEmitMode;
/**
* Map of all types that can be defer loaded (ts.ClassDeclaration) ->
* corresponding import information (reflection `Import`) within
* the current source file. The `Import` preserves the exported name
* as seen by the importing module so aliasing is handled correctly.
*/
deferrableDeclToImportDecl: Map<ClassDeclaration, Import>;
/**
* Map of `@defer` blocks -> their corresponding dependencies.
* Required to compile the defer resolver function in `PerBlock` mode.
*/
deferPerBlockDependencies: Map<TmplAstDeferredBlock, DeferredComponentDependency[]>;
/**
* Defines how dynamic imports for deferred dependencies should be grouped:
* - either in a function on per-component basis (in case of local compilation)
* - or in a function on per-block basis (in full compilation mode)
*/
deferBlockDepsEmitMode: DeferBlockDepsEmitMode;
/**
* List of deferrable dependencies in the entire component. Used to compile the
* defer resolver function in `PerComponent` mode.
*/
deferPerComponentDependencies: R3DeferPerComponentDependency[];
/** Whether the component is standalone and has any directly-imported directive dependencies. */
hasDirectiveDependencies: boolean;
}
/**
* Describes a dependency used within a `@defer` block.
*/
export type DeferredComponentDependency = R3DeferPerBlockDependency & {
/** Reference to the declaration that defines the dependency. */
declaration: Reference<ClassDeclaration>;
};

View File

@@ -0,0 +1,128 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { InterpolationConfig, ParsedTemplate, ParseSourceFile, TmplAstNode } from '@angular/compiler';
import ts from 'typescript';
import { FatalDiagnosticError } from '../../../diagnostics';
import { DependencyTracker } from '../../../incremental/api';
import { Resource } from '../../../metadata';
import { PartialEvaluator } from '../../../partial_evaluator';
import { ClassDeclaration, DeclarationNode, Decorator } from '../../../reflection';
import { CompilationMode } from '../../../transform';
import { SourceMapping } from '../../../typecheck/api';
import { ResourceLoader } from '../../common';
/**
* The literal style url extracted from the decorator, along with metadata for diagnostics.
*/
export interface StyleUrlMeta {
url: string;
expression: ts.Expression;
source: ResourceTypeForDiagnostics.StylesheetFromTemplate | ResourceTypeForDiagnostics.StylesheetFromDecorator;
}
/**
* Information about the origin of a resource in the application code. This is used for creating
* diagnostics, so we can point to the root cause of an error in the application code.
*
* A template resource comes from the `templateUrl` property on the component decorator.
*
* Stylesheets resources can come from either the `styleUrls` property on the component decorator,
* or from inline `style` tags and style links on the external template.
*/
export declare const enum ResourceTypeForDiagnostics {
Template = 0,
StylesheetFromTemplate = 1,
StylesheetFromDecorator = 2
}
/**
* Information about the template which was extracted during parsing.
*
* This contains the actual parsed template as well as any metadata collected during its parsing,
* some of which might be useful for re-parsing the template with different options.
*/
export interface ParsedComponentTemplate extends ParsedTemplate {
/**
* The template AST, parsed in a manner which preserves source map information for diagnostics.
*
* Not useful for emit.
*/
diagNodes: TmplAstNode[];
/**
* The `ParseSourceFile` for the template.
*/
file: ParseSourceFile;
}
export interface ParsedTemplateWithSource extends ParsedComponentTemplate {
/** The string contents of the template. */
content: string;
sourceMapping: SourceMapping;
declaration: TemplateDeclaration;
}
/**
* Common fields extracted from the declaration of a template.
*/
interface CommonTemplateDeclaration {
preserveWhitespaces: boolean;
interpolationConfig: InterpolationConfig;
templateUrl: string;
resolvedTemplateUrl: string;
}
/**
* Information extracted from the declaration of an inline template.
*/
export interface InlineTemplateDeclaration extends CommonTemplateDeclaration {
isInline: true;
expression: ts.Expression;
}
/**
* Information extracted from the declaration of an external template.
*/
export interface ExternalTemplateDeclaration extends CommonTemplateDeclaration {
isInline: false;
templateUrlExpression: ts.Expression;
}
/**
* The declaration of a template extracted from a component decorator.
*
* This data is extracted and stored separately to facilitate re-interpreting the template
* declaration whenever the compiler is notified of a change to a template file. With this
* information, `ComponentDecoratorHandler` is able to re-read the template and update the component
* record without needing to parse the original decorator again.
*/
export type TemplateDeclaration = InlineTemplateDeclaration | ExternalTemplateDeclaration;
/** Determines the node to use for debugging purposes for the given TemplateDeclaration. */
export declare function getTemplateDeclarationNodeForError(declaration: TemplateDeclaration): ts.Expression;
export interface ExtractTemplateOptions {
usePoisonedData: boolean;
enableI18nLegacyMessageIdFormat: boolean;
i18nNormalizeLineEndingsInICUs: boolean;
enableBlockSyntax: boolean;
enableLetSyntax: boolean;
enableSelectorless: boolean;
preserveSignificantWhitespace?: boolean;
}
export declare function extractTemplate(node: ClassDeclaration, template: TemplateDeclaration, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, options: ExtractTemplateOptions, compilationMode: CompilationMode): ParsedTemplateWithSource;
export declare function createEmptyTemplate(componentClass: ClassDeclaration, component: Map<string, ts.Expression>, containingFile: string): ParsedTemplateWithSource;
export declare function parseTemplateDeclaration(node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, defaultPreserveWhitespaces: boolean): TemplateDeclaration;
export declare function preloadAndParseTemplate(evaluator: PartialEvaluator, resourceLoader: ResourceLoader, depTracker: DependencyTracker | null, preanalyzeTemplateCache: Map<DeclarationNode, ParsedTemplateWithSource>, node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, defaultPreserveWhitespaces: boolean, options: ExtractTemplateOptions, compilationMode: CompilationMode): Promise<ParsedTemplateWithSource | null>;
export declare function makeResourceNotFoundError(file: string, nodeForError: ts.Node, resourceType: ResourceTypeForDiagnostics): FatalDiagnosticError;
/**
* Transforms the given decorator to inline external resources. i.e. if the decorator
* resolves to `@Component`, the `templateUrl` and `styleUrls` metadata fields will be
* transformed to their semantically-equivalent inline variants.
*
* This method is used for serializing decorators into the class metadata. The emitted
* class metadata should not refer to external resources as this would be inconsistent
* with the component definitions/declarations which already inline external resources.
*
* Additionally, the references to external resources would require libraries to ship
* external resources exclusively for the class metadata.
*/
export declare function transformDecoratorResources(dec: Decorator, component: Map<string, ts.Expression>, styles: string[], template: ParsedTemplateWithSource): Decorator;
export declare function extractComponentStyleUrls(evaluator: PartialEvaluator, component: Map<string, ts.Expression>): StyleUrlMeta[];
export declare function extractInlineStyleResources(component: Map<string, ts.Expression>): Set<Resource>;
export declare function _extractTemplateStyleUrls(template: ParsedTemplateWithSource): StyleUrlMeta[];
export {};

View File

@@ -0,0 +1,16 @@
/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { TmplAstNode } from '@angular/compiler';
/**
* Analyzes a component's template to determine if it's using selectorless syntax
* and to extract the names of the selectorless symbols that are referenced.
*/
export declare function analyzeTemplateForSelectorless(template: TmplAstNode[]): {
isSelectorless: boolean;
localReferencedSymbols: Set<string> | null;
};

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { SemanticReference, SemanticSymbol } from '../../../incremental/semantic_graph';
import { DirectiveSymbol } from '../../directive';
/**
* Represents an Angular component.
*/
export declare class ComponentSymbol extends DirectiveSymbol {
usedDirectives: SemanticReference[];
usedPipes: SemanticReference[];
isRemotelyScoped: boolean;
isEmitAffected(previousSymbol: SemanticSymbol, publicApiAffected: Set<SemanticSymbol>): boolean;
isTypeCheckBlockAffected(previousSymbol: SemanticSymbol, typeCheckApiAffected: Set<SemanticSymbol>): boolean;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { LegacyAnimationTriggerNames } from '@angular/compiler';
import ts from 'typescript';
import { Reference } from '../../../imports';
import { ForeignFunctionResolver, ResolvedValue } from '../../../partial_evaluator';
import { ClassDeclaration } from '../../../reflection';
/**
* Collect the animation names from the static evaluation result.
* @param value the static evaluation result of the animations
* @param legacyAnimationTriggerNames the animation names collected and whether some names could not be
* statically evaluated.
*/
export declare function collectLegacyAnimationNames(value: ResolvedValue, legacyAnimationTriggerNames: LegacyAnimationTriggerNames): void;
export declare function isLegacyAngularAnimationsReference(reference: Reference, symbolName: string): boolean;
export declare const legacyAnimationTriggerResolver: ForeignFunctionResolver;
export declare function validateAndFlattenComponentImports(imports: ResolvedValue, expr: ts.Expression, isDeferred: boolean): {
imports: Reference<ClassDeclaration>[];
diagnostics: ts.Diagnostic[];
};

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export { DirectiveDecoratorHandler } from './src/handler';
export { DirectiveSymbol } from './src/symbol';
export * from './src/shared';
export * from './src/input_function';
export * from './src/output_function';
export * from './src/query_functions';
export * from './src/model_function';
export * from './src/initializer_functions';

View File

@@ -0,0 +1,85 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ConstantPool, R3ClassMetadata, R3DirectiveMetadata } from '@angular/compiler';
import ts from 'typescript';
import { ImportedSymbolsTracker, Reference, ReferenceEmitter } from '../../../imports';
import { SemanticDepGraphUpdater } from '../../../incremental/semantic_graph';
import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping, MetadataReader, MetadataRegistry, ResourceRegistry } from '../../../metadata';
import { PartialEvaluator } from '../../../partial_evaluator';
import { PerfRecorder } from '../../../perf';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
import { LocalModuleScopeRegistry, TypeCheckScopeRegistry } from '../../../scope';
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../../transform';
import { InjectableClassRegistry, ReferencesRegistry } from '../../common';
import { HostBindingNodes } from './shared';
import { DirectiveSymbol } from './symbol';
import { JitDeclarationRegistry } from '../../common/src/jit_declaration_registry';
import { TypeCheckContext } from '../../../typecheck/api';
export interface DirectiveHandlerData {
baseClass: Reference<ClassDeclaration> | 'dynamic' | null;
typeCheckMeta: DirectiveTypeCheckMeta;
meta: R3DirectiveMetadata;
classMetadata: R3ClassMetadata | null;
providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
inputs: ClassPropertyMapping<InputMapping>;
inputFieldNamesFromMetadataArray: Set<string>;
outputs: ClassPropertyMapping;
isPoisoned: boolean;
isStructural: boolean;
decorator: ts.Decorator | null;
hostDirectives: HostDirectiveMeta[] | null;
rawHostDirectives: ts.Expression | null;
hostBindingNodes: HostBindingNodes;
resources: DirectiveResources;
}
export declare class DirectiveDecoratorHandler implements DecoratorHandler<Decorator | null, DirectiveHandlerData, DirectiveSymbol, unknown> {
private reflector;
private evaluator;
private metaRegistry;
private scopeRegistry;
private metaReader;
private injectableRegistry;
private refEmitter;
private referencesRegistry;
private isCore;
private strictCtorDeps;
private semanticDepGraphUpdater;
private annotateForClosureCompiler;
private perf;
private importTracker;
private includeClassMetadata;
private typeCheckScopeRegistry;
private readonly compilationMode;
private readonly jitDeclarationRegistry;
private readonly resourceRegistry;
private readonly strictStandalone;
private readonly implicitStandaloneValue;
private readonly usePoisonedData;
private readonly typeCheckHostBindings;
private readonly emitDeclarationOnly;
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, scopeRegistry: LocalModuleScopeRegistry, metaReader: MetadataReader, injectableRegistry: InjectableClassRegistry, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, isCore: boolean, strictCtorDeps: boolean, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, annotateForClosureCompiler: boolean, perf: PerfRecorder, importTracker: ImportedSymbolsTracker, includeClassMetadata: boolean, typeCheckScopeRegistry: TypeCheckScopeRegistry, compilationMode: CompilationMode, jitDeclarationRegistry: JitDeclarationRegistry, resourceRegistry: ResourceRegistry, strictStandalone: boolean, implicitStandaloneValue: boolean, usePoisonedData: boolean, typeCheckHostBindings: boolean, emitDeclarationOnly: boolean);
readonly precedence = HandlerPrecedence.PRIMARY;
readonly name = "DirectiveDecoratorHandler";
private readonly undecoratedMetadataExtractor;
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator | null> | undefined;
analyze(node: ClassDeclaration, decorator: Readonly<Decorator | null>): AnalysisOutput<DirectiveHandlerData>;
symbol(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): DirectiveSymbol;
register(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): void;
typeCheck(ctx: TypeCheckContext, node: ClassDeclaration, meta: Readonly<DirectiveHandlerData>): void;
resolve(node: ClassDeclaration, analysis: DirectiveHandlerData, symbol: DirectiveSymbol): ResolveResult<unknown>;
compileFull(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[];
compilePartial(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>): CompileResult[];
compileLocal(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[];
/**
* Checks if a given class uses Angular features and returns the TypeScript node
* that indicated the usage. Classes are considered using Angular features if they
* contain class members that are either decorated with a known Angular decorator,
* or if they correspond to a known Angular lifecycle hook.
*/
private findClassFieldWithAngularFeatures;
}

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ClassMember } from '../../../reflection';
import { InitializerFunctionMetadata } from './initializer_functions';
/**
* Validates that the initializer member is compatible with the given class
* member in terms of field access and visibility.
*
* @throws {FatalDiagnosticError} If the recognized initializer API is
* incompatible.
*/
export declare function validateAccessOfInitializerApiMember({ api, call }: InitializerFunctionMetadata, member: Pick<ClassMember, 'accessLevel'>): void;

View File

@@ -0,0 +1,52 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { ImportedSymbolsTracker } from '../../../imports';
import { ClassMemberAccessLevel, ReflectionHost } from '../../../reflection';
/**
* @fileoverview
*
* Angular exposes functions that can be used as class member initializers
* to make use of various APIs. Those are called initializer APIs.
*
* Signal-based inputs are relying on initializer APIs because such inputs
* are declared using `input` and `input.required` intersection functions.
* Similarly, signal-based queries follow the same pattern and are also
* declared through initializer APIs.
*/
export interface InitializerApiFunction {
/** Module name where the initializer function is imported from. */
owningModule: '@angular/core' | '@angular/core/rxjs-interop';
/** Export name of the initializer function. */
functionName: 'input' | 'model' | 'output' | 'outputFromObservable' | 'viewChild' | 'viewChildren' | 'contentChild' | 'contentChildren';
/** Class member access levels compatible with the API. */
allowedAccessLevels: ClassMemberAccessLevel[];
}
/**
* Metadata describing an Angular class member that was recognized through
* a function initializer. Like `input`, `input.required` or `viewChild`.
*/
export interface InitializerFunctionMetadata {
/** Initializer API function that was recognized. */
api: InitializerApiFunction;
/** Node referring to the call expression. */
call: ts.CallExpression;
/** Whether the initializer is required or not. E.g. `input.required` was used. */
isRequired: boolean;
}
/**
* Attempts to identify an Angular initializer function call.
*
* Note that multiple possible initializer API function names can be specified,
* allowing for checking multiple types in one pass.
*
* @returns The parsed initializer API, or null if none was found.
*/
export declare function tryParseInitializerApi<Functions extends InitializerApiFunction[]>(functions: Functions, expression: ts.Expression, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): (InitializerFunctionMetadata & {
api: Functions[number];
}) | null;

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ImportedSymbolsTracker } from '../../../imports';
import { InputMapping } from '../../../metadata';
import { ClassMember, ReflectionHost } from '../../../reflection';
import { InitializerApiFunction } from './initializer_functions';
/** Represents a function that can declare an input. */
export declare const INPUT_INITIALIZER_FN: InitializerApiFunction;
/**
* Attempts to parse a signal input class member. Returns the parsed
* input mapping if possible.
*/
export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
/**
* Parses and validates input and output initializer function options.
*
* This currently only parses the `alias` option and returns it. The other
* options for signal inputs are runtime constructs that aren't relevant at
* compile time.
*/
export declare function parseAndValidateInputAndOutputOptions(optionsNode: ts.Expression): {
alias: string | undefined;
};

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ImportedSymbolsTracker } from '../../../imports';
import { ModelMapping } from '../../../metadata';
import { ClassMember, ReflectionHost } from '../../../reflection';
import { InitializerApiFunction } from './initializer_functions';
/** Represents a function that can declare a model. */
export declare const MODEL_INITIALIZER_FN: InitializerApiFunction;
/**
* Attempts to parse a model class member. Returns the parsed model mapping if possible.
*/
export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;

View File

@@ -0,0 +1,22 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { ImportedSymbolsTracker } from '../../../imports';
import { InputOrOutput } from '../../../metadata';
import { ClassMember, ReflectionHost } from '../../../reflection';
import { InitializerApiFunction } from './initializer_functions';
/** Possible functions that can declare an output. */
export declare const OUTPUT_INITIALIZER_FNS: InitializerApiFunction[];
/**
* Attempts to parse a signal output class member. Returns the parsed
* input mapping if possible.
*/
export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
call: ts.CallExpression;
metadata: InputOrOutput;
} | null;

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3QueryMetadata } from '@angular/compiler';
import ts from 'typescript';
import { ImportedSymbolsTracker } from '../../../imports';
import { ClassMember, ReflectionHost } from '../../../reflection';
import { InitializerApiFunction } from './initializer_functions';
/** Possible query initializer API functions. */
export type QueryFunctionName = 'viewChild' | 'contentChild' | 'viewChildren' | 'contentChildren';
/** Possible query initializer API functions. */
export declare const QUERY_INITIALIZER_FNS: (InitializerApiFunction & {
functionName: QueryFunctionName;
})[];
/**
* Attempts to detect a possible query definition for the given class member.
*
* This function checks for all possible variants of queries and matches the
* first one. The query is then analyzed and its resolved metadata is returned.
*
* @returns Resolved query metadata, or null if no query is declared.
*/
export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
name: QueryFunctionName;
metadata: R3QueryMetadata;
call: ts.CallExpression;
} | null;

View File

@@ -0,0 +1,64 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3DirectiveMetadata, R3QueryMetadata } from '@angular/compiler';
import ts from 'typescript';
import { ImportedSymbolsTracker, Reference, ReferenceEmitter } from '../../../imports';
import { ClassPropertyMapping, DecoratorInputTransform, HostDirectiveMeta, InputMapping, Resource } from '../../../metadata';
import { DynamicValue, PartialEvaluator } from '../../../partial_evaluator';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
import { CompilationMode } from '../../../transform';
import { ReferencesRegistry, UndecoratedMetadataExtractor } from '../../common';
type QueryDecoratorName = 'ViewChild' | 'ViewChildren' | 'ContentChild' | 'ContentChildren';
export declare const queryDecoratorNames: QueryDecoratorName[];
export interface HostBindingNodes {
literal: ts.ObjectLiteralExpression | null;
bindingDecorators: Set<ts.Decorator>;
listenerDecorators: Set<ts.Decorator>;
}
/**
* Helper function to extract metadata from a `Directive` or `Component`. `Directive`s without a
* selector are allowed to be used for abstract base classes. These abstract directives should not
* appear in the declarations of an `NgModule` and additional verification is done when processing
* the module.
*/
export declare function extractDirectiveMetadata(clazz: ClassDeclaration, decorator: Readonly<Decorator>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker, evaluator: PartialEvaluator, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, isCore: boolean, annotateForClosureCompiler: boolean, compilationMode: CompilationMode, defaultSelector: string | null, strictStandalone: boolean, implicitStandaloneValue: boolean, emitDeclarationOnly: boolean): {
jitForced: false;
decorator: Map<string, ts.Expression>;
metadata: R3DirectiveMetadata;
inputs: ClassPropertyMapping<InputMapping>;
outputs: ClassPropertyMapping;
isStructural: boolean;
hostDirectives: HostDirectiveMeta[] | null;
rawHostDirectives: ts.Expression | null;
inputFieldNamesFromMetadataArray: Set<string>;
hostBindingNodes: HostBindingNodes;
} | {
jitForced: true;
};
export declare function extractDecoratorQueryMetadata(exprNode: ts.Node, name: string, args: ReadonlyArray<ts.Expression>, propertyName: string, reflector: ReflectionHost, evaluator: PartialEvaluator): R3QueryMetadata;
export declare function parseDirectiveStyles(directive: Map<string, ts.Expression>, evaluator: PartialEvaluator, compilationMode: CompilationMode): null | string[];
export declare function parseFieldStringArrayValue(directive: Map<string, ts.Expression>, field: string, evaluator: PartialEvaluator): null | string[];
/**
* Returns a function that can be used to extract data for the `setClassMetadata`
* calls from undecorated directive class members.
*/
export declare function getDirectiveUndecoratedMetadataExtractor(reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): UndecoratedMetadataExtractor;
/**
* Parses the `transform` function and its type for a decorator `@Input`.
*
* This logic verifies feasibility of extracting the transform write type
* into a different place, so that the input write type can be captured at
* a later point in a static acceptance member.
*
* Note: This is not needed for signal inputs where the transform type is
* automatically captured in the type of the `InputSignal`.
*
*/
export declare function parseDecoratorInputTransformFunction(clazz: ClassDeclaration, classPropertyName: string, value: DynamicValue | Reference, reflector: ReflectionHost, refEmitter: ReferenceEmitter, compilationMode: CompilationMode, emitDeclarationOnly: boolean): DecoratorInputTransform;
export declare function extractHostBindingResources(nodes: HostBindingNodes): ReadonlySet<Resource>;
export {};

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { SemanticSymbol, SemanticTypeParameter } from '../../../incremental/semantic_graph';
import { ClassPropertyMapping, DirectiveTypeCheckMeta, InputMapping } from '../../../metadata';
import { ClassDeclaration } from '../../../reflection';
/**
* Represents an Angular directive. Components are represented by `ComponentSymbol`, which inherits
* from this symbol.
*/
export declare class DirectiveSymbol extends SemanticSymbol {
readonly selector: string | null;
readonly inputs: ClassPropertyMapping<InputMapping>;
readonly outputs: ClassPropertyMapping;
readonly exportAs: string[] | null;
readonly typeCheckMeta: DirectiveTypeCheckMeta;
readonly typeParameters: SemanticTypeParameter[] | null;
baseClass: SemanticSymbol | null;
constructor(decl: ClassDeclaration, selector: string | null, inputs: ClassPropertyMapping<InputMapping>, outputs: ClassPropertyMapping, exportAs: string[] | null, typeCheckMeta: DirectiveTypeCheckMeta, typeParameters: SemanticTypeParameter[] | null);
isPublicApiAffected(previousSymbol: SemanticSymbol): boolean;
isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean;
}

View File

@@ -0,0 +1,13 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export { createForwardRefResolver, findAngularDecorator, getAngularDecorators, isAngularDecorator, NoopReferencesRegistry, ReferencesRegistry, ResourceLoader, ResourceLoaderContext, JitDeclarationRegistry, } from './common';
export { ComponentDecoratorHandler } from './component';
export { DirectiveDecoratorHandler, InitializerApiFunction, INPUT_INITIALIZER_FN, MODEL_INITIALIZER_FN, OUTPUT_INITIALIZER_FNS, QUERY_INITIALIZER_FNS, queryDecoratorNames, QueryFunctionName, tryParseInitializerApi, tryParseInitializerBasedOutput, tryParseSignalInputMapping, tryParseSignalModelMapping, tryParseSignalQueryFromInitializer, } from './directive';
export { NgModuleDecoratorHandler } from './ng_module';
export { InjectableDecoratorHandler } from './src/injectable';
export { PipeDecoratorHandler } from './src/pipe';

View File

@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export { NgModuleDecoratorHandler, NgModuleSymbol } from './src/handler';
export { createModuleWithProvidersResolver, isResolvedModuleWithProviders, ResolvedModuleWithProviders, } from './src/module_with_providers';

View File

@@ -0,0 +1,120 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { Expression, R3ClassMetadata, R3FactoryMetadata, R3InjectorMetadata, R3NgModuleMetadata, SchemaMetadata } from '@angular/compiler';
import ts from 'typescript';
import { LocalCompilationExtraImportsTracker, Reference, ReferenceEmitter } from '../../../imports';
import { SemanticDepGraphUpdater, SemanticReference, SemanticSymbol } from '../../../incremental/semantic_graph';
import { ExportedProviderStatusResolver, MetadataReader, MetadataRegistry } from '../../../metadata';
import { PartialEvaluator } from '../../../partial_evaluator';
import { PerfRecorder } from '../../../perf';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
import { LocalModuleScopeRegistry } from '../../../scope';
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../../transform';
import { InjectableClassRegistry, JitDeclarationRegistry, ReferencesRegistry } from '../../common';
export interface NgModuleAnalysis {
mod: R3NgModuleMetadata;
inj: R3InjectorMetadata;
fac: R3FactoryMetadata;
classMetadata: R3ClassMetadata | null;
declarations: Reference<ClassDeclaration>[];
rawDeclarations: ts.Expression | null;
schemas: SchemaMetadata[];
imports: TopLevelImportedExpression[];
importRefs: Reference<ClassDeclaration>[];
rawImports: ts.Expression | null;
exports: Reference<ClassDeclaration>[];
rawExports: ts.Expression | null;
id: Expression | null;
factorySymbolName: string;
providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
providers: ts.Expression | null;
remoteScopesMayRequireCycleProtection: boolean;
decorator: ts.Decorator | null;
}
export interface NgModuleResolution {
injectorImports: Expression[];
}
/**
* Represents an Angular NgModule.
*/
export declare class NgModuleSymbol extends SemanticSymbol {
readonly hasProviders: boolean;
private remotelyScopedComponents;
/**
* `SemanticSymbol`s of the transitive imports of this NgModule which came from imported
* standalone components.
*
* Standalone components are excluded/included in the `InjectorDef` emit output of the NgModule
* based on whether the compiler can prove that their transitive imports may contain exported
* providers, so a change in this set of symbols may affect the compilation output of this
* NgModule.
*/
private transitiveImportsFromStandaloneComponents;
constructor(decl: ClassDeclaration, hasProviders: boolean);
isPublicApiAffected(previousSymbol: SemanticSymbol): boolean;
isEmitAffected(previousSymbol: SemanticSymbol): boolean;
isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean;
addRemotelyScopedComponent(component: SemanticSymbol, usedDirectives: SemanticReference[], usedPipes: SemanticReference[]): void;
addTransitiveImportFromStandaloneComponent(importedSymbol: SemanticSymbol): void;
}
/**
* Compiles @NgModule annotations to ngModuleDef fields.
*/
export declare class NgModuleDecoratorHandler implements DecoratorHandler<Decorator, NgModuleAnalysis, NgModuleSymbol, NgModuleResolution> {
private reflector;
private evaluator;
private metaReader;
private metaRegistry;
private scopeRegistry;
private referencesRegistry;
private exportedProviderStatusResolver;
private semanticDepGraphUpdater;
private isCore;
private refEmitter;
private annotateForClosureCompiler;
private onlyPublishPublicTypings;
private injectableRegistry;
private perf;
private includeClassMetadata;
private includeSelectorScope;
private readonly compilationMode;
private readonly localCompilationExtraImportsTracker;
private readonly jitDeclarationRegistry;
private readonly emitDeclarationOnly;
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaReader: MetadataReader, metaRegistry: MetadataRegistry, scopeRegistry: LocalModuleScopeRegistry, referencesRegistry: ReferencesRegistry, exportedProviderStatusResolver: ExportedProviderStatusResolver, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, isCore: boolean, refEmitter: ReferenceEmitter, annotateForClosureCompiler: boolean, onlyPublishPublicTypings: boolean, injectableRegistry: InjectableClassRegistry, perf: PerfRecorder, includeClassMetadata: boolean, includeSelectorScope: boolean, compilationMode: CompilationMode, localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null, jitDeclarationRegistry: JitDeclarationRegistry, emitDeclarationOnly: boolean);
readonly precedence = HandlerPrecedence.PRIMARY;
readonly name = "NgModuleDecoratorHandler";
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
analyze(node: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<NgModuleAnalysis>;
symbol(node: ClassDeclaration, analysis: NgModuleAnalysis): NgModuleSymbol;
register(node: ClassDeclaration, analysis: NgModuleAnalysis): void;
resolve(node: ClassDeclaration, analysis: Readonly<NgModuleAnalysis>): ResolveResult<NgModuleResolution>;
compileFull(node: ClassDeclaration, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }: Readonly<NgModuleAnalysis>, { injectorImports }: Readonly<NgModuleResolution>): CompileResult[];
compilePartial(node: ClassDeclaration, { inj, fac, mod, classMetadata }: Readonly<NgModuleAnalysis>, { injectorImports }: Readonly<NgModuleResolution>): CompileResult[];
compileLocal(node: ClassDeclaration, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }: Readonly<NgModuleAnalysis>): CompileResult[];
/**
* Add class metadata statements, if provided, to the `ngModuleStatements`.
*/
private insertMetadataStatement;
/**
* Add remote scoping statements, as needed, to the `ngModuleStatements`.
*/
private appendRemoteScopingStatements;
private compileNgModule;
private _toR3Reference;
private isClassDeclarationReference;
/**
* Compute a list of `Reference`s from a resolved metadata value.
*/
private resolveTypeList;
}
export interface TopLevelImportedExpression {
expression: ts.Expression;
resolvedReferences: Array<Reference<ClassDeclaration>>;
hasModuleWithProviders: boolean;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import ts from 'typescript';
import { Reference } from '../../../imports';
import { ForeignFunctionResolver, SyntheticValue } from '../../../partial_evaluator';
import { ClassDeclaration, ReflectionHost } from '../../../reflection';
/**
* Creates a foreign function resolver to detect a `ModuleWithProviders<T>` type in a return type
* position of a function or method declaration. A `SyntheticValue` is produced if such a return
* type is recognized.
*
* @param reflector The reflection host to use for analyzing the syntax.
* @param isCore Whether the @angular/core package is being compiled.
*/
export declare function createModuleWithProvidersResolver(reflector: ReflectionHost, isCore: boolean): ForeignFunctionResolver;
export interface ResolvedModuleWithProviders {
ngModule: Reference<ClassDeclaration>;
mwpCall: ts.CallExpression;
}
export declare function isResolvedModuleWithProviders(sv: SyntheticValue<unknown>): sv is SyntheticValue<ResolvedModuleWithProviders>;

View File

@@ -0,0 +1,58 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3ClassMetadata, R3DependencyMetadata, R3InjectableMetadata } from '@angular/compiler';
import { InjectableClassRegistry } from '../../annotations/common';
import { PartialEvaluator } from '../../partial_evaluator';
import { PerfRecorder } from '../../perf';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../reflection';
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../transform';
export interface InjectableHandlerData {
meta: R3InjectableMetadata;
classMetadata: R3ClassMetadata | null;
ctorDeps: R3DependencyMetadata[] | 'invalid' | null;
needsFactory: boolean;
}
/**
* Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
*/
export declare class InjectableDecoratorHandler implements DecoratorHandler<Decorator, InjectableHandlerData, null, unknown> {
private reflector;
private evaluator;
private isCore;
private strictCtorDeps;
private injectableRegistry;
private perf;
private includeClassMetadata;
private readonly compilationMode;
/**
* What to do if the injectable already contains a ɵprov property.
*
* If true then an error diagnostic is reported.
* If false then there is no error and a new ɵprov property is not added.
*/
private errorOnDuplicateProv;
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, isCore: boolean, strictCtorDeps: boolean, injectableRegistry: InjectableClassRegistry, perf: PerfRecorder, includeClassMetadata: boolean, compilationMode: CompilationMode,
/**
* What to do if the injectable already contains a ɵprov property.
*
* If true then an error diagnostic is reported.
* If false then there is no error and a new ɵprov property is not added.
*/
errorOnDuplicateProv?: boolean);
readonly precedence = HandlerPrecedence.SHARED;
readonly name = "InjectableDecoratorHandler";
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
analyze(node: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<InjectableHandlerData>;
symbol(): null;
register(node: ClassDeclaration, analysis: InjectableHandlerData): void;
resolve(node: ClassDeclaration, analysis: Readonly<InjectableHandlerData>): ResolveResult<unknown>;
compileFull(node: ClassDeclaration, analysis: Readonly<InjectableHandlerData>): CompileResult[];
compilePartial(node: ClassDeclaration, analysis: Readonly<InjectableHandlerData>): CompileResult[];
compileLocal(node: ClassDeclaration, analysis: Readonly<InjectableHandlerData>): CompileResult[];
private compile;
}

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { R3ClassMetadata, R3PipeMetadata } from '@angular/compiler';
import ts from 'typescript';
import { SemanticSymbol } from '../../incremental/semantic_graph';
import { MetadataRegistry } from '../../metadata';
import { PartialEvaluator } from '../../partial_evaluator';
import { PerfRecorder } from '../../perf';
import { ClassDeclaration, Decorator, ReflectionHost } from '../../reflection';
import { LocalModuleScopeRegistry } from '../../scope';
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../transform';
import { InjectableClassRegistry } from '../common';
export interface PipeHandlerData {
meta: R3PipeMetadata;
classMetadata: R3ClassMetadata | null;
pipeNameExpr: ts.Expression | null;
decorator: ts.Decorator | null;
}
/**
* Represents an Angular pipe.
*/
export declare class PipeSymbol extends SemanticSymbol {
readonly name: string;
constructor(decl: ClassDeclaration, name: string);
isPublicApiAffected(previousSymbol: SemanticSymbol): boolean;
isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean;
}
export declare class PipeDecoratorHandler implements DecoratorHandler<Decorator, PipeHandlerData, PipeSymbol, unknown> {
private reflector;
private evaluator;
private metaRegistry;
private scopeRegistry;
private injectableRegistry;
private isCore;
private perf;
private includeClassMetadata;
private readonly compilationMode;
private readonly generateExtraImportsInLocalMode;
private readonly strictStandalone;
private readonly implicitStandaloneValue;
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, scopeRegistry: LocalModuleScopeRegistry, injectableRegistry: InjectableClassRegistry, isCore: boolean, perf: PerfRecorder, includeClassMetadata: boolean, compilationMode: CompilationMode, generateExtraImportsInLocalMode: boolean, strictStandalone: boolean, implicitStandaloneValue: boolean);
readonly precedence = HandlerPrecedence.PRIMARY;
readonly name = "PipeDecoratorHandler";
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
analyze(clazz: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<PipeHandlerData>;
symbol(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): PipeSymbol;
register(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): void;
resolve(node: ClassDeclaration): ResolveResult<unknown>;
compileFull(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[];
compilePartial(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[];
compileLocal(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[];
}