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

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

initial commit

  • Property mode set to 100644
File size: 10.7 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 { ChangeDetectionStrategy, ViewEncapsulation } from '../../core';
9import { InterpolationConfig } from '../../ml_parser/interpolation_config';
10import * as o from '../../output/output_ast';
11import { ParseSourceSpan } from '../../parse_util';
12import * as t from '../r3_ast';
13import { R3DependencyMetadata } from '../r3_factory';
14import { R3Reference } from '../util';
15/**
16 * Information needed to compile a directive for the render3 runtime.
17 */
18export interface R3DirectiveMetadata {
19 /**
20 * Name of the directive type.
21 */
22 name: string;
23 /**
24 * An expression representing a reference to the directive itself.
25 */
26 type: R3Reference;
27 /**
28 * An expression representing a reference to the directive being compiled, intended for use within
29 * a class definition itself.
30 *
31 * This can differ from the outer `type` if the class is being compiled by ngcc and is inside
32 * an IIFE structure that uses a different name internally.
33 */
34 internalType: o.Expression;
35 /**
36 * Number of generic type parameters of the type itself.
37 */
38 typeArgumentCount: number;
39 /**
40 * A source span for the directive type.
41 */
42 typeSourceSpan: ParseSourceSpan;
43 /**
44 * Dependencies of the directive's constructor.
45 */
46 deps: R3DependencyMetadata[] | 'invalid' | null;
47 /**
48 * Unparsed selector of the directive, or `null` if there was no selector.
49 */
50 selector: string | null;
51 /**
52 * Information about the content queries made by the directive.
53 */
54 queries: R3QueryMetadata[];
55 /**
56 * Information about the view queries made by the directive.
57 */
58 viewQueries: R3QueryMetadata[];
59 /**
60 * Mappings indicating how the directive interacts with its host element (host bindings,
61 * listeners, etc).
62 */
63 host: R3HostMetadata;
64 /**
65 * Information about usage of specific lifecycle events which require special treatment in the
66 * code generator.
67 */
68 lifecycle: {
69 /**
70 * Whether the directive uses NgOnChanges.
71 */
72 usesOnChanges: boolean;
73 };
74 /**
75 * A mapping of inputs from class property names to binding property names, or to a tuple of
76 * binding property name and class property name if the names are different.
77 */
78 inputs: {
79 [field: string]: string | [string, string];
80 };
81 /**
82 * A mapping of outputs from class property names to binding property names, or to a tuple of
83 * binding property name and class property name if the names are different.
84 */
85 outputs: {
86 [field: string]: string;
87 };
88 /**
89 * Whether or not the component or directive inherits from another class
90 */
91 usesInheritance: boolean;
92 /**
93 * Whether or not the component or directive inherits its entire decorator from its base class.
94 */
95 fullInheritance: boolean;
96 /**
97 * Reference name under which to export the directive's type in a template,
98 * if any.
99 */
100 exportAs: string[] | null;
101 /**
102 * The list of providers defined in the directive.
103 */
104 providers: o.Expression | null;
105}
106/**
107 * Specifies how a list of declaration type references should be emitted into the generated code.
108 */
109export declare const enum DeclarationListEmitMode {
110 /**
111 * The list of declarations is emitted into the generated code as is.
112 *
113 * ```
114 * directives: [MyDir],
115 * ```
116 */
117 Direct = 0,
118 /**
119 * The list of declarations is emitted into the generated code wrapped inside a closure, which
120 * is needed when at least one declaration is a forward reference.
121 *
122 * ```
123 * directives: function () { return [MyDir, ForwardDir]; },
124 * ```
125 */
126 Closure = 1,
127 /**
128 * Similar to `Closure`, with the addition that the list of declarations can contain individual
129 * items that are themselves forward references. This is relevant for JIT compilations, as
130 * unwrapping the forwardRef cannot be done statically so must be deferred. This mode emits
131 * the declaration list using a mapping transform through `resolveForwardRef` to ensure that
132 * any forward references within the list are resolved when the outer closure is invoked.
133 *
134 * Consider the case where the runtime has captured two declarations in two distinct values:
135 * ```
136 * const dirA = MyDir;
137 * const dirB = forwardRef(function() { return ForwardRef; });
138 * ```
139 *
140 * This mode would emit the declarations captured in `dirA` and `dirB` as follows:
141 * ```
142 * directives: function () { return [dirA, dirB].map(ng.resolveForwardRef); },
143 * ```
144 */
145 ClosureResolved = 2
146}
147/**
148 * Information needed to compile a component for the render3 runtime.
149 */
150export interface R3ComponentMetadata extends R3DirectiveMetadata {
151 /**
152 * Information about the component's template.
153 */
154 template: {
155 /**
156 * Parsed nodes of the template.
157 */
158 nodes: t.Node[];
159 /**
160 * Any ng-content selectors extracted from the template. Contains `null` when an ng-content
161 * element without selector is present.
162 */
163 ngContentSelectors: string[];
164 };
165 /**
166 * A map of pipe names to an expression referencing the pipe type which are in the scope of the
167 * compilation.
168 */
169 pipes: Map<string, o.Expression>;
170 /**
171 * A list of directive selectors and an expression referencing the directive type which are in the
172 * scope of the compilation.
173 */
174 directives: R3UsedDirectiveMetadata[];
175 /**
176 * Specifies how the 'directives' and/or `pipes` array, if generated, need to be emitted.
177 */
178 declarationListEmitMode: DeclarationListEmitMode;
179 /**
180 * A collection of styling data that will be applied and scoped to the component.
181 */
182 styles: string[];
183 /**
184 * An encapsulation policy for the template and CSS styles. One of:
185 * - `ViewEncapsulation.Emulated`: Use shimmed CSS that emulates the native behavior.
186 * - `ViewEncapsulation.None`: Use global CSS without any encapsulation.
187 * - `ViewEncapsulation.ShadowDom`: Use the latest ShadowDOM API to natively encapsulate styles
188 * into a shadow root.
189 */
190 encapsulation: ViewEncapsulation;
191 /**
192 * A collection of animation triggers that will be used in the component template.
193 */
194 animations: o.Expression | null;
195 /**
196 * The list of view providers defined in the component.
197 */
198 viewProviders: o.Expression | null;
199 /**
200 * Path to the .ts file in which this template's generated code will be included, relative to
201 * the compilation root. This will be used to generate identifiers that need to be globally
202 * unique in certain contexts (such as g3).
203 */
204 relativeContextFilePath: string;
205 /**
206 * Whether translation variable name should contain external message id
207 * (used by Closure Compiler's output of `goog.getMsg` for transition period).
208 */
209 i18nUseExternalIds: boolean;
210 /**
211 * Overrides the default interpolation start and end delimiters ({{ and }}).
212 */
213 interpolation: InterpolationConfig;
214 /**
215 * Strategy used for detecting changes in the component.
216 */
217 changeDetection?: ChangeDetectionStrategy;
218}
219/**
220 * Information about a directive that is used in a component template. Only the stable, public
221 * facing information of the directive is stored here.
222 */
223export interface R3UsedDirectiveMetadata {
224 /**
225 * The type of the directive as an expression.
226 */
227 type: o.Expression;
228 /**
229 * The selector of the directive.
230 */
231 selector: string;
232 /**
233 * The binding property names of the inputs of the directive.
234 */
235 inputs: string[];
236 /**
237 * The binding property names of the outputs of the directive.
238 */
239 outputs: string[];
240 /**
241 * Name under which the directive is exported, if any (exportAs in Angular). Null otherwise.
242 */
243 exportAs: string[] | null;
244 /**
245 * If true then this directive is actually a component; otherwise it is not.
246 */
247 isComponent?: boolean;
248}
249/**
250 * Information needed to compile a query (view or content).
251 */
252export interface R3QueryMetadata {
253 /**
254 * Name of the property on the class to update with query results.
255 */
256 propertyName: string;
257 /**
258 * Whether to read only the first matching result, or an array of results.
259 */
260 first: boolean;
261 /**
262 * Either an expression representing a type or `InjectionToken` for the query
263 * predicate, or a set of string selectors.
264 */
265 predicate: o.Expression | string[];
266 /**
267 * Whether to include only direct children or all descendants.
268 */
269 descendants: boolean;
270 /**
271 * If the `QueryList` should fire change event only if actual change to query was computed (vs old
272 * behavior where the change was fired whenever the query was recomputed, even if the recomputed
273 * query resulted in the same list.)
274 */
275 emitDistinctChangesOnly: boolean;
276 /**
277 * An expression representing a type to read from each matched node, or null if the default value
278 * for a given node is to be returned.
279 */
280 read: o.Expression | null;
281 /**
282 * Whether or not this query should collect only static results.
283 *
284 * If static is true, the query's results will be set on the component after nodes are created,
285 * but before change detection runs. This means that any results that relied upon change detection
286 * to run (e.g. results inside *ngIf or *ngFor views) will not be collected. Query results are
287 * available in the ngOnInit hook.
288 *
289 * If static is false, the query's results will be set on the component after change detection
290 * runs. This means that the query results can contain nodes inside *ngIf or *ngFor views, but
291 * the results will not be available in the ngOnInit hook (only in the ngAfterContentInit for
292 * content hooks and ngAfterViewInit for view hooks).
293 */
294 static: boolean;
295}
296/**
297 * Mappings indicating how the class interacts with its
298 * host element (host bindings, listeners, etc).
299 */
300export interface R3HostMetadata {
301 /**
302 * A mapping of attribute binding keys to `o.Expression`s.
303 */
304 attributes: {
305 [key: string]: o.Expression;
306 };
307 /**
308 * A mapping of event binding keys to unparsed expressions.
309 */
310 listeners: {
311 [key: string]: string;
312 };
313 /**
314 * A mapping of property binding keys to unparsed expressions.
315 */
316 properties: {
317 [key: string]: string;
318 };
319 specialAttributes: {
320 styleAttr?: string;
321 classAttr?: string;
322 };
323}
Note: See TracBrowser for help on using the repository browser.