@angular/compiler-cli 20.1.0-rc.0 → 20.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-SEKYV57I.js → chunk-6HOSNZU5.js} +2 -3
- package/bundles/{chunk-FPHHL4UV.js → chunk-BPDNYZBC.js} +253 -49
- package/bundles/chunk-DWRM7PIK.js +14 -0
- package/bundles/{chunk-TPEB2IXF.js → chunk-GWZQLAGK.js} +35 -7
- package/bundles/{chunk-IRC3OLFO.js → chunk-GXMJGI7A.js} +2004 -554
- package/bundles/{chunk-PML5JK7B.js → chunk-HYJ2H3FU.js} +120 -7
- package/bundles/{chunk-6ECVYRSU.js → chunk-I2BHWRAU.js} +11 -6
- package/bundles/{chunk-QEIHQPSG.js → chunk-JWGODKML.js} +19 -7
- package/bundles/{chunk-SC5ESQGY.js → chunk-NA3RDKZL.js} +27 -11
- package/bundles/{chunk-3NKMA2JO.js → chunk-SZY7NM6F.js} +5 -6
- package/bundles/{chunk-45WGF6MF.js → chunk-WX5V4QZA.js} +656 -126
- package/bundles/index.js +34 -19
- package/bundles/linker/babel/index.js +70 -18
- package/bundles/linker/index.js +11 -5
- package/bundles/private/localize.js +5 -6
- package/bundles/private/migrations.js +5 -6
- package/bundles/private/tooling.js +27 -11
- package/bundles/src/bin/ng_xi18n.js +11 -12
- package/bundles/src/bin/ngc.js +9 -10
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +3 -3
- package/src/ngtsc/docs/src/entities.d.ts +5 -1
- package/src/ngtsc/partial_evaluator/src/interpreter.d.ts +6 -3
- package/src/ngtsc/translator/src/typescript_ast_factory.d.ts +3 -0
- package/src/ngtsc/typecheck/src/expression.d.ts +2 -2
- package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -2
- package/bundles/chunk-2KXD3GSC.js +0 -34
- package/bundles/chunk-2KXD3GSC.js.map +0 -6
- package/bundles/chunk-3NKMA2JO.js.map +0 -6
- package/bundles/chunk-45WGF6MF.js.map +0 -6
- package/bundles/chunk-6ECVYRSU.js.map +0 -6
- package/bundles/chunk-FPHHL4UV.js.map +0 -6
- package/bundles/chunk-IRC3OLFO.js.map +0 -6
- package/bundles/chunk-KPQ72R34.js +0 -23
- package/bundles/chunk-KPQ72R34.js.map +0 -6
- package/bundles/chunk-PML5JK7B.js.map +0 -6
- package/bundles/chunk-QEIHQPSG.js.map +0 -6
- package/bundles/chunk-SC5ESQGY.js.map +0 -6
- package/bundles/chunk-SEKYV57I.js.map +0 -6
- package/bundles/chunk-TPEB2IXF.js.map +0 -6
- package/bundles/index.js.map +0 -6
- package/bundles/linker/babel/index.js.map +0 -6
- package/bundles/linker/index.js.map +0 -6
- package/bundles/private/localize.js.map +0 -6
- package/bundles/private/migrations.js.map +0 -6
- package/bundles/private/tooling.js.map +0 -6
- package/bundles/src/bin/ng_xi18n.js.map +0 -6
- package/bundles/src/bin/ngc.js.map +0 -6
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
angularJitApplicationTransform
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NA3RDKZL.js";
|
|
8
8
|
import {
|
|
9
9
|
AbsoluteModuleStrategy,
|
|
10
10
|
ActivePerfRecorder,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
toUnredirectedSourceFile,
|
|
93
93
|
tryParseInitializerApi,
|
|
94
94
|
untagAllTsFiles
|
|
95
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-GXMJGI7A.js";
|
|
96
96
|
import {
|
|
97
97
|
LogicalFileSystem,
|
|
98
98
|
absoluteFrom,
|
|
@@ -102,9 +102,9 @@ import {
|
|
|
102
102
|
getFileSystem,
|
|
103
103
|
join,
|
|
104
104
|
resolve
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-GWZQLAGK.js";
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// packages/compiler-cli/src/transformers/api.js
|
|
108
108
|
var DEFAULT_ERROR_CODE = 100;
|
|
109
109
|
var UNKNOWN_ERROR_CODE = 500;
|
|
110
110
|
var SOURCE = "angular";
|
|
@@ -122,7 +122,7 @@ var EmitFlags;
|
|
|
122
122
|
EmitFlags2[EmitFlags2["All"] = 31] = "All";
|
|
123
123
|
})(EmitFlags || (EmitFlags = {}));
|
|
124
124
|
|
|
125
|
-
//
|
|
125
|
+
// packages/compiler-cli/src/transformers/compiler_host.js
|
|
126
126
|
import ts from "typescript";
|
|
127
127
|
var wrapHostForTest = null;
|
|
128
128
|
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
|
|
@@ -132,7 +132,7 @@ function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, t
|
|
|
132
132
|
return tsHost;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// packages/compiler-cli/src/ngtsc/docs/src/entities.js
|
|
136
136
|
var EntryType;
|
|
137
137
|
(function(EntryType2) {
|
|
138
138
|
EntryType2["Block"] = "block";
|
|
@@ -179,22 +179,22 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
179
179
|
return "source" in entry;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
//
|
|
182
|
+
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
183
183
|
import ts12 from "typescript";
|
|
184
184
|
|
|
185
|
-
//
|
|
185
|
+
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
186
186
|
import ts6 from "typescript";
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
189
189
|
function isAngularPrivateName(name) {
|
|
190
190
|
const firstChar = name[0] ?? "";
|
|
191
191
|
return firstChar === "\u0275" || firstChar === "_";
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
//
|
|
194
|
+
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
195
195
|
import ts4 from "typescript";
|
|
196
196
|
|
|
197
|
-
//
|
|
197
|
+
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
198
198
|
function extractGenerics(declaration) {
|
|
199
199
|
return declaration.typeParameters?.map((typeParam) => ({
|
|
200
200
|
name: typeParam.name.getText(),
|
|
@@ -203,7 +203,7 @@ function extractGenerics(declaration) {
|
|
|
203
203
|
})) ?? [];
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
//
|
|
206
|
+
// packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.js
|
|
207
207
|
import ts2 from "typescript";
|
|
208
208
|
var decoratorExpression = /@(?=(Injectable|Component|Directive|Pipe|NgModule|Input|Output|HostBinding|HostListener|Inject|Optional|Self|Host|SkipSelf|ViewChild|ViewChildren|ContentChild|ContentChildren))/g;
|
|
209
209
|
function extractJsDocTags(node) {
|
|
@@ -244,13 +244,13 @@ function unescapeAngularDecorators(comment) {
|
|
|
244
244
|
return comment.replace(/_NG_AT_/g, "@");
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
//
|
|
247
|
+
// packages/compiler-cli/src/ngtsc/docs/src/type_extractor.js
|
|
248
248
|
import ts3 from "typescript";
|
|
249
249
|
function extractResolvedTypeString(node, checker) {
|
|
250
250
|
return checker.typeToString(checker.getTypeAtLocation(node), void 0, ts3.TypeFormatFlags.NoTruncation);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
//
|
|
253
|
+
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
254
254
|
var FunctionExtractor = class {
|
|
255
255
|
name;
|
|
256
256
|
exportDeclaration;
|
|
@@ -348,6 +348,7 @@ function extractReturnType(signature, typeChecker) {
|
|
|
348
348
|
return typeChecker.typeToString(
|
|
349
349
|
typeChecker.getReturnTypeOfSignature(signature),
|
|
350
350
|
void 0,
|
|
351
|
+
// This ensures that e.g. `T | undefined` is not reduced to `T`.
|
|
351
352
|
ts4.TypeFormatFlags.NoTypeReduction | ts4.TypeFormatFlags.NoTruncation
|
|
352
353
|
);
|
|
353
354
|
}
|
|
@@ -360,7 +361,7 @@ function findImplementationOfFunction(node, typeChecker) {
|
|
|
360
361
|
return implementation;
|
|
361
362
|
}
|
|
362
363
|
|
|
363
|
-
//
|
|
364
|
+
// packages/compiler-cli/src/ngtsc/docs/src/internal.js
|
|
364
365
|
import ts5 from "typescript";
|
|
365
366
|
function isInternal(member) {
|
|
366
367
|
return extractJsDocTags(member).some((tag) => tag.name === "internal") || hasLeadingInternalComment(member);
|
|
@@ -373,12 +374,14 @@ function hasLeadingInternalComment(member) {
|
|
|
373
374
|
(pos, end, kind, hasTrailingNewLine, containsInternal) => {
|
|
374
375
|
return containsInternal || memberText.slice(pos, end).includes("@internal");
|
|
375
376
|
},
|
|
377
|
+
/* state */
|
|
376
378
|
false,
|
|
379
|
+
/* initial */
|
|
377
380
|
false
|
|
378
381
|
) ?? false;
|
|
379
382
|
}
|
|
380
383
|
|
|
381
|
-
//
|
|
384
|
+
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
382
385
|
var ClassExtractor = class {
|
|
383
386
|
declaration;
|
|
384
387
|
typeChecker;
|
|
@@ -386,6 +389,7 @@ var ClassExtractor = class {
|
|
|
386
389
|
this.declaration = declaration;
|
|
387
390
|
this.typeChecker = typeChecker;
|
|
388
391
|
}
|
|
392
|
+
/** Extract docs info specific to classes. */
|
|
389
393
|
extract() {
|
|
390
394
|
return {
|
|
391
395
|
name: this.declaration.name.text,
|
|
@@ -400,6 +404,7 @@ var ClassExtractor = class {
|
|
|
400
404
|
implements: this.extractInterfaceConformance(this.declaration)
|
|
401
405
|
};
|
|
402
406
|
}
|
|
407
|
+
/** Extracts doc info for a class's members. */
|
|
403
408
|
extractAllClassMembers() {
|
|
404
409
|
const members = [];
|
|
405
410
|
for (const member of this.getMemberDeclarations()) {
|
|
@@ -412,6 +417,7 @@ var ClassExtractor = class {
|
|
|
412
417
|
}
|
|
413
418
|
return members;
|
|
414
419
|
}
|
|
420
|
+
/** Extract docs for a class's members (methods and properties). */
|
|
415
421
|
extractClassMember(memberDeclaration) {
|
|
416
422
|
if (this.isMethod(memberDeclaration)) {
|
|
417
423
|
return this.extractMethod(memberDeclaration);
|
|
@@ -424,9 +430,11 @@ var ClassExtractor = class {
|
|
|
424
430
|
}
|
|
425
431
|
return void 0;
|
|
426
432
|
}
|
|
433
|
+
/** Extract docs for all call signatures in the current class/interface. */
|
|
427
434
|
extractSignatures() {
|
|
428
435
|
return this.computeAllSignatureDeclarations().map((s) => this.extractSignature(s));
|
|
429
436
|
}
|
|
437
|
+
/** Extracts docs for a class method. */
|
|
430
438
|
extractMethod(methodDeclaration) {
|
|
431
439
|
const functionExtractor = new FunctionExtractor(methodDeclaration.name.getText(), methodDeclaration, this.typeChecker);
|
|
432
440
|
return {
|
|
@@ -435,6 +443,7 @@ var ClassExtractor = class {
|
|
|
435
443
|
memberTags: this.getMemberTags(methodDeclaration)
|
|
436
444
|
};
|
|
437
445
|
}
|
|
446
|
+
/** Extracts docs for a signature element (usually inside an interface). */
|
|
438
447
|
extractSignature(signature) {
|
|
439
448
|
const functionExtractor = new FunctionExtractor(ts6.isConstructSignatureDeclaration(signature) ? "new" : "", signature, this.typeChecker);
|
|
440
449
|
return {
|
|
@@ -443,6 +452,7 @@ var ClassExtractor = class {
|
|
|
443
452
|
memberTags: []
|
|
444
453
|
};
|
|
445
454
|
}
|
|
455
|
+
/** Extracts doc info for a property declaration. */
|
|
446
456
|
extractClassProperty(propertyDeclaration) {
|
|
447
457
|
return {
|
|
448
458
|
name: propertyDeclaration.name.getText(),
|
|
@@ -453,6 +463,7 @@ var ClassExtractor = class {
|
|
|
453
463
|
jsdocTags: extractJsDocTags(propertyDeclaration)
|
|
454
464
|
};
|
|
455
465
|
}
|
|
466
|
+
/** Extracts doc info for an accessor member (getter/setter). */
|
|
456
467
|
extractGetterSetter(accessor) {
|
|
457
468
|
return {
|
|
458
469
|
...this.extractClassProperty(accessor),
|
|
@@ -486,6 +497,7 @@ var ClassExtractor = class {
|
|
|
486
497
|
const implementClause = declaration.heritageClauses?.find((clause) => clause.token === ts6.SyntaxKind.ImplementsKeyword);
|
|
487
498
|
return implementClause?.types.map((m) => m.getText()) ?? [];
|
|
488
499
|
}
|
|
500
|
+
/** Gets the tags for a member (protected, readonly, static, etc.) */
|
|
489
501
|
getMemberTags(member) {
|
|
490
502
|
const tags = this.getMemberTagsFromModifiers(member.modifiers ?? []);
|
|
491
503
|
if (member.questionToken) {
|
|
@@ -496,6 +508,7 @@ var ClassExtractor = class {
|
|
|
496
508
|
}
|
|
497
509
|
return tags;
|
|
498
510
|
}
|
|
511
|
+
/** Computes all signature declarations of the class/interface. */
|
|
499
512
|
computeAllSignatureDeclarations() {
|
|
500
513
|
const type = this.typeChecker.getTypeAtLocation(this.declaration);
|
|
501
514
|
const signatures = [...type.getCallSignatures(), ...type.getConstructSignatures()];
|
|
@@ -508,6 +521,7 @@ var ClassExtractor = class {
|
|
|
508
521
|
}
|
|
509
522
|
return result;
|
|
510
523
|
}
|
|
524
|
+
/** Gets all member declarations, including inherited members. */
|
|
511
525
|
getMemberDeclarations() {
|
|
512
526
|
const type = this.typeChecker.getTypeAtLocation(this.declaration);
|
|
513
527
|
const members = type.getProperties();
|
|
@@ -525,6 +539,7 @@ var ClassExtractor = class {
|
|
|
525
539
|
}
|
|
526
540
|
return result;
|
|
527
541
|
}
|
|
542
|
+
/** The result only contains properties, method implementations and abstracts */
|
|
528
543
|
filterMethodOverloads(declarations) {
|
|
529
544
|
return declarations.filter((declaration, index) => {
|
|
530
545
|
if (ts6.isFunctionDeclaration(declaration) || ts6.isMethodDeclaration(declaration) || ts6.isConstructorDeclaration(declaration)) {
|
|
@@ -535,6 +550,7 @@ var ClassExtractor = class {
|
|
|
535
550
|
return true;
|
|
536
551
|
});
|
|
537
552
|
}
|
|
553
|
+
/** Get the tags for a member that come from the declaration modifiers. */
|
|
538
554
|
getMemberTagsFromModifiers(mods) {
|
|
539
555
|
const tags = [];
|
|
540
556
|
for (const mod of mods) {
|
|
@@ -544,6 +560,7 @@ var ClassExtractor = class {
|
|
|
544
560
|
}
|
|
545
561
|
return tags;
|
|
546
562
|
}
|
|
563
|
+
/** Gets the doc tag corresponding to a class member modifier (readonly, protected, etc.). */
|
|
547
564
|
getTagForMemberModifier(mod) {
|
|
548
565
|
switch (mod.kind) {
|
|
549
566
|
case ts6.SyntaxKind.StaticKeyword:
|
|
@@ -558,34 +575,55 @@ var ClassExtractor = class {
|
|
|
558
575
|
return void 0;
|
|
559
576
|
}
|
|
560
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Gets whether a given class member should be excluded from public API docs.
|
|
580
|
+
* This is the case if:
|
|
581
|
+
* - The member does not have a name
|
|
582
|
+
* - The member is neither a method nor property
|
|
583
|
+
* - The member is private
|
|
584
|
+
* - The member has a name that marks it as Angular-internal.
|
|
585
|
+
* - The member is marked as internal via JSDoc.
|
|
586
|
+
*/
|
|
561
587
|
isMemberExcluded(member) {
|
|
562
588
|
if (ts6.isConstructorDeclaration(member)) {
|
|
563
589
|
return false;
|
|
564
590
|
}
|
|
565
591
|
return !member.name || !this.isDocumentableMember(member) || !ts6.isCallSignatureDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts6.SyntaxKind.PrivateKeyword) || member.name.getText() === "prototype" || isAngularPrivateName(member.name.getText()) || isInternal(member);
|
|
566
592
|
}
|
|
593
|
+
/** Gets whether a class member is a method, property, or accessor. */
|
|
567
594
|
isDocumentableMember(member) {
|
|
568
|
-
return this.isMethod(member) || this.isProperty(member) || ts6.isAccessor(member) || ts6.isConstructorDeclaration(member) ||
|
|
595
|
+
return this.isMethod(member) || this.isProperty(member) || ts6.isAccessor(member) || ts6.isConstructorDeclaration(member) || // Signatures are documentable if they are part of an interface.
|
|
596
|
+
ts6.isCallSignatureDeclaration(member);
|
|
569
597
|
}
|
|
598
|
+
/** Check if the parameter is a constructor parameter with a public modifier */
|
|
570
599
|
isPublicConstructorParameterProperty(node) {
|
|
571
600
|
if (ts6.isParameterPropertyDeclaration(node, node.parent) && node.modifiers) {
|
|
572
601
|
return node.modifiers.some((modifier) => modifier.kind === ts6.SyntaxKind.PublicKeyword);
|
|
573
602
|
}
|
|
574
603
|
return false;
|
|
575
604
|
}
|
|
605
|
+
/** Gets whether a member is a property. */
|
|
576
606
|
isProperty(member) {
|
|
577
607
|
return ts6.isPropertyDeclaration(member) || ts6.isPropertySignature(member) || this.isPublicConstructorParameterProperty(member);
|
|
578
608
|
}
|
|
609
|
+
/** Gets whether a member is a method. */
|
|
579
610
|
isMethod(member) {
|
|
580
611
|
return ts6.isMethodDeclaration(member) || ts6.isMethodSignature(member);
|
|
581
612
|
}
|
|
613
|
+
/** Gets whether the given signature declaration is documentable. */
|
|
582
614
|
isDocumentableSignature(signature) {
|
|
583
615
|
return ts6.isConstructSignatureDeclaration(signature) || ts6.isCallSignatureDeclaration(signature);
|
|
584
616
|
}
|
|
617
|
+
/** Gets whether the declaration for this extractor is abstract. */
|
|
585
618
|
isAbstract() {
|
|
586
619
|
const modifiers = this.declaration.modifiers ?? [];
|
|
587
620
|
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
588
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
|
|
624
|
+
*
|
|
625
|
+
* This will prevent exposing private computed properties in the docs.
|
|
626
|
+
*/
|
|
589
627
|
hasPrivateComputedProperty(property) {
|
|
590
628
|
return ts6.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith("\u0275");
|
|
591
629
|
}
|
|
@@ -598,6 +636,7 @@ var DirectiveExtractor = class extends ClassExtractor {
|
|
|
598
636
|
this.reference = reference;
|
|
599
637
|
this.metadata = metadata;
|
|
600
638
|
}
|
|
639
|
+
/** Extract docs info for directives and components (including underlying class info). */
|
|
601
640
|
extract() {
|
|
602
641
|
return {
|
|
603
642
|
...super.extract(),
|
|
@@ -607,6 +646,7 @@ var DirectiveExtractor = class extends ClassExtractor {
|
|
|
607
646
|
entryType: this.metadata.isComponent ? EntryType.Component : EntryType.Directive
|
|
608
647
|
};
|
|
609
648
|
}
|
|
649
|
+
/** Extracts docs info for a directive property, including input/output metadata. */
|
|
610
650
|
extractClassProperty(propertyDeclaration) {
|
|
611
651
|
const entry = super.extractClassProperty(propertyDeclaration);
|
|
612
652
|
const inputMetadata = this.getInputMetadata(propertyDeclaration);
|
|
@@ -622,10 +662,12 @@ var DirectiveExtractor = class extends ClassExtractor {
|
|
|
622
662
|
}
|
|
623
663
|
return entry;
|
|
624
664
|
}
|
|
665
|
+
/** Gets the input metadata for a directive property. */
|
|
625
666
|
getInputMetadata(prop) {
|
|
626
667
|
const propName = prop.name.getText();
|
|
627
668
|
return this.metadata.inputs?.getByClassPropertyName(propName) ?? void 0;
|
|
628
669
|
}
|
|
670
|
+
/** Gets the output metadata for a directive property. */
|
|
629
671
|
getOutputMetadata(prop) {
|
|
630
672
|
const propName = prop.name.getText();
|
|
631
673
|
return this.metadata?.outputs?.getByClassPropertyName(propName) ?? void 0;
|
|
@@ -696,7 +738,7 @@ function extractPipeSyntax(metadata, classDeclaration) {
|
|
|
696
738
|
return `{{ value_expression | ${metadata.name}${paramNames.length ? ":" + paramNames.join(":") : ""} }}`;
|
|
697
739
|
}
|
|
698
740
|
|
|
699
|
-
//
|
|
741
|
+
// packages/compiler-cli/src/ngtsc/docs/src/constant_extractor.js
|
|
700
742
|
import ts7 from "typescript";
|
|
701
743
|
var LITERAL_AS_ENUM_TAG = "object-literal-as-enum";
|
|
702
744
|
function extractConstant(declaration, typeChecker) {
|
|
@@ -754,14 +796,21 @@ function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
|
754
796
|
});
|
|
755
797
|
}
|
|
756
798
|
|
|
757
|
-
//
|
|
799
|
+
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
758
800
|
import ts8 from "typescript";
|
|
759
801
|
function extractorDecorator(declaration, typeChecker) {
|
|
760
|
-
const documentedNode = getDecoratorJsDocNode(declaration);
|
|
802
|
+
const documentedNode = getDecoratorJsDocNode(declaration, typeChecker);
|
|
761
803
|
const decoratorType = getDecoratorType(declaration);
|
|
762
804
|
if (!decoratorType) {
|
|
763
805
|
throw new Error(`"${declaration.name.getText()} is not a decorator."`);
|
|
764
806
|
}
|
|
807
|
+
const members = getDecoratorProperties(declaration, typeChecker);
|
|
808
|
+
let signatures = [];
|
|
809
|
+
if (!members) {
|
|
810
|
+
const decoratorInterface = getDecoratorDeclaration(declaration, typeChecker);
|
|
811
|
+
const callSignatures = decoratorInterface.members.filter(ts8.isCallSignatureDeclaration);
|
|
812
|
+
signatures = getDecoratorSignatures(callSignatures, typeChecker);
|
|
813
|
+
}
|
|
765
814
|
return {
|
|
766
815
|
name: declaration.name.getText(),
|
|
767
816
|
decoratorType,
|
|
@@ -769,7 +818,8 @@ function extractorDecorator(declaration, typeChecker) {
|
|
|
769
818
|
rawComment: extractRawJsDoc(documentedNode),
|
|
770
819
|
description: extractJsDocDescription(documentedNode),
|
|
771
820
|
jsdocTags: extractJsDocTags(documentedNode),
|
|
772
|
-
members
|
|
821
|
+
members,
|
|
822
|
+
signatures
|
|
773
823
|
};
|
|
774
824
|
}
|
|
775
825
|
function isDecoratorDeclaration(declaration) {
|
|
@@ -788,44 +838,100 @@ function getDecoratorType(declaration) {
|
|
|
788
838
|
return DecoratorType.Parameter;
|
|
789
839
|
return void 0;
|
|
790
840
|
}
|
|
791
|
-
function
|
|
792
|
-
const
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
841
|
+
function getDecoratorDeclaration(declaration, typeChecker) {
|
|
842
|
+
const decoratorName = declaration.name.getText();
|
|
843
|
+
const decoratorDeclaration = declaration;
|
|
844
|
+
const decoratorType = typeChecker.getTypeAtLocation(decoratorDeclaration);
|
|
845
|
+
const aliasDeclaration = decoratorType.getSymbol().getDeclarations()[0];
|
|
846
|
+
const decoratorInterface = aliasDeclaration;
|
|
847
|
+
if (!decoratorInterface || !ts8.isInterfaceDeclaration(decoratorInterface)) {
|
|
848
|
+
throw new Error(`No decorator interface found for "${decoratorName}".`);
|
|
798
849
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
850
|
+
return decoratorInterface;
|
|
851
|
+
}
|
|
852
|
+
function getDecoratorProperties(declaration, typeChecker) {
|
|
853
|
+
const decoratorCallSig = getDecoratorJsDocNode(declaration, typeChecker);
|
|
854
|
+
const decoratorFirstParam = decoratorCallSig.parameters[0];
|
|
855
|
+
const firstParamType = typeChecker.getTypeAtLocation(decoratorFirstParam);
|
|
856
|
+
let firstParamTypeDecl;
|
|
857
|
+
if (firstParamType.isUnion()) {
|
|
858
|
+
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags & ts8.TypeFlags.Undefined) === 0);
|
|
859
|
+
firstParamTypeDecl = firstParamTypeUnion?.getSymbol()?.getDeclarations()[0];
|
|
803
860
|
} else {
|
|
804
|
-
|
|
861
|
+
firstParamTypeDecl = firstParamType.getSymbol()?.getDeclarations()[0];
|
|
805
862
|
}
|
|
806
|
-
if (!
|
|
807
|
-
|
|
863
|
+
if (!firstParamTypeDecl || !ts8.isInterfaceDeclaration(firstParamTypeDecl)) {
|
|
864
|
+
return null;
|
|
808
865
|
}
|
|
809
|
-
|
|
866
|
+
const interfaceDeclaration = firstParamTypeDecl;
|
|
867
|
+
return extractInterface(interfaceDeclaration, typeChecker).members;
|
|
810
868
|
}
|
|
811
|
-
function
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
869
|
+
function getDecoratorSignatures(callSignatures, typeChecker) {
|
|
870
|
+
return callSignatures.map((signatureDecl) => {
|
|
871
|
+
return {
|
|
872
|
+
parameters: extractParams(signatureDecl.parameters, typeChecker),
|
|
873
|
+
jsdocTags: extractJsDocTags(signatureDecl)
|
|
874
|
+
};
|
|
815
875
|
});
|
|
876
|
+
}
|
|
877
|
+
function extractParams(params, typeChecker) {
|
|
878
|
+
return params.map((param) => ({
|
|
879
|
+
name: param.name.getText(),
|
|
880
|
+
description: extractJsDocDescription(param),
|
|
881
|
+
type: getParamTypeString(param, typeChecker),
|
|
882
|
+
isOptional: !!(param.questionToken || param.initializer),
|
|
883
|
+
isRestParam: !!param.dotDotDotToken
|
|
884
|
+
}));
|
|
885
|
+
}
|
|
886
|
+
function getDecoratorInterface(declaration, typeChecker) {
|
|
887
|
+
const name = declaration.name.getText();
|
|
888
|
+
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
889
|
+
const decoratorType = typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
890
|
+
const decoratorInterface = decoratorType.getSymbol()?.getDeclarations()[0];
|
|
816
891
|
if (!decoratorInterface || !ts8.isInterfaceDeclaration(decoratorInterface)) {
|
|
817
|
-
throw new Error(`No interface "${name}
|
|
892
|
+
throw new Error(`No decorator interface found for "${name}".`);
|
|
818
893
|
}
|
|
819
|
-
|
|
894
|
+
return decoratorInterface;
|
|
895
|
+
}
|
|
896
|
+
function getDecoratorJsDocNode(declaration, typeChecker) {
|
|
897
|
+
const name = declaration.name.getText();
|
|
898
|
+
const decoratorInterface = getDecoratorInterface(declaration, typeChecker);
|
|
899
|
+
const callSignature = decoratorInterface.members.filter((node) => {
|
|
820
900
|
return ts8.isCallSignatureDeclaration(node) && extractRawJsDoc(node);
|
|
821
|
-
});
|
|
901
|
+
}).at(-1);
|
|
822
902
|
if (!callSignature || !ts8.isCallSignatureDeclaration(callSignature)) {
|
|
823
903
|
throw new Error(`No call signature with JsDoc on "${name}Decorator"`);
|
|
824
904
|
}
|
|
825
905
|
return callSignature;
|
|
826
906
|
}
|
|
907
|
+
function getParamTypeString(paramNode, typeChecker) {
|
|
908
|
+
const type = typeChecker.getTypeAtLocation(paramNode);
|
|
909
|
+
const printer = ts8.createPrinter({ removeComments: true });
|
|
910
|
+
const sourceFile = paramNode.getSourceFile();
|
|
911
|
+
const replace = [];
|
|
912
|
+
if (type.isUnion()) {
|
|
913
|
+
for (const subType of type.types) {
|
|
914
|
+
const decl = subType.getSymbol()?.getDeclarations()?.[0];
|
|
915
|
+
if (decl && ts8.isInterfaceDeclaration(decl) && decl.name.text !== "Function") {
|
|
916
|
+
replace.push({
|
|
917
|
+
initial: subType.symbol.name,
|
|
918
|
+
replacedWith: expandType(decl, sourceFile, printer)
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
let result = printer.printNode(ts8.EmitHint.Unspecified, paramNode, sourceFile).replace(new RegExp(`${paramNode.name.getText()}\\??: `), "").replaceAll(/\s+/g, " ");
|
|
924
|
+
for (const { initial, replacedWith } of replace) {
|
|
925
|
+
result = result.replace(initial, replacedWith);
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
function expandType(decl, sourceFile, printer) {
|
|
930
|
+
const props = decl.members.map((member) => printer.printNode(ts8.EmitHint.Unspecified, member, sourceFile)).join(" ").replaceAll(/\s+/g, " ");
|
|
931
|
+
return `{${props}}`;
|
|
932
|
+
}
|
|
827
933
|
|
|
828
|
-
//
|
|
934
|
+
// packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.js
|
|
829
935
|
import ts9 from "typescript";
|
|
830
936
|
function extractEnum(declaration, typeChecker) {
|
|
831
937
|
return {
|
|
@@ -855,7 +961,7 @@ function getEnumMemberValue(memberNode) {
|
|
|
855
961
|
return literal?.getText() ?? "";
|
|
856
962
|
}
|
|
857
963
|
|
|
858
|
-
//
|
|
964
|
+
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
859
965
|
import ts10 from "typescript";
|
|
860
966
|
var initializerApiTag = "initializerApiFunction";
|
|
861
967
|
function isInitializerApiFunction(node, typeChecker) {
|
|
@@ -959,11 +1065,12 @@ function extractFunctionWithOverloads(name, type, typeChecker) {
|
|
|
959
1065
|
return {
|
|
960
1066
|
name,
|
|
961
1067
|
signatures: extractCallSignatures(name, typeChecker, type),
|
|
1068
|
+
// Implementation may be populated later.
|
|
962
1069
|
implementation: null
|
|
963
1070
|
};
|
|
964
1071
|
}
|
|
965
1072
|
|
|
966
|
-
//
|
|
1073
|
+
// packages/compiler-cli/src/ngtsc/docs/src/type_alias_extractor.js
|
|
967
1074
|
function extractTypeAlias(declaration) {
|
|
968
1075
|
return {
|
|
969
1076
|
name: declaration.name.getText(),
|
|
@@ -976,7 +1083,7 @@ function extractTypeAlias(declaration) {
|
|
|
976
1083
|
};
|
|
977
1084
|
}
|
|
978
1085
|
|
|
979
|
-
//
|
|
1086
|
+
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
980
1087
|
import ts11 from "typescript";
|
|
981
1088
|
function getImportedSymbols(sourceFile) {
|
|
982
1089
|
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
@@ -1000,7 +1107,7 @@ function getImportedSymbols(sourceFile) {
|
|
|
1000
1107
|
return importSpecifiers;
|
|
1001
1108
|
}
|
|
1002
1109
|
|
|
1003
|
-
//
|
|
1110
|
+
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
1004
1111
|
var DocsExtractor = class {
|
|
1005
1112
|
typeChecker;
|
|
1006
1113
|
metadataReader;
|
|
@@ -1008,6 +1115,12 @@ var DocsExtractor = class {
|
|
|
1008
1115
|
this.typeChecker = typeChecker;
|
|
1009
1116
|
this.metadataReader = metadataReader;
|
|
1010
1117
|
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Gets the set of all documentable entries from a source file, including
|
|
1120
|
+
* declarations that are re-exported from this file as an entry-point.
|
|
1121
|
+
*
|
|
1122
|
+
* @param sourceFile The file from which to extract documentable entries.
|
|
1123
|
+
*/
|
|
1011
1124
|
extractAll(sourceFile, rootDir, privateModules) {
|
|
1012
1125
|
const entries = [];
|
|
1013
1126
|
const symbols = /* @__PURE__ */ new Map();
|
|
@@ -1031,6 +1144,7 @@ var DocsExtractor = class {
|
|
|
1031
1144
|
});
|
|
1032
1145
|
entry.source = {
|
|
1033
1146
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1147
|
+
// Start & End are off by 1
|
|
1034
1148
|
startLine: ts12.getLineAndCharacterOfPosition(realSourceFile, node.getStart()).line + 1,
|
|
1035
1149
|
endLine: ts12.getLineAndCharacterOfPosition(realSourceFile, node.getEnd()).line + 1
|
|
1036
1150
|
};
|
|
@@ -1039,6 +1153,7 @@ var DocsExtractor = class {
|
|
|
1039
1153
|
}
|
|
1040
1154
|
return { entries, symbols };
|
|
1041
1155
|
}
|
|
1156
|
+
/** Extract the doc entry for a single declaration. */
|
|
1042
1157
|
extractDeclaration(node) {
|
|
1043
1158
|
if (isNamedClassDeclaration(node)) {
|
|
1044
1159
|
return extractClass(node, this.metadataReader, this.typeChecker);
|
|
@@ -1064,6 +1179,7 @@ var DocsExtractor = class {
|
|
|
1064
1179
|
}
|
|
1065
1180
|
return null;
|
|
1066
1181
|
}
|
|
1182
|
+
/** Gets the list of exported declarations for doc extraction. */
|
|
1067
1183
|
getExportedDeclarations(sourceFile) {
|
|
1068
1184
|
const reflector = new TypeScriptReflectionHost(this.typeChecker, false, true);
|
|
1069
1185
|
const exportedDeclarationMap = reflector.getExportsOfModule(sourceFile);
|
|
@@ -1087,11 +1203,11 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1087
1203
|
return relativePath;
|
|
1088
1204
|
}
|
|
1089
1205
|
|
|
1090
|
-
//
|
|
1206
|
+
// packages/compiler-cli/src/ngtsc/program.js
|
|
1091
1207
|
import { HtmlParser, MessageBundle } from "@angular/compiler";
|
|
1092
1208
|
import ts27 from "typescript";
|
|
1093
1209
|
|
|
1094
|
-
//
|
|
1210
|
+
// packages/compiler-cli/src/transformers/i18n.js
|
|
1095
1211
|
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
|
|
1096
1212
|
import * as path from "path";
|
|
1097
1213
|
function i18nGetExtension(formatName) {
|
|
@@ -1142,10 +1258,10 @@ function getPathNormalizer(basePath) {
|
|
|
1142
1258
|
};
|
|
1143
1259
|
}
|
|
1144
1260
|
|
|
1145
|
-
//
|
|
1261
|
+
// packages/compiler-cli/src/typescript_support.js
|
|
1146
1262
|
import ts13 from "typescript";
|
|
1147
1263
|
|
|
1148
|
-
//
|
|
1264
|
+
// packages/compiler-cli/src/version_helpers.js
|
|
1149
1265
|
function toNumbers(value) {
|
|
1150
1266
|
const suffixIndex = value.lastIndexOf("-");
|
|
1151
1267
|
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
|
|
@@ -1180,7 +1296,7 @@ function compareVersions(v1, v2) {
|
|
|
1180
1296
|
return compareNumbers(toNumbers(v1), toNumbers(v2));
|
|
1181
1297
|
}
|
|
1182
1298
|
|
|
1183
|
-
//
|
|
1299
|
+
// packages/compiler-cli/src/typescript_support.js
|
|
1184
1300
|
var MIN_TS_VERSION = "5.8.0";
|
|
1185
1301
|
var MAX_TS_VERSION = "5.9.0";
|
|
1186
1302
|
var tsVersion = ts13.version;
|
|
@@ -1193,22 +1309,41 @@ function verifySupportedTypeScriptVersion() {
|
|
|
1193
1309
|
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
|
|
1194
1310
|
}
|
|
1195
1311
|
|
|
1196
|
-
//
|
|
1312
|
+
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1197
1313
|
import ts25 from "typescript";
|
|
1198
1314
|
|
|
1199
|
-
//
|
|
1315
|
+
// packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
|
|
1200
1316
|
var CycleAnalyzer = class {
|
|
1201
1317
|
importGraph;
|
|
1318
|
+
/**
|
|
1319
|
+
* Cycle detection is requested with the same `from` source file for all used directives and pipes
|
|
1320
|
+
* within a component, which makes it beneficial to cache the results as long as the `from` source
|
|
1321
|
+
* file has not changed. This avoids visiting the import graph that is reachable from multiple
|
|
1322
|
+
* directives/pipes more than once.
|
|
1323
|
+
*/
|
|
1202
1324
|
cachedResults = null;
|
|
1203
1325
|
constructor(importGraph) {
|
|
1204
1326
|
this.importGraph = importGraph;
|
|
1205
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Check for a cycle to be created in the `ts.Program` by adding an import between `from` and
|
|
1330
|
+
* `to`.
|
|
1331
|
+
*
|
|
1332
|
+
* @returns a `Cycle` object if an import between `from` and `to` would create a cycle; `null`
|
|
1333
|
+
* otherwise.
|
|
1334
|
+
*/
|
|
1206
1335
|
wouldCreateCycle(from, to) {
|
|
1207
1336
|
if (this.cachedResults === null || this.cachedResults.from !== from) {
|
|
1208
1337
|
this.cachedResults = new CycleResults(from, this.importGraph);
|
|
1209
1338
|
}
|
|
1210
1339
|
return this.cachedResults.wouldBeCyclic(to) ? new Cycle(this.importGraph, from, to) : null;
|
|
1211
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Record a synthetic import from `from` to `to`.
|
|
1343
|
+
*
|
|
1344
|
+
* This is an import that doesn't exist in the `ts.Program` but will be considered as part of the
|
|
1345
|
+
* import graph for cycle creation.
|
|
1346
|
+
*/
|
|
1212
1347
|
recordSyntheticImport(from, to) {
|
|
1213
1348
|
this.cachedResults = null;
|
|
1214
1349
|
this.importGraph.addSyntheticImport(from, to);
|
|
@@ -1242,6 +1377,10 @@ var CycleResults = class {
|
|
|
1242
1377
|
}
|
|
1243
1378
|
return false;
|
|
1244
1379
|
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Returns whether the source file is already known to be cyclic, or `null` if the result is not
|
|
1382
|
+
* yet known.
|
|
1383
|
+
*/
|
|
1245
1384
|
getCachedResult(sf) {
|
|
1246
1385
|
const result = sf[NgCyclicResult];
|
|
1247
1386
|
if (result === this.cyclic) {
|
|
@@ -1268,12 +1407,18 @@ var Cycle = class {
|
|
|
1268
1407
|
this.from = from;
|
|
1269
1408
|
this.to = to;
|
|
1270
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Compute an array of source-files that illustrates the cyclic path between `from` and `to`.
|
|
1412
|
+
*
|
|
1413
|
+
* Note that a `Cycle` will not be created unless a path is available between `to` and `from`,
|
|
1414
|
+
* so `findPath()` will never return `null`.
|
|
1415
|
+
*/
|
|
1271
1416
|
getPath() {
|
|
1272
1417
|
return [this.from, ...this.importGraph.findPath(this.to, this.from)];
|
|
1273
1418
|
}
|
|
1274
1419
|
};
|
|
1275
1420
|
|
|
1276
|
-
//
|
|
1421
|
+
// packages/compiler-cli/src/ngtsc/cycles/src/imports.js
|
|
1277
1422
|
import ts14 from "typescript";
|
|
1278
1423
|
var ImportGraph = class {
|
|
1279
1424
|
checker;
|
|
@@ -1283,12 +1428,28 @@ var ImportGraph = class {
|
|
|
1283
1428
|
this.checker = checker;
|
|
1284
1429
|
this.perf = perf;
|
|
1285
1430
|
}
|
|
1431
|
+
/**
|
|
1432
|
+
* List the direct (not transitive) imports of a given `ts.SourceFile`.
|
|
1433
|
+
*
|
|
1434
|
+
* This operation is cached.
|
|
1435
|
+
*/
|
|
1286
1436
|
importsOf(sf) {
|
|
1287
1437
|
if (!this.imports.has(sf)) {
|
|
1288
1438
|
this.imports.set(sf, this.scanImports(sf));
|
|
1289
1439
|
}
|
|
1290
1440
|
return this.imports.get(sf);
|
|
1291
1441
|
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Find an import path from the `start` SourceFile to the `end` SourceFile.
|
|
1444
|
+
*
|
|
1445
|
+
* This function implements a breadth first search that results in finding the
|
|
1446
|
+
* shortest path between the `start` and `end` points.
|
|
1447
|
+
*
|
|
1448
|
+
* @param start the starting point of the path.
|
|
1449
|
+
* @param end the ending point of the path.
|
|
1450
|
+
* @returns an array of source files that connect the `start` and `end` source files, or `null` if
|
|
1451
|
+
* no path could be found.
|
|
1452
|
+
*/
|
|
1292
1453
|
findPath(start, end) {
|
|
1293
1454
|
if (start === end) {
|
|
1294
1455
|
return [start];
|
|
@@ -1311,6 +1472,10 @@ var ImportGraph = class {
|
|
|
1311
1472
|
}
|
|
1312
1473
|
return null;
|
|
1313
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Add a record of an import from `sf` to `imported`, that's not present in the original
|
|
1477
|
+
* `ts.Program` but will be remembered by the `ImportGraph`.
|
|
1478
|
+
*/
|
|
1314
1479
|
addSyntheticImport(sf, imported) {
|
|
1315
1480
|
if (isLocalFile(imported)) {
|
|
1316
1481
|
this.importsOf(sf).add(imported);
|
|
@@ -1358,6 +1523,10 @@ var Found = class {
|
|
|
1358
1523
|
this.sourceFile = sourceFile;
|
|
1359
1524
|
this.parent = parent;
|
|
1360
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Back track through this found SourceFile and its ancestors to generate an array of
|
|
1528
|
+
* SourceFiles that form am import path between two SourceFiles.
|
|
1529
|
+
*/
|
|
1361
1530
|
toPath() {
|
|
1362
1531
|
const array = [];
|
|
1363
1532
|
let current = this;
|
|
@@ -1369,7 +1538,7 @@ var Found = class {
|
|
|
1369
1538
|
}
|
|
1370
1539
|
};
|
|
1371
1540
|
|
|
1372
|
-
//
|
|
1541
|
+
// packages/compiler-cli/src/ngtsc/entry_point/src/generator.js
|
|
1373
1542
|
import ts15 from "typescript";
|
|
1374
1543
|
var FlatIndexGenerator = class {
|
|
1375
1544
|
entryPoint;
|
|
@@ -1397,7 +1566,7 @@ export * from '${relativeEntryPoint}';
|
|
|
1397
1566
|
}
|
|
1398
1567
|
};
|
|
1399
1568
|
|
|
1400
|
-
//
|
|
1569
|
+
// packages/compiler-cli/src/ngtsc/entry_point/src/logic.js
|
|
1401
1570
|
function findFlatIndexEntryPoint(rootFiles) {
|
|
1402
1571
|
const tsFiles = rootFiles.filter((file) => isNonDeclarationTsPath(file));
|
|
1403
1572
|
let resolvedEntryPoint = null;
|
|
@@ -1413,7 +1582,7 @@ function findFlatIndexEntryPoint(rootFiles) {
|
|
|
1413
1582
|
return resolvedEntryPoint;
|
|
1414
1583
|
}
|
|
1415
1584
|
|
|
1416
|
-
//
|
|
1585
|
+
// packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.js
|
|
1417
1586
|
import ts16 from "typescript";
|
|
1418
1587
|
function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
1419
1588
|
const diagnostics = [];
|
|
@@ -1493,7 +1662,7 @@ function getDescriptorOfDeclaration(decl) {
|
|
|
1493
1662
|
}
|
|
1494
1663
|
}
|
|
1495
1664
|
|
|
1496
|
-
//
|
|
1665
|
+
// packages/compiler-cli/src/ngtsc/entry_point/src/reference_graph.js
|
|
1497
1666
|
var ReferenceGraph = class {
|
|
1498
1667
|
references = /* @__PURE__ */ new Map();
|
|
1499
1668
|
add(from, to) {
|
|
@@ -1545,7 +1714,7 @@ var ReferenceGraph = class {
|
|
|
1545
1714
|
}
|
|
1546
1715
|
};
|
|
1547
1716
|
|
|
1548
|
-
//
|
|
1717
|
+
// packages/compiler-cli/src/ngtsc/incremental/src/dependency_tracking.js
|
|
1549
1718
|
var FileDependencyGraph = class {
|
|
1550
1719
|
nodes = /* @__PURE__ */ new Map();
|
|
1551
1720
|
addDependency(from, on) {
|
|
@@ -1561,6 +1730,27 @@ var FileDependencyGraph = class {
|
|
|
1561
1730
|
const node = this.nodes.get(from);
|
|
1562
1731
|
return node ? [...node.usesResources] : [];
|
|
1563
1732
|
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Update the current dependency graph from a previous one, incorporating a set of physical
|
|
1735
|
+
* changes.
|
|
1736
|
+
*
|
|
1737
|
+
* This method performs two tasks:
|
|
1738
|
+
*
|
|
1739
|
+
* 1. For files which have not logically changed, their dependencies from `previous` are added to
|
|
1740
|
+
* `this` graph.
|
|
1741
|
+
* 2. For files which have logically changed, they're added to a set of logically changed files
|
|
1742
|
+
* which is eventually returned.
|
|
1743
|
+
*
|
|
1744
|
+
* In essence, for build `n`, this method performs:
|
|
1745
|
+
*
|
|
1746
|
+
* G(n) + L(n) = G(n - 1) + P(n)
|
|
1747
|
+
*
|
|
1748
|
+
* where:
|
|
1749
|
+
*
|
|
1750
|
+
* G(n) = the dependency graph of build `n`
|
|
1751
|
+
* L(n) = the logically changed files from build n - 1 to build n.
|
|
1752
|
+
* P(n) = the physically changed files from build n - 1 to build n.
|
|
1753
|
+
*/
|
|
1564
1754
|
updateWithPhysicalChanges(previous, changedTsPaths, deletedTsPaths, changedResources) {
|
|
1565
1755
|
const logicallyChanged = /* @__PURE__ */ new Set();
|
|
1566
1756
|
for (const sf of previous.nodes.keys()) {
|
|
@@ -1610,7 +1800,7 @@ function isLogicallyChanged(sf, node, changedTsPaths, deletedTsPaths, changedRes
|
|
|
1610
1800
|
return false;
|
|
1611
1801
|
}
|
|
1612
1802
|
|
|
1613
|
-
//
|
|
1803
|
+
// packages/compiler-cli/src/ngtsc/incremental/src/state.js
|
|
1614
1804
|
var IncrementalStateKind;
|
|
1615
1805
|
(function(IncrementalStateKind2) {
|
|
1616
1806
|
IncrementalStateKind2[IncrementalStateKind2["Fresh"] = 0] = "Fresh";
|
|
@@ -1618,17 +1808,23 @@ var IncrementalStateKind;
|
|
|
1618
1808
|
IncrementalStateKind2[IncrementalStateKind2["Analyzed"] = 2] = "Analyzed";
|
|
1619
1809
|
})(IncrementalStateKind || (IncrementalStateKind = {}));
|
|
1620
1810
|
|
|
1621
|
-
//
|
|
1811
|
+
// packages/compiler-cli/src/ngtsc/incremental/src/incremental.js
|
|
1622
1812
|
var PhaseKind;
|
|
1623
1813
|
(function(PhaseKind2) {
|
|
1624
1814
|
PhaseKind2[PhaseKind2["Analysis"] = 0] = "Analysis";
|
|
1625
1815
|
PhaseKind2[PhaseKind2["TypeCheckAndEmit"] = 1] = "TypeCheckAndEmit";
|
|
1626
1816
|
})(PhaseKind || (PhaseKind = {}));
|
|
1627
|
-
var IncrementalCompilation = class {
|
|
1817
|
+
var IncrementalCompilation = class _IncrementalCompilation {
|
|
1628
1818
|
depGraph;
|
|
1629
1819
|
versions;
|
|
1630
1820
|
step;
|
|
1631
1821
|
phase;
|
|
1822
|
+
/**
|
|
1823
|
+
* `IncrementalState` of this compilation if it were to be reused in a subsequent incremental
|
|
1824
|
+
* compilation at the current moment.
|
|
1825
|
+
*
|
|
1826
|
+
* Exposed via the `state` read-only getter.
|
|
1827
|
+
*/
|
|
1632
1828
|
_state;
|
|
1633
1829
|
constructor(state, depGraph, versions, step) {
|
|
1634
1830
|
this.depGraph = depGraph;
|
|
@@ -1640,11 +1836,20 @@ var IncrementalCompilation = class {
|
|
|
1640
1836
|
semanticDepGraphUpdater: new SemanticDepGraphUpdater(step !== null ? step.priorState.semanticDepGraph : null)
|
|
1641
1837
|
};
|
|
1642
1838
|
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Begin a fresh `IncrementalCompilation`.
|
|
1841
|
+
*/
|
|
1643
1842
|
static fresh(program, versions) {
|
|
1644
1843
|
const state = {
|
|
1645
1844
|
kind: IncrementalStateKind.Fresh
|
|
1646
1845
|
};
|
|
1647
|
-
return new
|
|
1846
|
+
return new _IncrementalCompilation(
|
|
1847
|
+
state,
|
|
1848
|
+
new FileDependencyGraph(),
|
|
1849
|
+
versions,
|
|
1850
|
+
/* reuse */
|
|
1851
|
+
null
|
|
1852
|
+
);
|
|
1648
1853
|
}
|
|
1649
1854
|
static incremental(program, newVersions, oldProgram, oldState, modifiedResourceFiles, perf) {
|
|
1650
1855
|
return perf.inPhase(PerfPhase.Reconciliation, () => {
|
|
@@ -1653,7 +1858,7 @@ var IncrementalCompilation = class {
|
|
|
1653
1858
|
let priorAnalysis;
|
|
1654
1859
|
switch (oldState.kind) {
|
|
1655
1860
|
case IncrementalStateKind.Fresh:
|
|
1656
|
-
return
|
|
1861
|
+
return _IncrementalCompilation.fresh(program, newVersions);
|
|
1657
1862
|
case IncrementalStateKind.Analyzed:
|
|
1658
1863
|
priorAnalysis = oldState;
|
|
1659
1864
|
break;
|
|
@@ -1684,7 +1889,7 @@ var IncrementalCompilation = class {
|
|
|
1684
1889
|
}
|
|
1685
1890
|
}
|
|
1686
1891
|
if (sf.isDeclarationFile) {
|
|
1687
|
-
return
|
|
1892
|
+
return _IncrementalCompilation.fresh(program, newVersions);
|
|
1688
1893
|
}
|
|
1689
1894
|
physicallyChangedTsFiles.add(sfPath);
|
|
1690
1895
|
}
|
|
@@ -1702,7 +1907,7 @@ var IncrementalCompilation = class {
|
|
|
1702
1907
|
changedResourceFiles,
|
|
1703
1908
|
lastAnalyzedState: priorAnalysis
|
|
1704
1909
|
};
|
|
1705
|
-
return new
|
|
1910
|
+
return new _IncrementalCompilation(state, depGraph, newVersions, {
|
|
1706
1911
|
priorState: priorAnalysis,
|
|
1707
1912
|
logicallyChangedTsFiles
|
|
1708
1913
|
});
|
|
@@ -1824,8 +2029,8 @@ function toOriginalSourceFile(sf) {
|
|
|
1824
2029
|
}
|
|
1825
2030
|
}
|
|
1826
2031
|
|
|
1827
|
-
//
|
|
1828
|
-
var TrackedIncrementalBuildStrategy = class {
|
|
2032
|
+
// packages/compiler-cli/src/ngtsc/incremental/src/strategy.js
|
|
2033
|
+
var TrackedIncrementalBuildStrategy = class _TrackedIncrementalBuildStrategy {
|
|
1829
2034
|
state = null;
|
|
1830
2035
|
isSet = false;
|
|
1831
2036
|
getIncrementalState() {
|
|
@@ -1836,7 +2041,7 @@ var TrackedIncrementalBuildStrategy = class {
|
|
|
1836
2041
|
this.isSet = true;
|
|
1837
2042
|
}
|
|
1838
2043
|
toNextBuildStrategy() {
|
|
1839
|
-
const strategy = new
|
|
2044
|
+
const strategy = new _TrackedIncrementalBuildStrategy();
|
|
1840
2045
|
strategy.state = this.isSet ? this.state : null;
|
|
1841
2046
|
return strategy;
|
|
1842
2047
|
}
|
|
@@ -1858,7 +2063,7 @@ var PatchedProgramIncrementalBuildStrategy = class {
|
|
|
1858
2063
|
};
|
|
1859
2064
|
var SYM_INCREMENTAL_STATE = Symbol("NgIncrementalState");
|
|
1860
2065
|
|
|
1861
|
-
//
|
|
2066
|
+
// packages/compiler-cli/src/ngtsc/indexer/src/api.js
|
|
1862
2067
|
var IdentifierKind;
|
|
1863
2068
|
(function(IdentifierKind2) {
|
|
1864
2069
|
IdentifierKind2[IdentifierKind2["Property"] = 0] = "Property";
|
|
@@ -1881,30 +2086,47 @@ var AbsoluteSourceSpan = class {
|
|
|
1881
2086
|
}
|
|
1882
2087
|
};
|
|
1883
2088
|
|
|
1884
|
-
//
|
|
2089
|
+
// packages/compiler-cli/src/ngtsc/indexer/src/context.js
|
|
1885
2090
|
var IndexingContext = class {
|
|
1886
2091
|
components = /* @__PURE__ */ new Set();
|
|
2092
|
+
/**
|
|
2093
|
+
* Adds a component to the context.
|
|
2094
|
+
*/
|
|
1887
2095
|
addComponent(info) {
|
|
1888
2096
|
this.components.add(info);
|
|
1889
2097
|
}
|
|
1890
2098
|
};
|
|
1891
2099
|
|
|
1892
|
-
//
|
|
2100
|
+
// packages/compiler-cli/src/ngtsc/indexer/src/transform.js
|
|
1893
2101
|
import { ParseSourceFile } from "@angular/compiler";
|
|
1894
2102
|
|
|
1895
|
-
//
|
|
2103
|
+
// packages/compiler-cli/src/ngtsc/indexer/src/template.js
|
|
1896
2104
|
import { ASTWithSource, CombinedRecursiveAstVisitor, ImplicitReceiver, PropertyRead, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstReference, TmplAstTemplate, TmplAstVariable, tmplAstVisitAll } from "@angular/compiler";
|
|
1897
2105
|
var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
1898
2106
|
boundTemplate;
|
|
2107
|
+
// Identifiers of interest found in the template.
|
|
1899
2108
|
identifiers = /* @__PURE__ */ new Set();
|
|
1900
2109
|
errors = [];
|
|
1901
2110
|
currentAstWithSource = null;
|
|
2111
|
+
// Map of targets in a template to their identifiers.
|
|
1902
2112
|
targetIdentifierCache = /* @__PURE__ */ new Map();
|
|
2113
|
+
// Map of elements and templates to their identifiers.
|
|
1903
2114
|
directiveHostIdentifierCache = /* @__PURE__ */ new Map();
|
|
2115
|
+
/**
|
|
2116
|
+
* Creates a template visitor for a bound template target. The bound target can be used when
|
|
2117
|
+
* deferred to the expression visitor to get information about the target of an expression.
|
|
2118
|
+
*
|
|
2119
|
+
* @param boundTemplate bound template target
|
|
2120
|
+
*/
|
|
1904
2121
|
constructor(boundTemplate) {
|
|
1905
2122
|
super();
|
|
1906
2123
|
this.boundTemplate = boundTemplate;
|
|
1907
2124
|
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Add an identifier for an HTML element and visit its children recursively.
|
|
2127
|
+
*
|
|
2128
|
+
* @param element
|
|
2129
|
+
*/
|
|
1908
2130
|
visitElement(element) {
|
|
1909
2131
|
const elementIdentifier = this.directiveHostToIdentifier(element);
|
|
1910
2132
|
if (elementIdentifier !== null) {
|
|
@@ -1967,6 +2189,7 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
|
1967
2189
|
this.visit(attribute.value instanceof ASTWithSource ? attribute.value.ast : attribute.value);
|
|
1968
2190
|
this.currentAstWithSource = previous;
|
|
1969
2191
|
}
|
|
2192
|
+
/** Creates an identifier for a template element or template node. */
|
|
1970
2193
|
directiveHostToIdentifier(node) {
|
|
1971
2194
|
if (this.directiveHostIdentifierCache.has(node)) {
|
|
1972
2195
|
return this.directiveHostIdentifierCache.get(node);
|
|
@@ -2014,10 +2237,12 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
|
2014
2237
|
selector: dir.selector
|
|
2015
2238
|
};
|
|
2016
2239
|
}))
|
|
2240
|
+
// cast b/c pre-TypeScript 3.5 unions aren't well discriminated
|
|
2017
2241
|
};
|
|
2018
2242
|
this.directiveHostIdentifierCache.set(node, identifier);
|
|
2019
2243
|
return identifier;
|
|
2020
2244
|
}
|
|
2245
|
+
/** Creates an identifier for a template reference or template variable target. */
|
|
2021
2246
|
targetToIdentifier(node) {
|
|
2022
2247
|
if (this.targetIdentifierCache.has(node)) {
|
|
2023
2248
|
return this.targetIdentifierCache.get(node);
|
|
@@ -2071,6 +2296,7 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
|
2071
2296
|
this.targetIdentifierCache.set(node, identifier);
|
|
2072
2297
|
return identifier;
|
|
2073
2298
|
}
|
|
2299
|
+
/** Gets the start location of a string in a SourceSpan */
|
|
2074
2300
|
getStartLocation(name, context) {
|
|
2075
2301
|
const localStr = context.toString();
|
|
2076
2302
|
if (!localStr.includes(name)) {
|
|
@@ -2079,6 +2305,12 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
|
2079
2305
|
}
|
|
2080
2306
|
return context.start.offset + localStr.indexOf(name);
|
|
2081
2307
|
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Visits a node's expression and adds its identifiers, if any, to the visitor's state.
|
|
2310
|
+
* Only ASTs with information about the expression source and its location are visited.
|
|
2311
|
+
*
|
|
2312
|
+
* @param node node whose expression to visit
|
|
2313
|
+
*/
|
|
2082
2314
|
visit(node) {
|
|
2083
2315
|
if (node instanceof ASTWithSource) {
|
|
2084
2316
|
const previous = this.currentAstWithSource;
|
|
@@ -2089,6 +2321,12 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
|
|
|
2089
2321
|
super.visit(node);
|
|
2090
2322
|
}
|
|
2091
2323
|
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Visits an identifier, adding it to the identifier store if it is useful for indexing.
|
|
2326
|
+
*
|
|
2327
|
+
* @param ast expression AST the identifier is in
|
|
2328
|
+
* @param kind identifier kind
|
|
2329
|
+
*/
|
|
2092
2330
|
visitIdentifier(ast, kind) {
|
|
2093
2331
|
if (this.currentAstWithSource === null || this.currentAstWithSource.source === null) {
|
|
2094
2332
|
return;
|
|
@@ -2126,7 +2364,7 @@ function getTemplateIdentifiers(boundTemplate) {
|
|
|
2126
2364
|
return { identifiers: visitor.identifiers, errors: visitor.errors };
|
|
2127
2365
|
}
|
|
2128
2366
|
|
|
2129
|
-
//
|
|
2367
|
+
// packages/compiler-cli/src/ngtsc/indexer/src/transform.js
|
|
2130
2368
|
function generateAnalysis(context) {
|
|
2131
2369
|
const analysis = /* @__PURE__ */ new Map();
|
|
2132
2370
|
context.components.forEach(({ declaration, selector, boundTemplate, templateMeta }) => {
|
|
@@ -2162,7 +2400,7 @@ function generateAnalysis(context) {
|
|
|
2162
2400
|
return analysis;
|
|
2163
2401
|
}
|
|
2164
2402
|
|
|
2165
|
-
//
|
|
2403
|
+
// packages/compiler-cli/src/ngtsc/metadata/src/ng_module_index.js
|
|
2166
2404
|
var NgModuleIndexImpl = class {
|
|
2167
2405
|
metaReader;
|
|
2168
2406
|
localReader;
|
|
@@ -2170,7 +2408,11 @@ var NgModuleIndexImpl = class {
|
|
|
2170
2408
|
this.metaReader = metaReader;
|
|
2171
2409
|
this.localReader = localReader;
|
|
2172
2410
|
}
|
|
2411
|
+
// A map from an NgModule's Class Declaration to the "main" reference to that module, aka the one
|
|
2412
|
+
// present in the reader metadata object
|
|
2173
2413
|
ngModuleAuthoritativeReference = /* @__PURE__ */ new Map();
|
|
2414
|
+
// A map from a Directive/Pipe's class declaration to the class declarations of all re-exporting
|
|
2415
|
+
// NgModules
|
|
2174
2416
|
typeToExportingModules = /* @__PURE__ */ new Map();
|
|
2175
2417
|
indexed = false;
|
|
2176
2418
|
updateWith(cache, key, elem) {
|
|
@@ -2252,7 +2494,7 @@ var NgModuleIndexImpl = class {
|
|
|
2252
2494
|
}
|
|
2253
2495
|
};
|
|
2254
2496
|
|
|
2255
|
-
//
|
|
2497
|
+
// packages/compiler-cli/src/ngtsc/resource/src/loader.js
|
|
2256
2498
|
import ts17 from "typescript";
|
|
2257
2499
|
var CSS_PREPROCESSOR_EXT = /(\.scss|\.sass|\.less|\.styl)$/;
|
|
2258
2500
|
var RESOURCE_MARKER = ".$ngresource$";
|
|
@@ -2272,6 +2514,18 @@ var AdapterResourceLoader = class {
|
|
|
2272
2514
|
this.canPreload = !!this.adapter.readResource;
|
|
2273
2515
|
this.canPreprocess = !!this.adapter.transformResource;
|
|
2274
2516
|
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Resolve the url of a resource relative to the file that contains the reference to it.
|
|
2519
|
+
* The return value of this method can be used in the `load()` and `preload()` methods.
|
|
2520
|
+
*
|
|
2521
|
+
* Uses the provided CompilerHost if it supports mapping resources to filenames.
|
|
2522
|
+
* Otherwise, uses a fallback mechanism that searches the module resolution candidates.
|
|
2523
|
+
*
|
|
2524
|
+
* @param url The, possibly relative, url of the resource.
|
|
2525
|
+
* @param fromFile The path to the file that contains the URL of the resource.
|
|
2526
|
+
* @returns A resolved url of resource.
|
|
2527
|
+
* @throws An error if the resource cannot be resolved.
|
|
2528
|
+
*/
|
|
2275
2529
|
resolve(url, fromFile) {
|
|
2276
2530
|
let resolvedUrl = null;
|
|
2277
2531
|
if (this.adapter.resourceNameToFileName) {
|
|
@@ -2284,6 +2538,18 @@ var AdapterResourceLoader = class {
|
|
|
2284
2538
|
}
|
|
2285
2539
|
return resolvedUrl;
|
|
2286
2540
|
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Preload the specified resource, asynchronously.
|
|
2543
|
+
*
|
|
2544
|
+
* Once the resource is loaded, its value is cached so it can be accessed synchronously via the
|
|
2545
|
+
* `load()` method.
|
|
2546
|
+
*
|
|
2547
|
+
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to preload.
|
|
2548
|
+
* @param context Information about the resource such as the type and containing file.
|
|
2549
|
+
* @returns A Promise that is resolved once the resource has been loaded or `undefined` if the
|
|
2550
|
+
* file has already been loaded.
|
|
2551
|
+
* @throws An Error if pre-loading is not available.
|
|
2552
|
+
*/
|
|
2287
2553
|
preload(resolvedUrl, context) {
|
|
2288
2554
|
if (!this.adapter.readResource) {
|
|
2289
2555
|
throw new Error("HostResourceLoader: the CompilerHost provided does not support pre-loading resources.");
|
|
@@ -2318,6 +2584,14 @@ var AdapterResourceLoader = class {
|
|
|
2318
2584
|
return fetchCompletion;
|
|
2319
2585
|
}
|
|
2320
2586
|
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Preprocess the content data of an inline resource, asynchronously.
|
|
2589
|
+
*
|
|
2590
|
+
* @param data The existing content data from the inline resource.
|
|
2591
|
+
* @param context Information regarding the resource such as the type and containing file.
|
|
2592
|
+
* @returns A Promise that resolves to the processed data. If no processing occurs, the
|
|
2593
|
+
* same data string that was passed to the function will be resolved.
|
|
2594
|
+
*/
|
|
2321
2595
|
async preprocessInline(data, context) {
|
|
2322
2596
|
if (!this.adapter.transformResource || context.type !== "style") {
|
|
2323
2597
|
return data;
|
|
@@ -2334,6 +2608,14 @@ var AdapterResourceLoader = class {
|
|
|
2334
2608
|
}
|
|
2335
2609
|
return transformResult.content;
|
|
2336
2610
|
}
|
|
2611
|
+
/**
|
|
2612
|
+
* Load the resource at the given url, synchronously.
|
|
2613
|
+
*
|
|
2614
|
+
* The contents of the resource may have been cached by a previous call to `preload()`.
|
|
2615
|
+
*
|
|
2616
|
+
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to load.
|
|
2617
|
+
* @returns The contents of the resource.
|
|
2618
|
+
*/
|
|
2337
2619
|
load(resolvedUrl) {
|
|
2338
2620
|
if (this.cache.has(resolvedUrl)) {
|
|
2339
2621
|
return this.cache.get(resolvedUrl);
|
|
@@ -2345,9 +2627,16 @@ var AdapterResourceLoader = class {
|
|
|
2345
2627
|
this.cache.set(resolvedUrl, result);
|
|
2346
2628
|
return result;
|
|
2347
2629
|
}
|
|
2630
|
+
/**
|
|
2631
|
+
* Invalidate the entire resource cache.
|
|
2632
|
+
*/
|
|
2348
2633
|
invalidate() {
|
|
2349
2634
|
this.cache.clear();
|
|
2350
2635
|
}
|
|
2636
|
+
/**
|
|
2637
|
+
* Attempt to resolve `url` in the context of `fromFile`, while respecting the rootDirs
|
|
2638
|
+
* option from the tsconfig. First, normalize the file name.
|
|
2639
|
+
*/
|
|
2351
2640
|
fallbackResolve(url, fromFile) {
|
|
2352
2641
|
let candidateLocations;
|
|
2353
2642
|
if (url.startsWith("/")) {
|
|
@@ -2374,6 +2663,13 @@ var AdapterResourceLoader = class {
|
|
|
2374
2663
|
const segment = "." + url;
|
|
2375
2664
|
return this.adapter.rootDirs.map((rootDir) => join(rootDir, segment));
|
|
2376
2665
|
}
|
|
2666
|
+
/**
|
|
2667
|
+
* TypeScript provides utilities to resolve module names, but not resource files (which aren't
|
|
2668
|
+
* a part of the ts.Program). However, TypeScript's module resolution can be used creatively
|
|
2669
|
+
* to locate where resource files should be expected to exist. Since module resolution returns
|
|
2670
|
+
* a list of file names that were considered, the loader can enumerate the possible locations
|
|
2671
|
+
* for the file by setting up a module resolution for it that will fail.
|
|
2672
|
+
*/
|
|
2377
2673
|
getResolvedCandidateLocations(url, fromFile) {
|
|
2378
2674
|
const failedLookup = ts17.resolveModuleName(url + RESOURCE_MARKER, fromFile, this.options, this.lookupResolutionHost);
|
|
2379
2675
|
if (failedLookup.failedLookupLocations === void 0) {
|
|
@@ -2409,7 +2705,7 @@ function createLookupResolutionHost(adapter) {
|
|
|
2409
2705
|
};
|
|
2410
2706
|
}
|
|
2411
2707
|
|
|
2412
|
-
//
|
|
2708
|
+
// packages/compiler-cli/src/ngtsc/scope/src/standalone.js
|
|
2413
2709
|
var StandaloneComponentScopeReader = class {
|
|
2414
2710
|
metaReader;
|
|
2415
2711
|
localModuleReader;
|
|
@@ -2507,10 +2803,10 @@ var StandaloneComponentScopeReader = class {
|
|
|
2507
2803
|
}
|
|
2508
2804
|
};
|
|
2509
2805
|
|
|
2510
|
-
//
|
|
2806
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.js
|
|
2511
2807
|
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute } from "@angular/compiler";
|
|
2512
2808
|
|
|
2513
|
-
//
|
|
2809
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/symbol_util.js
|
|
2514
2810
|
import ts18 from "typescript";
|
|
2515
2811
|
var SIGNAL_FNS = /* @__PURE__ */ new Set([
|
|
2516
2812
|
"WritableSignal",
|
|
@@ -2520,7 +2816,9 @@ var SIGNAL_FNS = /* @__PURE__ */ new Set([
|
|
|
2520
2816
|
"ModelSignal"
|
|
2521
2817
|
]);
|
|
2522
2818
|
function isSignalReference(symbol) {
|
|
2523
|
-
return (symbol.kind === SymbolKind.Expression || symbol.kind === SymbolKind.Variable || symbol.kind === SymbolKind.LetDeclaration) &&
|
|
2819
|
+
return (symbol.kind === SymbolKind.Expression || symbol.kind === SymbolKind.Variable || symbol.kind === SymbolKind.LetDeclaration) && // Note that `tsType.symbol` isn't optional in the typings,
|
|
2820
|
+
// but it appears that it can be undefined at runtime.
|
|
2821
|
+
(symbol.tsType.symbol !== void 0 && isSignalSymbol(symbol.tsType.symbol) || symbol.tsType.aliasSymbol !== void 0 && isSignalSymbol(symbol.tsType.aliasSymbol));
|
|
2524
2822
|
}
|
|
2525
2823
|
function isSignalSymbol(symbol) {
|
|
2526
2824
|
const declarations = symbol.getDeclarations();
|
|
@@ -2530,10 +2828,23 @@ function isSignalSymbol(symbol) {
|
|
|
2530
2828
|
});
|
|
2531
2829
|
}
|
|
2532
2830
|
|
|
2533
|
-
//
|
|
2831
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.js
|
|
2534
2832
|
import { CombinedRecursiveAstVisitor as CombinedRecursiveAstVisitor2 } from "@angular/compiler";
|
|
2535
2833
|
var TemplateCheckWithVisitor = class {
|
|
2834
|
+
/**
|
|
2835
|
+
* When extended diagnostics were first introduced, the visitor wasn't implemented correctly
|
|
2836
|
+
* which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
|
|
2837
|
+
* the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
|
|
2838
|
+
* need to be done in a major version to avoid external breakages. This flag is used to opt out
|
|
2839
|
+
* pre-existing diagnostics from the correct behavior until the breakages have been fixed while
|
|
2840
|
+
* ensuring that newly-written diagnostics are correct from the beginning.
|
|
2841
|
+
* TODO(crisbeto): remove this flag and fix the internal brekages.
|
|
2842
|
+
*/
|
|
2536
2843
|
canVisitStructuralAttributes = true;
|
|
2844
|
+
/**
|
|
2845
|
+
* Base implementation for run function, visits all nodes in template and calls
|
|
2846
|
+
* `visitNode()` for each one.
|
|
2847
|
+
*/
|
|
2537
2848
|
run(ctx, component, template) {
|
|
2538
2849
|
const visitor = new TemplateVisitor2(ctx, component, this);
|
|
2539
2850
|
return visitor.getDiagnostics(template);
|
|
@@ -2576,7 +2887,7 @@ var TemplateVisitor2 = class extends CombinedRecursiveAstVisitor2 {
|
|
|
2576
2887
|
}
|
|
2577
2888
|
};
|
|
2578
2889
|
|
|
2579
|
-
//
|
|
2890
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.js
|
|
2580
2891
|
var SIGNAL_INSTANCE_PROPERTIES = /* @__PURE__ */ new Set(["set", "update", "asReadonly"]);
|
|
2581
2892
|
var FUNCTION_INSTANCE_PROPERTIES = /* @__PURE__ */ new Set(["name", "length", "prototype"]);
|
|
2582
2893
|
var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
|
|
@@ -2590,7 +2901,14 @@ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
|
|
|
2590
2901
|
return [];
|
|
2591
2902
|
}
|
|
2592
2903
|
const nodeAst = isPropertyReadNodeAst(node);
|
|
2593
|
-
if (
|
|
2904
|
+
if (
|
|
2905
|
+
// a bound property like `[prop]="mySignal"`
|
|
2906
|
+
(node.type === BindingType.Property || // or a class binding like `[class.myClass]="mySignal"`
|
|
2907
|
+
node.type === BindingType.Class || // or a style binding like `[style.width]="mySignal"`
|
|
2908
|
+
node.type === BindingType.Style || // or an attribute binding like `[attr.role]="mySignal"`
|
|
2909
|
+
node.type === BindingType.Attribute || // or an animation binding like `[@myAnimation]="mySignal"`
|
|
2910
|
+
node.type === BindingType.LegacyAnimation) && nodeAst
|
|
2911
|
+
) {
|
|
2594
2912
|
return buildDiagnosticForSignal(ctx, nodeAst, component);
|
|
2595
2913
|
}
|
|
2596
2914
|
}
|
|
@@ -2638,7 +2956,7 @@ var factory = {
|
|
|
2638
2956
|
create: () => new InterpolatedSignalCheck()
|
|
2639
2957
|
};
|
|
2640
2958
|
|
|
2641
|
-
//
|
|
2959
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.js
|
|
2642
2960
|
import { TmplAstBoundEvent } from "@angular/compiler";
|
|
2643
2961
|
var InvalidBananaInBoxCheck = class extends TemplateCheckWithVisitor {
|
|
2644
2962
|
code = ErrorCode.INVALID_BANANA_IN_BOX;
|
|
@@ -2661,7 +2979,7 @@ var factory2 = {
|
|
|
2661
2979
|
create: () => new InvalidBananaInBoxCheck()
|
|
2662
2980
|
};
|
|
2663
2981
|
|
|
2664
|
-
//
|
|
2982
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.js
|
|
2665
2983
|
import { TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
2666
2984
|
var KNOWN_CONTROL_FLOW_DIRECTIVES = /* @__PURE__ */ new Map([
|
|
2667
2985
|
["ngIf", { directive: "NgIf", builtIn: "@if" }],
|
|
@@ -2703,7 +3021,7 @@ var factory3 = {
|
|
|
2703
3021
|
}
|
|
2704
3022
|
};
|
|
2705
3023
|
|
|
2706
|
-
//
|
|
3024
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_ngforof_let/index.js
|
|
2707
3025
|
import { TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
2708
3026
|
var MissingNgForOfLetCheck = class extends TemplateCheckWithVisitor {
|
|
2709
3027
|
code = ErrorCode.MISSING_NGFOROF_LET;
|
|
@@ -2733,7 +3051,7 @@ var factory4 = {
|
|
|
2733
3051
|
create: () => new MissingNgForOfLetCheck()
|
|
2734
3052
|
};
|
|
2735
3053
|
|
|
2736
|
-
//
|
|
3054
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.js
|
|
2737
3055
|
import { TmplAstTemplate as TmplAstTemplate4 } from "@angular/compiler";
|
|
2738
3056
|
var KNOWN_CONTROL_FLOW_DIRECTIVES2 = /* @__PURE__ */ new Set([
|
|
2739
3057
|
"ngIf",
|
|
@@ -2773,7 +3091,7 @@ var factory5 = {
|
|
|
2773
3091
|
create: () => new MissingStructuralDirectiveCheck()
|
|
2774
3092
|
};
|
|
2775
3093
|
|
|
2776
|
-
//
|
|
3094
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.js
|
|
2777
3095
|
import { Binary } from "@angular/compiler";
|
|
2778
3096
|
import ts19 from "typescript";
|
|
2779
3097
|
var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
@@ -2816,7 +3134,7 @@ var factory6 = {
|
|
|
2816
3134
|
}
|
|
2817
3135
|
};
|
|
2818
3136
|
|
|
2819
|
-
//
|
|
3137
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
|
|
2820
3138
|
import { SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
2821
3139
|
import ts20 from "typescript";
|
|
2822
3140
|
var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
@@ -2860,7 +3178,7 @@ var factory7 = {
|
|
|
2860
3178
|
}
|
|
2861
3179
|
};
|
|
2862
3180
|
|
|
2863
|
-
//
|
|
3181
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/skip_hydration_not_static/index.js
|
|
2864
3182
|
import { TmplAstBoundAttribute as TmplAstBoundAttribute2, TmplAstTextAttribute } from "@angular/compiler";
|
|
2865
3183
|
var NG_SKIP_HYDRATION_ATTR_NAME = "ngSkipHydration";
|
|
2866
3184
|
var NgSkipHydrationSpec = class extends TemplateCheckWithVisitor {
|
|
@@ -2871,7 +3189,11 @@ var NgSkipHydrationSpec = class extends TemplateCheckWithVisitor {
|
|
|
2871
3189
|
const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
|
|
2872
3190
|
return [diagnostic];
|
|
2873
3191
|
}
|
|
2874
|
-
const acceptedValues = [
|
|
3192
|
+
const acceptedValues = [
|
|
3193
|
+
"true",
|
|
3194
|
+
""
|
|
3195
|
+
/* empty string */
|
|
3196
|
+
];
|
|
2875
3197
|
if (node instanceof TmplAstTextAttribute && node.name === NG_SKIP_HYDRATION_ATTR_NAME && !acceptedValues.includes(node.value) && node.value !== void 0) {
|
|
2876
3198
|
const errorString = `ngSkipHydration only accepts "true" or "" as value or no value at all. For example 'ngSkipHydration="true"' or 'ngSkipHydration'`;
|
|
2877
3199
|
const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
|
|
@@ -2886,7 +3208,7 @@ var factory8 = {
|
|
|
2886
3208
|
create: () => new NgSkipHydrationSpec()
|
|
2887
3209
|
};
|
|
2888
3210
|
|
|
2889
|
-
//
|
|
3211
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/suffix_not_supported/index.js
|
|
2890
3212
|
import { TmplAstBoundAttribute as TmplAstBoundAttribute3 } from "@angular/compiler";
|
|
2891
3213
|
var STYLE_SUFFIXES = ["px", "%", "em"];
|
|
2892
3214
|
var SuffixNotSupportedCheck = class extends TemplateCheckWithVisitor {
|
|
@@ -2907,7 +3229,7 @@ var factory9 = {
|
|
|
2907
3229
|
create: () => new SuffixNotSupportedCheck()
|
|
2908
3230
|
};
|
|
2909
3231
|
|
|
2910
|
-
//
|
|
3232
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/text_attribute_not_binding/index.js
|
|
2911
3233
|
import { TmplAstTextAttribute as TmplAstTextAttribute2 } from "@angular/compiler";
|
|
2912
3234
|
var TextAttributeNotBindingSpec = class extends TemplateCheckWithVisitor {
|
|
2913
3235
|
code = ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
|
|
@@ -2927,7 +3249,11 @@ var TextAttributeNotBindingSpec = class extends TemplateCheckWithVisitor {
|
|
|
2927
3249
|
}
|
|
2928
3250
|
} else {
|
|
2929
3251
|
const expectedKey = `[${name}]`;
|
|
2930
|
-
const expectedValue =
|
|
3252
|
+
const expectedValue = (
|
|
3253
|
+
// true/false are special cases because we don't want to convert them to strings but
|
|
3254
|
+
// rather maintain the logical true/false when bound.
|
|
3255
|
+
node.value === "true" || node.value === "false" ? node.value : `'${node.value}'`
|
|
3256
|
+
);
|
|
2931
3257
|
errorString = "Attribute, style, and class bindings should be enclosed with square braces.";
|
|
2932
3258
|
if (node.value) {
|
|
2933
3259
|
errorString += ` For example, '${expectedKey}="${expectedValue}"'.`;
|
|
@@ -2943,7 +3269,7 @@ var factory10 = {
|
|
|
2943
3269
|
create: () => new TextAttributeNotBindingSpec()
|
|
2944
3270
|
};
|
|
2945
3271
|
|
|
2946
|
-
//
|
|
3272
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/uninvoked_function_in_event_binding/index.js
|
|
2947
3273
|
import { ASTWithSource as ASTWithSource3, Call, Chain, Conditional, ParsedEventType, PropertyRead as PropertyRead3, SafeCall as SafeCall2, SafePropertyRead as SafePropertyRead2, TmplAstBoundEvent as TmplAstBoundEvent2 } from "@angular/compiler";
|
|
2948
3274
|
var UninvokedFunctionInEventBindingSpec = class extends TemplateCheckWithVisitor {
|
|
2949
3275
|
code = ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
|
|
@@ -2991,7 +3317,7 @@ var factory11 = {
|
|
|
2991
3317
|
create: () => new UninvokedFunctionInEventBindingSpec()
|
|
2992
3318
|
};
|
|
2993
3319
|
|
|
2994
|
-
//
|
|
3320
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/unparenthesized_nullish_coalescing/index.js
|
|
2995
3321
|
import { Binary as Binary2 } from "@angular/compiler";
|
|
2996
3322
|
var UnparenthesizedNullishCoalescing = class extends TemplateCheckWithVisitor {
|
|
2997
3323
|
code = ErrorCode.UNPARENTHESIZED_NULLISH_COALESCING;
|
|
@@ -3021,7 +3347,7 @@ var factory12 = {
|
|
|
3021
3347
|
create: () => new UnparenthesizedNullishCoalescing()
|
|
3022
3348
|
};
|
|
3023
3349
|
|
|
3024
|
-
//
|
|
3350
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/unused_let_declaration/index.js
|
|
3025
3351
|
import { AST, ASTWithSource as ASTWithSource4, TmplAstLetDeclaration } from "@angular/compiler";
|
|
3026
3352
|
var UnusedLetDeclarationCheck = class extends TemplateCheckWithVisitor {
|
|
3027
3353
|
code = ErrorCode.UNUSED_LET_DECLARATION;
|
|
@@ -3063,7 +3389,7 @@ var factory13 = {
|
|
|
3063
3389
|
create: () => new UnusedLetDeclarationCheck()
|
|
3064
3390
|
};
|
|
3065
3391
|
|
|
3066
|
-
//
|
|
3392
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/uninvoked_track_function/index.js
|
|
3067
3393
|
import { Call as Call2, PropertyRead as PropertyRead4, SafeCall as SafeCall3, SafePropertyRead as SafePropertyRead3, TmplAstForLoopBlock } from "@angular/compiler";
|
|
3068
3394
|
var UninvokedTrackFunctionCheck = class extends TemplateCheckWithVisitor {
|
|
3069
3395
|
code = ErrorCode.UNINVOKED_TRACK_FUNCTION;
|
|
@@ -3095,10 +3421,10 @@ var factory14 = {
|
|
|
3095
3421
|
create: () => new UninvokedTrackFunctionCheck()
|
|
3096
3422
|
};
|
|
3097
3423
|
|
|
3098
|
-
//
|
|
3424
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3099
3425
|
import ts21 from "typescript";
|
|
3100
3426
|
|
|
3101
|
-
//
|
|
3427
|
+
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
3102
3428
|
var DiagnosticCategoryLabel;
|
|
3103
3429
|
(function(DiagnosticCategoryLabel2) {
|
|
3104
3430
|
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
@@ -3106,7 +3432,7 @@ var DiagnosticCategoryLabel;
|
|
|
3106
3432
|
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
3107
3433
|
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
3108
3434
|
|
|
3109
|
-
//
|
|
3435
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3110
3436
|
var ExtendedTemplateCheckerImpl = class {
|
|
3111
3437
|
partialCtx;
|
|
3112
3438
|
templateChecks;
|
|
@@ -3134,6 +3460,8 @@ var ExtendedTemplateCheckerImpl = class {
|
|
|
3134
3460
|
for (const [check, category] of this.templateChecks.entries()) {
|
|
3135
3461
|
const ctx = {
|
|
3136
3462
|
...this.partialCtx,
|
|
3463
|
+
// Wrap `templateTypeChecker.makeTemplateDiagnostic()` to implicitly provide all the known
|
|
3464
|
+
// options.
|
|
3137
3465
|
makeTemplateDiagnostic: (span, message, relatedInformation) => {
|
|
3138
3466
|
return this.partialCtx.templateTypeChecker.makeTemplateDiagnostic(component, span, category, check.code, message, relatedInformation);
|
|
3139
3467
|
}
|
|
@@ -3160,7 +3488,7 @@ function assertNever(value) {
|
|
|
3160
3488
|
${value}`);
|
|
3161
3489
|
}
|
|
3162
3490
|
|
|
3163
|
-
//
|
|
3491
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/index.js
|
|
3164
3492
|
var ALL_DIAGNOSTIC_FACTORIES = [
|
|
3165
3493
|
factory2,
|
|
3166
3494
|
factory6,
|
|
@@ -3183,7 +3511,7 @@ var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
|
|
|
3183
3511
|
...ALL_DIAGNOSTIC_FACTORIES.map((factory15) => factory15.name)
|
|
3184
3512
|
]);
|
|
3185
3513
|
|
|
3186
|
-
//
|
|
3514
|
+
// packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
|
|
3187
3515
|
import { ASTWithSource as ASTWithSource5, ImplicitReceiver as ImplicitReceiver2, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead5, Binary as Binary3, RecursiveAstVisitor, TmplAstBoundEvent as TmplAstBoundEvent3, TmplAstLetDeclaration as TmplAstLetDeclaration2, TmplAstRecursiveVisitor, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
|
|
3188
3516
|
import ts22 from "typescript";
|
|
3189
3517
|
var TemplateSemanticsCheckerImpl = class {
|
|
@@ -3196,7 +3524,7 @@ var TemplateSemanticsCheckerImpl = class {
|
|
|
3196
3524
|
return template !== null ? TemplateSemanticsVisitor.visit(template, component, this.templateTypeChecker) : [];
|
|
3197
3525
|
}
|
|
3198
3526
|
};
|
|
3199
|
-
var TemplateSemanticsVisitor = class extends TmplAstRecursiveVisitor {
|
|
3527
|
+
var TemplateSemanticsVisitor = class _TemplateSemanticsVisitor extends TmplAstRecursiveVisitor {
|
|
3200
3528
|
expressionVisitor;
|
|
3201
3529
|
constructor(expressionVisitor) {
|
|
3202
3530
|
super();
|
|
@@ -3205,7 +3533,7 @@ var TemplateSemanticsVisitor = class extends TmplAstRecursiveVisitor {
|
|
|
3205
3533
|
static visit(nodes, component, templateTypeChecker) {
|
|
3206
3534
|
const diagnostics = [];
|
|
3207
3535
|
const expressionVisitor = new ExpressionsSemanticsVisitor(templateTypeChecker, component, diagnostics);
|
|
3208
|
-
const templateVisitor = new
|
|
3536
|
+
const templateVisitor = new _TemplateSemanticsVisitor(expressionVisitor);
|
|
3209
3537
|
nodes.forEach((node) => node.visit(templateVisitor));
|
|
3210
3538
|
return diagnostics;
|
|
3211
3539
|
}
|
|
@@ -3282,7 +3610,7 @@ function unwrapAstWithSource(ast) {
|
|
|
3282
3610
|
return ast instanceof ASTWithSource5 ? ast.ast : ast;
|
|
3283
3611
|
}
|
|
3284
3612
|
|
|
3285
|
-
//
|
|
3613
|
+
// packages/compiler-cli/src/ngtsc/validation/src/rules/initializer_api_usage_rule.js
|
|
3286
3614
|
import ts23 from "typescript";
|
|
3287
3615
|
var APIS_TO_CHECK = [
|
|
3288
3616
|
INPUT_INITIALIZER_FN,
|
|
@@ -3334,7 +3662,7 @@ var InitializerApiUsageRule = class {
|
|
|
3334
3662
|
}
|
|
3335
3663
|
};
|
|
3336
3664
|
|
|
3337
|
-
//
|
|
3665
|
+
// packages/compiler-cli/src/ngtsc/validation/src/rules/unused_standalone_imports_rule.js
|
|
3338
3666
|
import ts24 from "typescript";
|
|
3339
3667
|
var UnusedStandaloneImportsRule = class {
|
|
3340
3668
|
templateTypeChecker;
|
|
@@ -3399,6 +3727,11 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3399
3727
|
}
|
|
3400
3728
|
return unused;
|
|
3401
3729
|
}
|
|
3730
|
+
/**
|
|
3731
|
+
* Determines if an import reference *might* be coming from a shared imports array.
|
|
3732
|
+
* @param reference Reference to be checked.
|
|
3733
|
+
* @param rawImports AST node that defines the `imports` array.
|
|
3734
|
+
*/
|
|
3402
3735
|
isPotentialSharedReference(reference, rawImports) {
|
|
3403
3736
|
if (reference.getIdentityInExpression(rawImports) !== null) {
|
|
3404
3737
|
return false;
|
|
@@ -3425,13 +3758,17 @@ function closestNode(start, predicate) {
|
|
|
3425
3758
|
return null;
|
|
3426
3759
|
}
|
|
3427
3760
|
|
|
3428
|
-
//
|
|
3761
|
+
// packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
|
|
3429
3762
|
var SourceFileValidator = class {
|
|
3430
3763
|
rules;
|
|
3431
3764
|
constructor(reflector, importedSymbolsTracker, templateTypeChecker, typeCheckingConfig) {
|
|
3432
3765
|
this.rules = [new InitializerApiUsageRule(reflector, importedSymbolsTracker)];
|
|
3433
3766
|
this.rules.push(new UnusedStandaloneImportsRule(templateTypeChecker, typeCheckingConfig, importedSymbolsTracker));
|
|
3434
3767
|
}
|
|
3768
|
+
/**
|
|
3769
|
+
* Gets the diagnostics for a specific file, or null if the file is valid.
|
|
3770
|
+
* @param sourceFile File to be checked.
|
|
3771
|
+
*/
|
|
3435
3772
|
getDiagnosticsForFile(sourceFile) {
|
|
3436
3773
|
if (sourceFile.isDeclarationFile || sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
|
|
3437
3774
|
return null;
|
|
@@ -3465,7 +3802,7 @@ var SourceFileValidator = class {
|
|
|
3465
3802
|
}
|
|
3466
3803
|
};
|
|
3467
3804
|
|
|
3468
|
-
//
|
|
3805
|
+
// packages/compiler-cli/src/ngtsc/core/src/feature_detection.js
|
|
3469
3806
|
import semver from "semver";
|
|
3470
3807
|
function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
3471
3808
|
if (coreVersion === `0.0.0-${"PLACEHOLDER"}`) {
|
|
@@ -3474,7 +3811,7 @@ function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
|
3474
3811
|
return semver.satisfies(coreVersion, minVersion, { includePrerelease: true });
|
|
3475
3812
|
}
|
|
3476
3813
|
|
|
3477
|
-
//
|
|
3814
|
+
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
3478
3815
|
var CompilationTicketKind;
|
|
3479
3816
|
(function(CompilationTicketKind2) {
|
|
3480
3817
|
CompilationTicketKind2[CompilationTicketKind2["Fresh"] = 0] = "Fresh";
|
|
@@ -3532,7 +3869,7 @@ function incrementalFromStateTicket(oldProgram, oldState, newProgram, options, i
|
|
|
3532
3869
|
perfRecorder
|
|
3533
3870
|
};
|
|
3534
3871
|
}
|
|
3535
|
-
var NgCompiler = class {
|
|
3872
|
+
var NgCompiler = class _NgCompiler {
|
|
3536
3873
|
adapter;
|
|
3537
3874
|
options;
|
|
3538
3875
|
inputProgram;
|
|
@@ -3541,8 +3878,24 @@ var NgCompiler = class {
|
|
|
3541
3878
|
incrementalCompilation;
|
|
3542
3879
|
usePoisonedData;
|
|
3543
3880
|
livePerfRecorder;
|
|
3881
|
+
/**
|
|
3882
|
+
* Lazily evaluated state of the compilation.
|
|
3883
|
+
*
|
|
3884
|
+
* This is created on demand by calling `ensureAnalyzed`.
|
|
3885
|
+
*/
|
|
3544
3886
|
compilation = null;
|
|
3887
|
+
/**
|
|
3888
|
+
* Any diagnostics related to the construction of the compilation.
|
|
3889
|
+
*
|
|
3890
|
+
* These are diagnostics which arose during setup of the host and/or program.
|
|
3891
|
+
*/
|
|
3545
3892
|
constructionDiagnostics = [];
|
|
3893
|
+
/**
|
|
3894
|
+
* Non-template diagnostics related to the program itself. Does not include template
|
|
3895
|
+
* diagnostics because the template type checker memoizes them itself.
|
|
3896
|
+
*
|
|
3897
|
+
* This is set by (and memoizes) `getNonTemplateDiagnostics`.
|
|
3898
|
+
*/
|
|
3546
3899
|
nonTemplateDiagnostics = null;
|
|
3547
3900
|
closureCompilerEnabled;
|
|
3548
3901
|
currentProgram;
|
|
@@ -3560,13 +3913,27 @@ var NgCompiler = class {
|
|
|
3560
3913
|
implicitStandaloneValue;
|
|
3561
3914
|
enableSelectorless;
|
|
3562
3915
|
emitDeclarationOnly;
|
|
3916
|
+
/**
|
|
3917
|
+
* `NgCompiler` can be reused for multiple compilations (for resource-only changes), and each
|
|
3918
|
+
* new compilation uses a fresh `PerfRecorder`. Thus, classes created with a lifespan of the
|
|
3919
|
+
* `NgCompiler` use a `DelegatingPerfRecorder` so the `PerfRecorder` they write to can be updated
|
|
3920
|
+
* with each fresh compilation.
|
|
3921
|
+
*/
|
|
3563
3922
|
delegatingPerfRecorder;
|
|
3923
|
+
/**
|
|
3924
|
+
* Convert a `CompilationTicket` into an `NgCompiler` instance for the requested compilation.
|
|
3925
|
+
*
|
|
3926
|
+
* Depending on the nature of the compilation request, the `NgCompiler` instance may be reused
|
|
3927
|
+
* from a previous compilation and updated with any changes, it may be a new instance which
|
|
3928
|
+
* incrementally reuses state from a previous compilation, or it may represent a fresh
|
|
3929
|
+
* compilation entirely.
|
|
3930
|
+
*/
|
|
3564
3931
|
static fromTicket(ticket, adapter) {
|
|
3565
3932
|
switch (ticket.kind) {
|
|
3566
3933
|
case CompilationTicketKind.Fresh:
|
|
3567
|
-
return new
|
|
3934
|
+
return new _NgCompiler(adapter, ticket.options, ticket.tsProgram, ticket.programDriver, ticket.incrementalBuildStrategy, IncrementalCompilation.fresh(ticket.tsProgram, versionMapFromProgram(ticket.tsProgram, ticket.programDriver)), ticket.enableTemplateTypeChecker, ticket.usePoisonedData, ticket.perfRecorder);
|
|
3568
3935
|
case CompilationTicketKind.IncrementalTypeScript:
|
|
3569
|
-
return new
|
|
3936
|
+
return new _NgCompiler(adapter, ticket.options, ticket.newProgram, ticket.programDriver, ticket.incrementalBuildStrategy, ticket.incrementalCompilation, ticket.enableTemplateTypeChecker, ticket.usePoisonedData, ticket.perfRecorder);
|
|
3570
3937
|
case CompilationTicketKind.IncrementalResource:
|
|
3571
3938
|
const compiler = ticket.compiler;
|
|
3572
3939
|
compiler.updateWithChangedResources(ticket.modifiedResourceFiles, ticket.perfRecorder);
|
|
@@ -3598,6 +3965,10 @@ var NgCompiler = class {
|
|
|
3598
3965
|
this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
|
|
3599
3966
|
const moduleResolutionCache = ts25.createModuleResolutionCache(
|
|
3600
3967
|
this.adapter.getCurrentDirectory(),
|
|
3968
|
+
// doen't retain a reference to `this`, if other closures in the constructor here reference
|
|
3969
|
+
// `this` internally then a closure created here would retain them. This can cause major
|
|
3970
|
+
// memory leak issues since the `moduleResolutionCache` is a long-lived object and finds its
|
|
3971
|
+
// way into all kinds of places inside TS internal objects.
|
|
3601
3972
|
this.adapter.getCanonicalFileName.bind(this.adapter)
|
|
3602
3973
|
);
|
|
3603
3974
|
this.moduleResolver = new ModuleResolver(inputProgram, this.options, this.adapter, moduleResolutionCache);
|
|
@@ -3647,10 +4018,18 @@ var NgCompiler = class {
|
|
|
3647
4018
|
}
|
|
3648
4019
|
});
|
|
3649
4020
|
}
|
|
4021
|
+
/**
|
|
4022
|
+
* Get the resource dependencies of a file.
|
|
4023
|
+
*
|
|
4024
|
+
* If the file is not part of the compilation, an empty array will be returned.
|
|
4025
|
+
*/
|
|
3650
4026
|
getResourceDependencies(file) {
|
|
3651
4027
|
this.ensureAnalyzed();
|
|
3652
4028
|
return this.incrementalCompilation.depGraph.getResourceDependencies(file);
|
|
3653
4029
|
}
|
|
4030
|
+
/**
|
|
4031
|
+
* Get all Angular-related diagnostics for this compilation.
|
|
4032
|
+
*/
|
|
3654
4033
|
getDiagnostics() {
|
|
3655
4034
|
const diagnostics = [...this.getNonTemplateDiagnostics()];
|
|
3656
4035
|
try {
|
|
@@ -3663,6 +4042,11 @@ var NgCompiler = class {
|
|
|
3663
4042
|
}
|
|
3664
4043
|
return this.addMessageTextDetails(diagnostics);
|
|
3665
4044
|
}
|
|
4045
|
+
/**
|
|
4046
|
+
* Get all Angular-related diagnostics for this compilation.
|
|
4047
|
+
*
|
|
4048
|
+
* If a `ts.SourceFile` is passed, only diagnostics related to that file are returned.
|
|
4049
|
+
*/
|
|
3666
4050
|
getDiagnosticsForFile(file, optimizeFor) {
|
|
3667
4051
|
const diagnostics = [
|
|
3668
4052
|
...this.getNonTemplateDiagnostics().filter((diag) => diag.file === file)
|
|
@@ -3677,6 +4061,9 @@ var NgCompiler = class {
|
|
|
3677
4061
|
}
|
|
3678
4062
|
return this.addMessageTextDetails(diagnostics);
|
|
3679
4063
|
}
|
|
4064
|
+
/**
|
|
4065
|
+
* Get all `ts.Diagnostic`s currently available that pertain to the given component.
|
|
4066
|
+
*/
|
|
3680
4067
|
getDiagnosticsForComponent(component) {
|
|
3681
4068
|
const compilation = this.ensureAnalyzed();
|
|
3682
4069
|
const ttc = compilation.templateTypeChecker;
|
|
@@ -3698,6 +4085,9 @@ var NgCompiler = class {
|
|
|
3698
4085
|
}
|
|
3699
4086
|
return this.addMessageTextDetails(diagnostics);
|
|
3700
4087
|
}
|
|
4088
|
+
/**
|
|
4089
|
+
* Add Angular.io error guide links to diagnostics for this compilation.
|
|
4090
|
+
*/
|
|
3701
4091
|
addMessageTextDetails(diagnostics) {
|
|
3702
4092
|
return diagnostics.map((diag) => {
|
|
3703
4093
|
if (diag.code && COMPILER_ERRORS_WITH_GUIDES.has(ngErrorCode(diag.code))) {
|
|
@@ -3709,9 +4099,27 @@ var NgCompiler = class {
|
|
|
3709
4099
|
return diag;
|
|
3710
4100
|
});
|
|
3711
4101
|
}
|
|
4102
|
+
/**
|
|
4103
|
+
* Get all setup-related diagnostics for this compilation.
|
|
4104
|
+
*/
|
|
3712
4105
|
getOptionDiagnostics() {
|
|
3713
4106
|
return this.constructionDiagnostics;
|
|
3714
4107
|
}
|
|
4108
|
+
/**
|
|
4109
|
+
* Get the current `ts.Program` known to this `NgCompiler`.
|
|
4110
|
+
*
|
|
4111
|
+
* Compilation begins with an input `ts.Program`, and during template type-checking operations new
|
|
4112
|
+
* `ts.Program`s may be produced using the `ProgramDriver`. The most recent such `ts.Program` to
|
|
4113
|
+
* be produced is available here.
|
|
4114
|
+
*
|
|
4115
|
+
* This `ts.Program` serves two key purposes:
|
|
4116
|
+
*
|
|
4117
|
+
* * As an incremental starting point for creating the next `ts.Program` based on files that the
|
|
4118
|
+
* user has changed (for clients using the TS compiler program APIs).
|
|
4119
|
+
*
|
|
4120
|
+
* * As the "before" point for an incremental compilation invocation, to determine what's changed
|
|
4121
|
+
* between the old and new programs (for all compilations).
|
|
4122
|
+
*/
|
|
3715
4123
|
getCurrentProgram() {
|
|
3716
4124
|
return this.currentProgram;
|
|
3717
4125
|
}
|
|
@@ -3721,14 +4129,23 @@ var NgCompiler = class {
|
|
|
3721
4129
|
}
|
|
3722
4130
|
return this.ensureAnalyzed().templateTypeChecker;
|
|
3723
4131
|
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Retrieves the `ts.Declaration`s for any component(s) which use the given template file.
|
|
4134
|
+
*/
|
|
3724
4135
|
getComponentsWithTemplateFile(templateFilePath) {
|
|
3725
4136
|
const { resourceRegistry } = this.ensureAnalyzed();
|
|
3726
4137
|
return resourceRegistry.getComponentsWithTemplate(resolve(templateFilePath));
|
|
3727
4138
|
}
|
|
4139
|
+
/**
|
|
4140
|
+
* Retrieves the `ts.Declaration`s for any component(s) which use the given template file.
|
|
4141
|
+
*/
|
|
3728
4142
|
getComponentsWithStyleFile(styleFilePath) {
|
|
3729
4143
|
const { resourceRegistry } = this.ensureAnalyzed();
|
|
3730
4144
|
return resourceRegistry.getComponentsWithStyle(resolve(styleFilePath));
|
|
3731
4145
|
}
|
|
4146
|
+
/**
|
|
4147
|
+
* Retrieves external resources for the given directive.
|
|
4148
|
+
*/
|
|
3732
4149
|
getDirectiveResources(classDecl) {
|
|
3733
4150
|
if (!isNamedClassDeclaration(classDecl)) {
|
|
3734
4151
|
return null;
|
|
@@ -3751,6 +4168,15 @@ var NgCompiler = class {
|
|
|
3751
4168
|
}
|
|
3752
4169
|
return meta;
|
|
3753
4170
|
}
|
|
4171
|
+
/**
|
|
4172
|
+
* Perform Angular's analysis step (as a precursor to `getDiagnostics` or `prepareEmit`)
|
|
4173
|
+
* asynchronously.
|
|
4174
|
+
*
|
|
4175
|
+
* Normally, this operation happens lazily whenever `getDiagnostics` or `prepareEmit` are called.
|
|
4176
|
+
* However, certain consumers may wish to allow for an asynchronous phase of analysis, where
|
|
4177
|
+
* resources such as `styleUrls` are resolved asynchronously. In these cases `analyzeAsync` must
|
|
4178
|
+
* be called first, and its `Promise` awaited prior to calling any other APIs of `NgCompiler`.
|
|
4179
|
+
*/
|
|
3754
4180
|
async analyzeAsync() {
|
|
3755
4181
|
if (this.compilation !== null) {
|
|
3756
4182
|
return;
|
|
@@ -3772,6 +4198,10 @@ var NgCompiler = class {
|
|
|
3772
4198
|
this.resolveCompilation(this.compilation.traitCompiler);
|
|
3773
4199
|
});
|
|
3774
4200
|
}
|
|
4201
|
+
/**
|
|
4202
|
+
* Fetch transformers and other information which is necessary for a consumer to `emit` the
|
|
4203
|
+
* program with Angular-added definitions.
|
|
4204
|
+
*/
|
|
3775
4205
|
prepareEmit() {
|
|
3776
4206
|
const compilation = this.ensureAnalyzed();
|
|
3777
4207
|
untagAllTsFiles(this.inputProgram);
|
|
@@ -3820,12 +4250,27 @@ var NgCompiler = class {
|
|
|
3820
4250
|
}
|
|
3821
4251
|
return { transformers: { before, afterDeclarations } };
|
|
3822
4252
|
}
|
|
4253
|
+
/**
|
|
4254
|
+
* Run the indexing process and return a `Map` of all indexed components.
|
|
4255
|
+
*
|
|
4256
|
+
* See the `indexing` package for more details.
|
|
4257
|
+
*/
|
|
3823
4258
|
getIndexedComponents() {
|
|
3824
4259
|
const compilation = this.ensureAnalyzed();
|
|
3825
4260
|
const context = new IndexingContext();
|
|
3826
4261
|
compilation.traitCompiler.index(context);
|
|
3827
4262
|
return generateAnalysis(context);
|
|
3828
4263
|
}
|
|
4264
|
+
/**
|
|
4265
|
+
* Gets information for the current program that may be used to generate API
|
|
4266
|
+
* reference documentation. This includes Angular-specific information, such
|
|
4267
|
+
* as component inputs and outputs.
|
|
4268
|
+
*
|
|
4269
|
+
* @param entryPoint Path to the entry point for the package for which API
|
|
4270
|
+
* docs should be extracted.
|
|
4271
|
+
*
|
|
4272
|
+
* @returns A map of symbols with their associated module, eg: ApplicationRef => @angular/core
|
|
4273
|
+
*/
|
|
3829
4274
|
getApiDocumentation(entryPoint, privateModules) {
|
|
3830
4275
|
const compilation = this.ensureAnalyzed();
|
|
3831
4276
|
const checker = this.inputProgram.getTypeChecker();
|
|
@@ -3839,10 +4284,17 @@ var NgCompiler = class {
|
|
|
3839
4284
|
const rootDir = this.inputProgram.getCurrentDirectory();
|
|
3840
4285
|
return docsExtractor.extractAll(entryPointSourceFile, rootDir, privateModules);
|
|
3841
4286
|
}
|
|
4287
|
+
/**
|
|
4288
|
+
* Collect i18n messages into the `Xi18nContext`.
|
|
4289
|
+
*/
|
|
3842
4290
|
xi18n(ctx) {
|
|
3843
4291
|
const compilation = this.ensureAnalyzed();
|
|
3844
4292
|
compilation.traitCompiler.xi18n(ctx);
|
|
3845
4293
|
}
|
|
4294
|
+
/**
|
|
4295
|
+
* Emits the JavaScript module that can be used to replace the metadata of a class during HMR.
|
|
4296
|
+
* @param node Class for which to generate the update module.
|
|
4297
|
+
*/
|
|
3846
4298
|
emitHmrUpdateModule(node) {
|
|
3847
4299
|
const { traitCompiler, reflector } = this.ensureAnalyzed();
|
|
3848
4300
|
if (!reflector.isClass(node)) {
|
|
@@ -3858,6 +4310,9 @@ var NgCompiler = class {
|
|
|
3858
4310
|
return ts25.transpileModule(nodeText, {
|
|
3859
4311
|
compilerOptions: {
|
|
3860
4312
|
...this.options,
|
|
4313
|
+
// Some module types can produce additional code (see #60795) whereas we need the
|
|
4314
|
+
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
4315
|
+
// to ensure that it looks as expected.
|
|
3861
4316
|
module: ts25.ModuleKind.ES2022,
|
|
3862
4317
|
target: ts25.ScriptTarget.ES2022
|
|
3863
4318
|
},
|
|
@@ -3912,18 +4367,28 @@ var NgCompiler = class {
|
|
|
3912
4367
|
checkControlFlowBodies: true,
|
|
3913
4368
|
strictNullInputBindings: strictTemplates,
|
|
3914
4369
|
checkTypeOfAttributes: strictTemplates,
|
|
4370
|
+
// Even in full template type-checking mode, DOM binding checks are not quite ready yet.
|
|
3915
4371
|
checkTypeOfDomBindings: false,
|
|
3916
4372
|
checkTypeOfOutputEvents: strictTemplates,
|
|
3917
4373
|
checkTypeOfAnimationEvents: strictTemplates,
|
|
4374
|
+
// Checking of DOM events currently has an adverse effect on developer experience,
|
|
4375
|
+
// e.g. for `<input (blur)="update($event.target.value)">` enabling this check results in:
|
|
4376
|
+
// - error TS2531: Object is possibly 'null'.
|
|
4377
|
+
// - error TS2339: Property 'value' does not exist on type 'EventTarget'.
|
|
3918
4378
|
checkTypeOfDomEvents: strictTemplates,
|
|
3919
4379
|
checkTypeOfDomReferences: strictTemplates,
|
|
4380
|
+
// Non-DOM references have the correct type in View Engine so there is no strictness flag.
|
|
3920
4381
|
checkTypeOfNonDomReferences: true,
|
|
4382
|
+
// Pipes are checked in View Engine so there is no strictness flag.
|
|
3921
4383
|
checkTypeOfPipes: true,
|
|
3922
4384
|
strictSafeNavigationTypes: strictTemplates,
|
|
3923
4385
|
useContextGenericType: strictTemplates,
|
|
3924
4386
|
strictLiteralTypes: true,
|
|
3925
4387
|
enableTemplateTypeChecker: this.enableTemplateTypeChecker,
|
|
3926
4388
|
useInlineTypeConstructors,
|
|
4389
|
+
// Warnings for suboptimal type inference are only enabled if in Language Service mode
|
|
4390
|
+
// (providing the full TemplateTypeChecker API) and if strict mode is not enabled. In strict
|
|
4391
|
+
// mode, the user is in full control of type inference.
|
|
3927
4392
|
suggestionsForSuboptimalTypeInference: this.enableTemplateTypeChecker && !strictTemplates,
|
|
3928
4393
|
controlFlowPreventingContentProjection: this.options.extendedDiagnostics?.defaultCategory || DiagnosticCategoryLabel.Warning,
|
|
3929
4394
|
unusedStandaloneImports: this.options.extendedDiagnostics?.defaultCategory || DiagnosticCategoryLabel.Warning,
|
|
@@ -3936,6 +4401,8 @@ var NgCompiler = class {
|
|
|
3936
4401
|
checkQueries: false,
|
|
3937
4402
|
checkTemplateBodies: false,
|
|
3938
4403
|
checkControlFlowBodies: false,
|
|
4404
|
+
// Enable deep schema checking in "basic" template type-checking mode only if Closure
|
|
4405
|
+
// compilation is requested, which is a good proxy for "only in google3".
|
|
3939
4406
|
alwaysCheckSchemaInTemplateBodies: this.closureCompilerEnabled,
|
|
3940
4407
|
checkTypeOfInputBindings: false,
|
|
3941
4408
|
strictNullInputBindings: false,
|
|
@@ -3953,6 +4420,8 @@ var NgCompiler = class {
|
|
|
3953
4420
|
strictLiteralTypes: false,
|
|
3954
4421
|
enableTemplateTypeChecker: this.enableTemplateTypeChecker,
|
|
3955
4422
|
useInlineTypeConstructors,
|
|
4423
|
+
// In "basic" template type-checking mode, no warnings are produced since most things are
|
|
4424
|
+
// not checked anyways.
|
|
3956
4425
|
suggestionsForSuboptimalTypeInference: false,
|
|
3957
4426
|
controlFlowPreventingContentProjection: this.options.extendedDiagnostics?.defaultCategory || DiagnosticCategoryLabel.Warning,
|
|
3958
4427
|
unusedStandaloneImports: this.options.extendedDiagnostics?.defaultCategory || DiagnosticCategoryLabel.Warning,
|
|
@@ -4091,8 +4560,13 @@ var NgCompiler = class {
|
|
|
4091
4560
|
localImportStrategy = new RelativePathStrategy(reflector);
|
|
4092
4561
|
}
|
|
4093
4562
|
refEmitter = new ReferenceEmitter([
|
|
4563
|
+
// First, try to use local identifiers if available.
|
|
4094
4564
|
new LocalIdentifierStrategy(),
|
|
4565
|
+
// Next, attempt to use an absolute import.
|
|
4095
4566
|
new AbsoluteModuleStrategy(this.inputProgram, checker, this.moduleResolver, reflector),
|
|
4567
|
+
// Finally, check if the reference is being written into a file within the project's .ts
|
|
4568
|
+
// sources, and use a relative import if so. If this fails, ReferenceEmitter will throw
|
|
4569
|
+
// an error.
|
|
4096
4570
|
localImportStrategy
|
|
4097
4571
|
]);
|
|
4098
4572
|
if (this.entryPoint === null && this.options.generateDeepReexports === true) {
|
|
@@ -4100,8 +4574,11 @@ var NgCompiler = class {
|
|
|
4100
4574
|
}
|
|
4101
4575
|
} else {
|
|
4102
4576
|
refEmitter = new ReferenceEmitter([
|
|
4577
|
+
// First, try to use local identifiers if available.
|
|
4103
4578
|
new LocalIdentifierStrategy(),
|
|
4579
|
+
// Then use aliased references (this is a workaround to StrictDeps checks).
|
|
4104
4580
|
...this.options["_useHostForImportAndAliasGeneration"] ? [new AliasStrategy()] : [],
|
|
4581
|
+
// Then use fileNameToModuleName to emit imports.
|
|
4105
4582
|
new UnifiedModulesStrategy(reflector, this.adapter.unifiedModulesHost)
|
|
4106
4583
|
]);
|
|
4107
4584
|
if (this.options["_useHostForImportAndAliasGeneration"]) {
|
|
@@ -4163,7 +4640,11 @@ var NgCompiler = class {
|
|
|
4163
4640
|
const jitDeclarationRegistry = new JitDeclarationRegistry();
|
|
4164
4641
|
const handlers = [
|
|
4165
4642
|
new ComponentDecoratorHandler(reflector, evaluator, metaRegistry, metaReader, scopeReader, this.adapter, ngModuleScopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, strictCtorDeps, this.resourceManager, this.adapter.rootDirs, this.options.preserveWhitespaces || false, this.options.i18nUseExternalIds !== false, this.options.enableI18nLegacyMessageIdFormat !== false, this.usePoisonedData, this.options.i18nNormalizeLineEndingsInICUs === true, this.moduleResolver, this.cycleAnalyzer, cycleHandlingStrategy, refEmitter, referencesRegistry, this.incrementalCompilation.depGraph, injectableRegistry, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder, hostDirectivesResolver, importTracker, supportTestBed, compilationMode, deferredSymbolsTracker, !!this.options.forbidOrphanComponents, this.enableBlockSyntax, this.enableLetSyntax, externalRuntimeStyles, localCompilationExtraImportsTracker, jitDeclarationRegistry, this.options.i18nPreserveWhitespaceForLegacyExtraction ?? true, !!this.options.strictStandalone, this.enableHmr, this.implicitStandaloneValue, typeCheckHostBindings, this.enableSelectorless, this.emitDeclarationOnly),
|
|
4643
|
+
// TODO(alxhub): understand why the cast here is necessary (something to do with `null`
|
|
4644
|
+
// not being assignable to `unknown` when wrapped in `Readonly`).
|
|
4166
4645
|
new DirectiveDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder, importTracker, supportTestBed, typeCheckScopeRegistry, compilationMode, jitDeclarationRegistry, resourceRegistry, !!this.options.strictStandalone, this.implicitStandaloneValue, this.usePoisonedData, typeCheckHostBindings, this.emitDeclarationOnly),
|
|
4646
|
+
// Pipe handler must be before injectable handler in list so pipe factories are printed
|
|
4647
|
+
// before injectable factories (so injectable factories can delegate to them)
|
|
4167
4648
|
new PipeDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, injectableRegistry, isCore, this.delegatingPerfRecorder, supportTestBed, compilationMode, !!this.options.generateExtraImportsInLocalMode, !!this.options.strictStandalone, this.implicitStandaloneValue),
|
|
4168
4649
|
new InjectableDecoratorHandler(reflector, evaluator, isCore, strictCtorDeps, injectableRegistry, this.delegatingPerfRecorder, supportTestBed, compilationMode),
|
|
4169
4650
|
new NgModuleDecoratorHandler(reflector, evaluator, metaReader, metaRegistry, ngModuleScopeRegistry, referencesRegistry, exportedProviderStatusResolver, semanticDepGraphUpdater, isCore, refEmitter, this.closureCompilerEnabled, this.options.onlyPublishPublicTypingsForNgModules ?? false, injectableRegistry, this.delegatingPerfRecorder, supportTestBed, supportJitMode, compilationMode, localCompilationExtraImportsTracker, jitDeclarationRegistry, this.emitDeclarationOnly)
|
|
@@ -4362,7 +4843,7 @@ function versionMapFromProgram(program, driver) {
|
|
|
4362
4843
|
return versions;
|
|
4363
4844
|
}
|
|
4364
4845
|
|
|
4365
|
-
//
|
|
4846
|
+
// packages/compiler-cli/src/ngtsc/core/src/host.js
|
|
4366
4847
|
import ts26 from "typescript";
|
|
4367
4848
|
var DelegatingCompilerHost = class {
|
|
4368
4849
|
delegate;
|
|
@@ -4395,6 +4876,8 @@ var DelegatingCompilerHost = class {
|
|
|
4395
4876
|
hasInvalidatedResolutions;
|
|
4396
4877
|
resolveModuleNameLiterals;
|
|
4397
4878
|
resolveTypeReferenceDirectiveReferences;
|
|
4879
|
+
// jsDocParsingMode is not a method like the other elements above
|
|
4880
|
+
// TODO: ignore usage can be dropped once 5.2 support is dropped
|
|
4398
4881
|
get jsDocParsingMode() {
|
|
4399
4882
|
return this.delegate.jsDocParsingMode;
|
|
4400
4883
|
}
|
|
@@ -4437,7 +4920,7 @@ var DelegatingCompilerHost = class {
|
|
|
4437
4920
|
return this.delegate[name] !== void 0 ? this.delegate[name].bind(this.delegate) : void 0;
|
|
4438
4921
|
}
|
|
4439
4922
|
};
|
|
4440
|
-
var NgCompilerHost = class extends DelegatingCompilerHost {
|
|
4923
|
+
var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
4441
4924
|
shimAdapter;
|
|
4442
4925
|
shimTagger;
|
|
4443
4926
|
entryPoint = null;
|
|
@@ -4456,15 +4939,32 @@ var NgCompilerHost = class extends DelegatingCompilerHost {
|
|
|
4456
4939
|
this.resolveModuleNames = this.createCachedResolveModuleNamesFunction();
|
|
4457
4940
|
}
|
|
4458
4941
|
}
|
|
4942
|
+
/**
|
|
4943
|
+
* Retrieves a set of `ts.SourceFile`s which should not be emitted as JS files.
|
|
4944
|
+
*
|
|
4945
|
+
* Available after this host is used to create a `ts.Program` (which causes all the files in the
|
|
4946
|
+
* program to be enumerated).
|
|
4947
|
+
*/
|
|
4459
4948
|
get ignoreForEmit() {
|
|
4460
4949
|
return this.shimAdapter.ignoreForEmit;
|
|
4461
4950
|
}
|
|
4951
|
+
/**
|
|
4952
|
+
* Retrieve the array of shim extension prefixes for which shims were created for each original
|
|
4953
|
+
* file.
|
|
4954
|
+
*/
|
|
4462
4955
|
get shimExtensionPrefixes() {
|
|
4463
4956
|
return this.shimAdapter.extensionPrefixes;
|
|
4464
4957
|
}
|
|
4958
|
+
/**
|
|
4959
|
+
* Performs cleanup that needs to happen after a `ts.Program` has been created using this host.
|
|
4960
|
+
*/
|
|
4465
4961
|
postProgramCreationCleanup() {
|
|
4466
4962
|
this.shimTagger.finalize();
|
|
4467
4963
|
}
|
|
4964
|
+
/**
|
|
4965
|
+
* Create an `NgCompilerHost` from a delegate host, an array of input filenames, and the full set
|
|
4966
|
+
* of TypeScript and Angular compiler options.
|
|
4967
|
+
*/
|
|
4468
4968
|
static wrap(delegate, inputFiles, options, oldProgram) {
|
|
4469
4969
|
const topLevelShimGenerators = [];
|
|
4470
4970
|
const perFileShimGenerators = [];
|
|
@@ -4499,11 +4999,22 @@ var NgCompilerHost = class extends DelegatingCompilerHost {
|
|
|
4499
4999
|
}
|
|
4500
5000
|
const shimAdapter = new ShimAdapter(delegate, normalizedTsInputFiles, topLevelShimGenerators, perFileShimGenerators, oldProgram);
|
|
4501
5001
|
const shimTagger = new ShimReferenceTagger(perFileShimGenerators.map((gen) => gen.extensionPrefix));
|
|
4502
|
-
return new
|
|
5002
|
+
return new _NgCompilerHost(delegate, inputFiles, rootDirs, shimAdapter, shimTagger, entryPoint, diagnostics);
|
|
4503
5003
|
}
|
|
5004
|
+
/**
|
|
5005
|
+
* Check whether the given `ts.SourceFile` is a shim file.
|
|
5006
|
+
*
|
|
5007
|
+
* If this returns false, the file is user-provided.
|
|
5008
|
+
*/
|
|
4504
5009
|
isShim(sf) {
|
|
4505
5010
|
return isShim(sf);
|
|
4506
5011
|
}
|
|
5012
|
+
/**
|
|
5013
|
+
* Check whether the given `ts.SourceFile` is a resource file.
|
|
5014
|
+
*
|
|
5015
|
+
* This simply returns `false` for the compiler-cli since resource files are not added as root
|
|
5016
|
+
* files to the project.
|
|
5017
|
+
*/
|
|
4507
5018
|
isResource(sf) {
|
|
4508
5019
|
return false;
|
|
4509
5020
|
}
|
|
@@ -4536,10 +5047,13 @@ var NgCompilerHost = class extends DelegatingCompilerHost {
|
|
|
4536
5047
|
}
|
|
4537
5048
|
};
|
|
4538
5049
|
|
|
4539
|
-
//
|
|
5050
|
+
// packages/compiler-cli/src/ngtsc/program.js
|
|
4540
5051
|
var NgtscProgram = class {
|
|
4541
5052
|
options;
|
|
4542
5053
|
compiler;
|
|
5054
|
+
/**
|
|
5055
|
+
* The primary TypeScript program, which is used for analysis and emit.
|
|
5056
|
+
*/
|
|
4543
5057
|
tsProgram;
|
|
4544
5058
|
host;
|
|
4545
5059
|
incrementalStrategy;
|
|
@@ -4581,7 +5095,9 @@ var NgtscProgram = class {
|
|
|
4581
5095
|
this.incrementalStrategy,
|
|
4582
5096
|
programDriver,
|
|
4583
5097
|
perfRecorder,
|
|
5098
|
+
/* enableTemplateTypeChecker */
|
|
4584
5099
|
false,
|
|
5100
|
+
/* usePoisonedData */
|
|
4585
5101
|
false
|
|
4586
5102
|
);
|
|
4587
5103
|
} else {
|
|
@@ -4663,6 +5179,13 @@ var NgtscProgram = class {
|
|
|
4663
5179
|
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
|
4664
5180
|
}
|
|
4665
5181
|
}
|
|
5182
|
+
/**
|
|
5183
|
+
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
|
|
5184
|
+
* loading of any resources during the process.
|
|
5185
|
+
*
|
|
5186
|
+
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
|
|
5187
|
+
* like SASS files used in `styleUrls`.
|
|
5188
|
+
*/
|
|
4666
5189
|
loadNgStructureAsync() {
|
|
4667
5190
|
return this.compiler.analyzeAsync();
|
|
4668
5191
|
}
|
|
@@ -4744,6 +5267,14 @@ var NgtscProgram = class {
|
|
|
4744
5267
|
getIndexedComponents() {
|
|
4745
5268
|
return this.compiler.getIndexedComponents();
|
|
4746
5269
|
}
|
|
5270
|
+
/**
|
|
5271
|
+
* Gets information for the current program that may be used to generate API
|
|
5272
|
+
* reference documentation. This includes Angular-specific information, such
|
|
5273
|
+
* as component inputs and outputs.
|
|
5274
|
+
*
|
|
5275
|
+
* @param entryPoint Path to the entry point for the package for which API
|
|
5276
|
+
* docs should be extracted.
|
|
5277
|
+
*/
|
|
4747
5278
|
getApiDocumentation(entryPoint, privateModules) {
|
|
4748
5279
|
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
|
4749
5280
|
}
|
|
@@ -4764,15 +5295,15 @@ function mergeEmitResults(emitResults) {
|
|
|
4764
5295
|
return { diagnostics, emitSkipped, emittedFiles };
|
|
4765
5296
|
}
|
|
4766
5297
|
|
|
4767
|
-
//
|
|
5298
|
+
// packages/compiler-cli/src/transformers/program.js
|
|
4768
5299
|
function createProgram({ rootNames, options, host, oldProgram }) {
|
|
4769
5300
|
return new NgtscProgram(rootNames, options, host, oldProgram);
|
|
4770
5301
|
}
|
|
4771
5302
|
|
|
4772
|
-
//
|
|
5303
|
+
// packages/compiler-cli/src/perform_compile.js
|
|
4773
5304
|
import ts29 from "typescript";
|
|
4774
5305
|
|
|
4775
|
-
//
|
|
5306
|
+
// packages/compiler-cli/src/transformers/util.js
|
|
4776
5307
|
import ts28 from "typescript";
|
|
4777
5308
|
function createMessageDiagnostic(messageText) {
|
|
4778
5309
|
return {
|
|
@@ -4786,7 +5317,7 @@ function createMessageDiagnostic(messageText) {
|
|
|
4786
5317
|
};
|
|
4787
5318
|
}
|
|
4788
5319
|
|
|
4789
|
-
//
|
|
5320
|
+
// packages/compiler-cli/src/perform_compile.js
|
|
4790
5321
|
var defaultFormatHost = {
|
|
4791
5322
|
getCurrentDirectory: () => ts29.sys.getCurrentDirectory(),
|
|
4792
5323
|
getCanonicalFileName: (fileName) => fileName,
|
|
@@ -5002,18 +5533,17 @@ export {
|
|
|
5002
5533
|
performCompilation,
|
|
5003
5534
|
defaultGatherDiagnostics
|
|
5004
5535
|
};
|
|
5005
|
-
|
|
5536
|
+
/**
|
|
5006
5537
|
* @license
|
|
5007
5538
|
* Copyright Google LLC All Rights Reserved.
|
|
5008
5539
|
*
|
|
5009
5540
|
* Use of this source code is governed by an MIT-style license that can be
|
|
5010
5541
|
* found in the LICENSE file at https://angular.dev/license
|
|
5011
5542
|
*/
|
|
5012
|
-
|
|
5543
|
+
/*!
|
|
5013
5544
|
* @license
|
|
5014
5545
|
* Copyright Google LLC All Rights Reserved.
|
|
5015
5546
|
*
|
|
5016
5547
|
* Use of this source code is governed by an MIT-style license that can be
|
|
5017
5548
|
* found in the LICENSE file at https://angular.dev/license
|
|
5018
5549
|
*/
|
|
5019
|
-
//# sourceMappingURL=chunk-45WGF6MF.js.map
|