-
Notifications
You must be signed in to change notification settings - Fork 24.8k
/
api.ts
595 lines (508 loc) · 16.5 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
/**
* @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.io/license
*/
import {ChangeDetectionStrategy, ViewEncapsulation} from '../../core';
import * as o from '../../output/output_ast';
export interface R3PartialDeclaration {
/**
* The minimum version of the compiler that can process this partial declaration.
*/
minVersion: string;
/**
* Version number of the Angular compiler that was used to compile this declaration. The linker
* will be able to detect which version a library is using and interpret its metadata accordingly.
*/
version: string;
/**
* A reference to the `@angular/core` ES module, which allows access
* to all Angular exports, including Ivy instructions.
*/
ngImport: o.Expression;
/**
* Reference to the decorated class, which is subject to this partial declaration.
*/
type: o.Expression;
}
// TODO(legacy-partial-output-inputs): Remove in v18.
// https://github.com/angular/angular/blob/d4b423690210872b5c32a322a6090beda30b05a3/packages/core/src/compiler/compiler_facade_interface.ts#L197-L199
export type LegacyInputPartialMapping =
| string
| [bindingPropertyName: string, classPropertyName: string, transformFunction?: o.Expression];
/**
* Describes the shape of the object that the `ɵɵngDeclareDirective()` function accepts.
*/
export interface R3DeclareDirectiveMetadata extends R3PartialDeclaration {
/**
* Unparsed selector of the directive.
*/
selector?: string;
/**
* A mapping of inputs from class property names to binding property names, or to a tuple of
* binding property name and class property name if the names are different.
*/
inputs?: {
[fieldName: string]:
| {
classPropertyName: string;
publicName: string;
isSignal: boolean;
isRequired: boolean;
transformFunction: o.Expression | null;
}
| LegacyInputPartialMapping;
};
/**
* A mapping of outputs from class property names to binding property names.
*/
outputs?: {[classPropertyName: string]: string};
/**
* Information about host bindings present on the component.
*/
host?: {
/**
* A mapping of attribute names to their value expression.
*/
attributes?: {[key: string]: o.Expression};
/**
* A mapping of event names to their unparsed event handler expression.
*/
listeners: {[key: string]: string};
/**
* A mapping of bound properties to their unparsed binding expression.
*/
properties?: {[key: string]: string};
/**
* The value of the class attribute, if present. This is stored outside of `attributes` as its
* string value must be known statically.
*/
classAttribute?: string;
/**
* The value of the style attribute, if present. This is stored outside of `attributes` as its
* string value must be known statically.
*/
styleAttribute?: string;
};
/**
* Information about the content queries made by the directive.
*/
queries?: R3DeclareQueryMetadata[];
/**
* Information about the view queries made by the directive.
*/
viewQueries?: R3DeclareQueryMetadata[];
/**
* The list of providers provided by the directive.
*/
providers?: o.Expression;
/**
* The names by which the directive is exported.
*/
exportAs?: string[];
/**
* Whether the directive has an inheritance clause. Defaults to false.
*/
usesInheritance?: boolean;
/**
* Whether the directive implements the `ngOnChanges` hook. Defaults to false.
*/
usesOnChanges?: boolean;
/**
* Whether the directive is standalone. Defaults to false.
*/
isStandalone?: boolean;
/**
* Whether the directive is a signal-based directive. Defaults to false.
*/
isSignal?: boolean;
/**
* Additional directives applied to the directive host.
*/
hostDirectives?: R3DeclareHostDirectiveMetadata[];
}
/**
* Describes the shape of the object that the `ɵɵngDeclareComponent()` function accepts.
*/
export interface R3DeclareComponentMetadata extends R3DeclareDirectiveMetadata {
/**
* The component's unparsed template string as opaque expression. The template is represented
* using either a string literal or template literal without substitutions, but its value is
* not read directly. Instead, the template parser is given the full source file's text and
* the range of this expression to parse directly from source.
*/
template: o.Expression;
/**
* Whether the template was inline (using `template`) or external (using `templateUrl`).
* Defaults to false.
*/
isInline?: boolean;
/**
* CSS from inline styles and included styleUrls.
*/
styles?: string[];
/**
* List of components which matched in the template, including sufficient
* metadata for each directive to attribute bindings and references within
* the template to each directive specifically, if the runtime instructions
* support this.
*/
components?: R3DeclareDirectiveDependencyMetadata[];
/**
* List of directives which matched in the template, including sufficient
* metadata for each directive to attribute bindings and references within
* the template to each directive specifically, if the runtime instructions
* support this.
*/
directives?: R3DeclareDirectiveDependencyMetadata[];
/**
* List of dependencies which matched in the template, including sufficient
* metadata for each directive/pipe to attribute bindings and references within
* the template to each directive specifically, if the runtime instructions
* support this.
*/
dependencies?: R3DeclareTemplateDependencyMetadata[];
/**
* List of defer block dependency functions, ordered by the appearance
* of the corresponding deferred block in the template.
*/
deferBlockDependencies?: o.Expression[];
/**
* A map of pipe names to an expression referencing the pipe type (possibly a forward reference
* wrapped in a `forwardRef` invocation) which are used in the template.
*/
pipes?: {[pipeName: string]: o.Expression | (() => o.Expression)};
/**
* The list of view providers defined in the component.
*/
viewProviders?: o.Expression;
/**
* A collection of animation triggers that will be used in the component template.
*/
animations?: o.Expression;
/**
* Strategy used for detecting changes in the component.
* Defaults to `ChangeDetectionStrategy.Default`.
*/
changeDetection?: ChangeDetectionStrategy;
/**
* An encapsulation policy for the component's styling.
* Defaults to `ViewEncapsulation.Emulated`.
*/
encapsulation?: ViewEncapsulation;
/**
* Overrides the default interpolation start and end delimiters. Defaults to {{ and }}.
*/
interpolation?: [string, string];
/**
* Whether whitespace in the template should be preserved. Defaults to false.
*/
preserveWhitespaces?: boolean;
}
export type R3DeclareTemplateDependencyMetadata =
| R3DeclareDirectiveDependencyMetadata
| R3DeclarePipeDependencyMetadata
| R3DeclareNgModuleDependencyMetadata;
export interface R3DeclareDirectiveDependencyMetadata {
kind: 'directive' | 'component';
/**
* Selector of the directive.
*/
selector: string;
/**
* Reference to the directive class (possibly a forward reference wrapped in a `forwardRef`
* invocation).
*/
type: o.Expression | (() => o.Expression);
/**
* Property names of the directive's inputs.
*/
inputs?: string[];
/**
* Event names of the directive's outputs.
*/
outputs?: string[];
/**
* Names by which this directive exports itself for references.
*/
exportAs?: string[];
}
export interface R3DeclarePipeDependencyMetadata {
kind: 'pipe';
name: string;
/**
* Reference to the pipe class (possibly a forward reference wrapped in a `forwardRef`
* invocation).
*/
type: o.Expression | (() => o.Expression);
}
export interface R3DeclareNgModuleDependencyMetadata {
kind: 'ngmodule';
type: o.Expression | (() => o.Expression);
}
export interface R3DeclareQueryMetadata {
/**
* Name of the property on the class to update with query results.
*/
propertyName: string;
/**
* Whether to read only the first matching result, or an array of results. Defaults to false.
*/
first?: boolean;
/**
* Either an expression representing a type (possibly wrapped in a `forwardRef()`) or
* `InjectionToken` for the query predicate, or a set of string selectors.
*/
predicate: o.Expression | string[];
/**
* Whether to include only direct children or all descendants. Defaults to false.
*/
descendants?: boolean;
/**
* True to only fire changes if there are underlying changes to the query.
*/
emitDistinctChangesOnly?: boolean;
/**
* An expression representing a type to read from each matched node, or null if the default value
* for a given node is to be returned.
*/
read?: o.Expression;
/**
* Whether or not this query should collect only static results. Defaults to false.
*
* If static is true, the query's results will be set on the component after nodes are created,
* but before change detection runs. This means that any results that relied upon change detection
* to run (e.g. results inside *ngIf or *ngFor views) will not be collected. Query results are
* available in the ngOnInit hook.
*
* If static is false, the query's results will be set on the component after change detection
* runs. This means that the query results can contain nodes inside *ngIf or *ngFor views, but
* the results will not be available in the ngOnInit hook (only in the ngAfterContentInit for
* content hooks and ngAfterViewInit for view hooks).
*/
static?: boolean;
/** Whether the query is signal-based. */
isSignal: boolean;
}
/**
* Describes the shape of the objects that the `ɵɵngDeclareNgModule()` accepts.
*/
export interface R3DeclareNgModuleMetadata extends R3PartialDeclaration {
/**
* An array of expressions representing the bootstrap components specified by the module.
*/
bootstrap?: o.Expression[];
/**
* An array of expressions representing the directives and pipes declared by the module.
*/
declarations?: o.Expression[];
/**
* An array of expressions representing the imports of the module.
*/
imports?: o.Expression[];
/**
* An array of expressions representing the exports of the module.
*/
exports?: o.Expression[];
/**
* The set of schemas that declare elements to be allowed in the NgModule.
*/
schemas?: o.Expression[];
/** Unique ID or expression representing the unique ID of an NgModule. */
id?: o.Expression;
}
/**
* Describes the shape of the objects that the `ɵɵngDeclareInjector()` accepts.
*/
export interface R3DeclareInjectorMetadata extends R3PartialDeclaration {
/**
* The list of providers provided by the injector.
*/
providers?: o.Expression;
/**
* The list of imports into the injector.
*/
imports?: o.Expression[];
}
/**
* Describes the shape of the object that the `ɵɵngDeclarePipe()` function accepts.
*
* This interface serves primarily as documentation, as conformance to this interface is not
* enforced during linking.
*/
export interface R3DeclarePipeMetadata extends R3PartialDeclaration {
/**
* The name to use in templates to refer to this pipe.
*/
name: string;
/**
* Whether this pipe is "pure".
*
* A pure pipe's `transform()` method is only invoked when its input arguments change.
*
* Default: true.
*/
pure?: boolean;
/**
* Whether the pipe is standalone.
*
* Default: false.
*/
isStandalone?: boolean;
}
/**
* Describes the shape of the object that the `ɵɵngDeclareFactory()` function accepts.
*
* This interface serves primarily as documentation, as conformance to this interface is not
* enforced during linking.
*/
export interface R3DeclareFactoryMetadata extends R3PartialDeclaration {
/**
* A collection of dependencies that this factory relies upon.
*
* If this is `null`, then the type's constructor is nonexistent and will be inherited from an
* ancestor of the type.
*
* If this is `'invalid'`, then one or more of the parameters wasn't resolvable and any attempt to
* use these deps will result in a runtime error.
*/
deps: R3DeclareDependencyMetadata[] | 'invalid' | null;
/**
* Type of the target being created by the factory.
*/
target: FactoryTarget;
}
export enum FactoryTarget {
Directive = 0,
Component = 1,
Injectable = 2,
Pipe = 3,
NgModule = 4,
}
/**
* Describes the shape of the object that the `ɵɵngDeclareInjectable()` function accepts.
*
* This interface serves primarily as documentation, as conformance to this interface is not
* enforced during linking.
*/
export interface R3DeclareInjectableMetadata extends R3PartialDeclaration {
/**
* If provided, specifies that the declared injectable belongs to a particular injector:
* - `InjectorType` such as `NgModule`,
* - `'root'` the root injector
* - `'any'` all injectors.
* If not provided, then it does not belong to any injector. Must be explicitly listed in the
* providers of an injector.
*/
providedIn?: o.Expression;
/**
* If provided, an expression that evaluates to a class to use when creating an instance of this
* injectable.
*/
useClass?: o.Expression;
/**
* If provided, an expression that evaluates to a function to use when creating an instance of
* this injectable.
*/
useFactory?: o.Expression;
/**
* If provided, an expression that evaluates to a token of another injectable that this injectable
* aliases.
*/
useExisting?: o.Expression;
/**
* If provided, an expression that evaluates to the value of the instance of this injectable.
*/
useValue?: o.Expression;
/**
* An array of dependencies to support instantiating this injectable via `useClass` or
* `useFactory`.
*/
deps?: R3DeclareDependencyMetadata[];
}
/**
* Metadata indicating how a dependency should be injected into a factory.
*/
export interface R3DeclareDependencyMetadata {
/**
* An expression representing the token or value to be injected, or `null` if the dependency is
* not valid.
*
* If this dependency is due to the `@Attribute()` decorator, then this is an expression
* evaluating to the name of the attribute.
*/
token: o.Expression | null;
/**
* Whether the dependency is injecting an attribute value.
* Default: false.
*/
attribute?: boolean;
/**
* Whether the dependency has an @Host qualifier.
* Default: false,
*/
host?: boolean;
/**
* Whether the dependency has an @Optional qualifier.
* Default: false,
*/
optional?: boolean;
/**
* Whether the dependency has an @Self qualifier.
* Default: false,
*/
self?: boolean;
/**
* Whether the dependency has an @SkipSelf qualifier.
* Default: false,
*/
skipSelf?: boolean;
}
/**
* Describes the shape of the object that the `ɵɵngDeclareClassMetadata()` function accepts.
*
* This interface serves primarily as documentation, as conformance to this interface is not
* enforced during linking.
*/
export interface R3DeclareClassMetadata extends R3PartialDeclaration {
/**
* The Angular decorators of the class.
*/
decorators: o.Expression;
/**
* Optionally specifies the constructor parameters, their types and the Angular decorators of each
* parameter. This property is omitted if the class does not have a constructor.
*/
ctorParameters?: o.Expression;
/**
* Optionally specifies the Angular decorators applied to the class properties. This property is
* omitted if no properties have any decorators.
*/
propDecorators?: o.Expression;
}
/**
* Describes the shape of the object that the `ɵɵngDeclareClassMetadataAsync()` function accepts.
*
* This interface serves primarily as documentation, as conformance to this interface is not
* enforced during linking.
*/
export interface R3DeclareClassMetadataAsync extends R3PartialDeclaration {
/** Function that loads the deferred dependencies associated with the component. */
resolveDeferredDeps: o.Expression;
/**
* Function that, when invoked with the resolved deferred
* dependencies, will return the class metadata.
*/
resolveMetadata: o.Expression;
}
/**
* Describes the shape of the object literal that can be
* passed in as a part of the `hostDirectives` array.
*/
export interface R3DeclareHostDirectiveMetadata {
directive: o.Expression;
inputs?: string[];
outputs?: string[];
}