1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /// <amd-module name="@angular/compiler-cli/src/ngtsc/annotations/src/directive" />
|
---|
9 | import { ConstantPool, ParsedHostBindings, R3ClassMetadata, R3DirectiveMetadata, R3QueryMetadata } from '@angular/compiler';
|
---|
10 | import * as ts from 'typescript';
|
---|
11 | import { Reference } from '../../imports';
|
---|
12 | import { SemanticDepGraphUpdater, SemanticSymbol, SemanticTypeParameter } from '../../incremental/semantic_graph';
|
---|
13 | import { ClassPropertyMapping, DirectiveTypeCheckMeta, InjectableClassRegistry, MetadataReader, MetadataRegistry } from '../../metadata';
|
---|
14 | import { PartialEvaluator } from '../../partial_evaluator';
|
---|
15 | import { PerfRecorder } from '../../perf';
|
---|
16 | import { ClassDeclaration, ClassMember, Decorator, ReflectionHost } from '../../reflection';
|
---|
17 | import { LocalModuleScopeRegistry } from '../../scope';
|
---|
18 | import { AnalysisOutput, CompileResult, DecoratorHandler, DetectResult, HandlerFlags, HandlerPrecedence, ResolveResult } from '../../transform';
|
---|
19 | export interface DirectiveHandlerData {
|
---|
20 | baseClass: Reference<ClassDeclaration> | 'dynamic' | null;
|
---|
21 | typeCheckMeta: DirectiveTypeCheckMeta;
|
---|
22 | meta: R3DirectiveMetadata;
|
---|
23 | classMetadata: R3ClassMetadata | null;
|
---|
24 | providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
|
---|
25 | inputs: ClassPropertyMapping;
|
---|
26 | outputs: ClassPropertyMapping;
|
---|
27 | isPoisoned: boolean;
|
---|
28 | isStructural: boolean;
|
---|
29 | }
|
---|
30 | /**
|
---|
31 | * Represents an Angular directive. Components are represented by `ComponentSymbol`, which inherits
|
---|
32 | * from this symbol.
|
---|
33 | */
|
---|
34 | export declare class DirectiveSymbol extends SemanticSymbol {
|
---|
35 | readonly selector: string | null;
|
---|
36 | readonly inputs: ClassPropertyMapping;
|
---|
37 | readonly outputs: ClassPropertyMapping;
|
---|
38 | readonly exportAs: string[] | null;
|
---|
39 | readonly typeCheckMeta: DirectiveTypeCheckMeta;
|
---|
40 | readonly typeParameters: SemanticTypeParameter[] | null;
|
---|
41 | baseClass: SemanticSymbol | null;
|
---|
42 | constructor(decl: ClassDeclaration, selector: string | null, inputs: ClassPropertyMapping, outputs: ClassPropertyMapping, exportAs: string[] | null, typeCheckMeta: DirectiveTypeCheckMeta, typeParameters: SemanticTypeParameter[] | null);
|
---|
43 | isPublicApiAffected(previousSymbol: SemanticSymbol): boolean;
|
---|
44 | isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean;
|
---|
45 | }
|
---|
46 | export declare class DirectiveDecoratorHandler implements DecoratorHandler<Decorator | null, DirectiveHandlerData, DirectiveSymbol, unknown> {
|
---|
47 | private reflector;
|
---|
48 | private evaluator;
|
---|
49 | private metaRegistry;
|
---|
50 | private scopeRegistry;
|
---|
51 | private metaReader;
|
---|
52 | private injectableRegistry;
|
---|
53 | private isCore;
|
---|
54 | private semanticDepGraphUpdater;
|
---|
55 | private annotateForClosureCompiler;
|
---|
56 | private compileUndecoratedClassesWithAngularFeatures;
|
---|
57 | private perf;
|
---|
58 | constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, scopeRegistry: LocalModuleScopeRegistry, metaReader: MetadataReader, injectableRegistry: InjectableClassRegistry, isCore: boolean, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, annotateForClosureCompiler: boolean, compileUndecoratedClassesWithAngularFeatures: boolean, perf: PerfRecorder);
|
---|
59 | readonly precedence = HandlerPrecedence.PRIMARY;
|
---|
60 | readonly name: string;
|
---|
61 | detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator | null> | undefined;
|
---|
62 | analyze(node: ClassDeclaration, decorator: Readonly<Decorator | null>, flags?: HandlerFlags): AnalysisOutput<DirectiveHandlerData>;
|
---|
63 | symbol(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): DirectiveSymbol;
|
---|
64 | register(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): void;
|
---|
65 | resolve(node: ClassDeclaration, analysis: DirectiveHandlerData, symbol: DirectiveSymbol): ResolveResult<unknown>;
|
---|
66 | compileFull(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[];
|
---|
67 | compilePartial(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>): CompileResult[];
|
---|
68 | /**
|
---|
69 | * Checks if a given class uses Angular features and returns the TypeScript node
|
---|
70 | * that indicated the usage. Classes are considered using Angular features if they
|
---|
71 | * contain class members that are either decorated with a known Angular decorator,
|
---|
72 | * or if they correspond to a known Angular lifecycle hook.
|
---|
73 | */
|
---|
74 | private findClassFieldWithAngularFeatures;
|
---|
75 | }
|
---|
76 | /**
|
---|
77 | * Helper function to extract metadata from a `Directive` or `Component`. `Directive`s without a
|
---|
78 | * selector are allowed to be used for abstract base classes. These abstract directives should not
|
---|
79 | * appear in the declarations of an `NgModule` and additional verification is done when processing
|
---|
80 | * the module.
|
---|
81 | */
|
---|
82 | export declare function extractDirectiveMetadata(clazz: ClassDeclaration, decorator: Readonly<Decorator | null>, reflector: ReflectionHost, evaluator: PartialEvaluator, isCore: boolean, flags: HandlerFlags, annotateForClosureCompiler: boolean, defaultSelector?: string | null): {
|
---|
83 | decorator: Map<string, ts.Expression>;
|
---|
84 | metadata: R3DirectiveMetadata;
|
---|
85 | inputs: ClassPropertyMapping;
|
---|
86 | outputs: ClassPropertyMapping;
|
---|
87 | isStructural: boolean;
|
---|
88 | } | undefined;
|
---|
89 | export declare function extractQueryMetadata(exprNode: ts.Node, name: string, args: ReadonlyArray<ts.Expression>, propertyName: string, reflector: ReflectionHost, evaluator: PartialEvaluator): R3QueryMetadata;
|
---|
90 | export declare function extractQueriesFromDecorator(queryData: ts.Expression, reflector: ReflectionHost, evaluator: PartialEvaluator, isCore: boolean): {
|
---|
91 | content: R3QueryMetadata[];
|
---|
92 | view: R3QueryMetadata[];
|
---|
93 | };
|
---|
94 | export declare function parseFieldArrayValue(directive: Map<string, ts.Expression>, field: string, evaluator: PartialEvaluator): null | string[];
|
---|
95 | export declare function queriesFromFields(fields: {
|
---|
96 | member: ClassMember;
|
---|
97 | decorators: Decorator[];
|
---|
98 | }[], reflector: ReflectionHost, evaluator: PartialEvaluator): R3QueryMetadata[];
|
---|
99 | export declare function extractHostBindings(members: ClassMember[], evaluator: PartialEvaluator, coreModule: string | undefined, metadata?: Map<string, ts.Expression>): ParsedHostBindings;
|
---|