source: trip-planner-front/node_modules/@angular/compiler/src/render3/view/t2_api.d.ts

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.8 KB
Line 
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 */
8import { AST } from '../../expression_parser/ast';
9import { BoundAttribute, BoundEvent, Element, Node, Reference, Template, TextAttribute, Variable } from '../r3_ast';
10/**
11 * A logical target for analysis, which could contain a template or other types of bindings.
12 */
13export interface Target {
14 template?: Node[];
15}
16/**
17 * A data structure which can indicate whether a given property name is present or not.
18 *
19 * This is used to represent the set of inputs or outputs present on a directive, and allows the
20 * binder to query for the presence of a mapping for property names.
21 */
22export interface InputOutputPropertySet {
23 hasBindingPropertyName(propertyName: string): boolean;
24}
25/**
26 * Metadata regarding a directive that's needed to match it against template elements. This is
27 * provided by a consumer of the t2 APIs.
28 */
29export interface DirectiveMeta {
30 /**
31 * Name of the directive class (used for debugging).
32 */
33 name: string;
34 /** The selector for the directive or `null` if there isn't one. */
35 selector: string | null;
36 /**
37 * Whether the directive is a component.
38 */
39 isComponent: boolean;
40 /**
41 * Set of inputs which this directive claims.
42 *
43 * Goes from property names to field names.
44 */
45 inputs: InputOutputPropertySet;
46 /**
47 * Set of outputs which this directive claims.
48 *
49 * Goes from property names to field names.
50 */
51 outputs: InputOutputPropertySet;
52 /**
53 * Name under which the directive is exported, if any (exportAs in Angular).
54 *
55 * Null otherwise
56 */
57 exportAs: string[] | null;
58 isStructural: boolean;
59}
60/**
61 * Interface to the binding API, which processes a template and returns an object similar to the
62 * `ts.TypeChecker`.
63 *
64 * The returned `BoundTarget` has an API for extracting information about the processed target.
65 */
66export interface TargetBinder<D extends DirectiveMeta> {
67 bind(target: Target): BoundTarget<D>;
68}
69/**
70 * Result of performing the binding operation against a `Target`.
71 *
72 * The original `Target` is accessible, as well as a suite of methods for extracting binding
73 * information regarding the `Target`.
74 *
75 * @param DirectiveT directive metadata type
76 */
77export interface BoundTarget<DirectiveT extends DirectiveMeta> {
78 /**
79 * Get the original `Target` that was bound.
80 */
81 readonly target: Target;
82 /**
83 * For a given template node (either an `Element` or a `Template`), get the set of directives
84 * which matched the node, if any.
85 */
86 getDirectivesOfNode(node: Element | Template): DirectiveT[] | null;
87 /**
88 * For a given `Reference`, get the reference's target - either an `Element`, a `Template`, or
89 * a directive on a particular node.
90 */
91 getReferenceTarget(ref: Reference): {
92 directive: DirectiveT;
93 node: Element | Template;
94 } | Element | Template | null;
95 /**
96 * For a given binding, get the entity to which the binding is being made.
97 *
98 * This will either be a directive or the node itself.
99 */
100 getConsumerOfBinding(binding: BoundAttribute | BoundEvent | TextAttribute): DirectiveT | Element | Template | null;
101 /**
102 * If the given `AST` expression refers to a `Reference` or `Variable` within the `Target`, then
103 * return that.
104 *
105 * Otherwise, returns `null`.
106 *
107 * This is only defined for `AST` expressions that read or write to a property of an
108 * `ImplicitReceiver`.
109 */
110 getExpressionTarget(expr: AST): Reference | Variable | null;
111 /**
112 * Given a particular `Reference` or `Variable`, get the `Template` which created it.
113 *
114 * All `Variable`s are defined on templates, so this will always return a value for a `Variable`
115 * from the `Target`. For `Reference`s this only returns a value if the `Reference` points to a
116 * `Template`. Returns `null` otherwise.
117 */
118 getTemplateOfSymbol(symbol: Reference | Variable): Template | null;
119 /**
120 * Get the nesting level of a particular `Template`.
121 *
122 * This starts at 1 for top-level `Template`s within the `Target` and increases for `Template`s
123 * nested at deeper levels.
124 */
125 getNestingLevel(template: Template): number;
126 /**
127 * Get all `Reference`s and `Variables` visible within the given `Template` (or at the top level,
128 * if `null` is passed).
129 */
130 getEntitiesInTemplateScope(template: Template | null): ReadonlySet<Reference | Variable>;
131 /**
132 * Get a list of all the directives used by the target.
133 */
134 getUsedDirectives(): DirectiveT[];
135 /**
136 * Get a list of all the pipes used by the target.
137 */
138 getUsedPipes(): string[];
139}
Note: See TracBrowser for help on using the repository browser.