@angular/core 19.0.0-next.9 → 19.0.0-rc.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.
Files changed (42) hide show
  1. package/fesm2022/core.mjs +21183 -19410
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +71 -47
  4. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  5. package/fesm2022/primitives/signals.mjs +8 -6
  6. package/fesm2022/primitives/signals.mjs.map +1 -1
  7. package/fesm2022/rxjs-interop.mjs +90 -10
  8. package/fesm2022/rxjs-interop.mjs.map +1 -1
  9. package/fesm2022/testing.mjs +174 -113
  10. package/fesm2022/testing.mjs.map +1 -1
  11. package/index.d.ts +524 -92
  12. package/package.json +1 -1
  13. package/primitives/event-dispatch/index.d.ts +7 -4
  14. package/primitives/signals/index.d.ts +3 -1
  15. package/rxjs-interop/index.d.ts +35 -4
  16. package/schematics/bundles/{checker-3b2ea20f.js → checker-9ca42e51.js} +2303 -1006
  17. package/schematics/bundles/combine_units-a16385aa.js +1634 -0
  18. package/schematics/bundles/{compiler_host-b4ba5a28.js → compiler_host-31afa4ed.js} +8 -5
  19. package/schematics/bundles/control-flow-migration.js +3 -3
  20. package/schematics/bundles/explicit-standalone-flag.js +29 -9
  21. package/schematics/bundles/imports-4ac08251.js +1 -1
  22. package/schematics/bundles/inject-migration.js +222 -54
  23. package/schematics/bundles/leading_space-d190b83b.js +1 -1
  24. package/schematics/bundles/migrate_ts_type_references-b2a28742.js +1463 -0
  25. package/schematics/bundles/nodes-0e7d45ca.js +1 -1
  26. package/schematics/bundles/output-migration.js +575 -0
  27. package/schematics/bundles/pending-tasks.js +3 -3
  28. package/schematics/bundles/{program-6534a30a.js → program-71beec0b.js} +1385 -460
  29. package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
  30. package/schematics/bundles/provide-initializer.js +179 -0
  31. package/schematics/bundles/route-lazy-loading.js +9 -4
  32. package/schematics/bundles/signal-input-migration.js +183 -311
  33. package/schematics/bundles/signal-queries-migration.js +404 -146
  34. package/schematics/bundles/signals.js +54 -0
  35. package/schematics/bundles/standalone-migration.js +29 -12
  36. package/schematics/collection.json +11 -0
  37. package/schematics/migrations.json +7 -1
  38. package/schematics/ng-generate/output-migration/schema.json +19 -0
  39. package/schematics/ng-generate/signal-queries-migration/schema.json +11 -0
  40. package/schematics/ng-generate/signals/schema.json +65 -0
  41. package/testing/index.d.ts +1 -1
  42. package/schematics/bundles/group_replacements-e1b5cbf8.js +0 -31571
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-next.9
3
+ * @license Angular v19.0.0-rc.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
- var checker = require('./checker-3b2ea20f.js');
9
+ var checker = require('./checker-9ca42e51.js');
10
10
  var ts = require('typescript');
11
11
  var p = require('path');
12
12
  require('os');
@@ -34,9 +34,31 @@ function _interopNamespace(e) {
34
34
  var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
35
35
  var p__namespace = /*#__PURE__*/_interopNamespace(p);
36
36
 
37
+ class XmlTagDefinition {
38
+ closedByParent = false;
39
+ implicitNamespacePrefix = null;
40
+ isVoid = false;
41
+ ignoreFirstLf = false;
42
+ canSelfClose = true;
43
+ preventNamespaceInheritance = false;
44
+ requireExtraParent(currentParent) {
45
+ return false;
46
+ }
47
+ isClosedByChild(name) {
48
+ return false;
49
+ }
50
+ getContentType() {
51
+ return checker.TagContentType.PARSABLE_DATA;
52
+ }
53
+ }
54
+ const _TAG_DEFINITION = new XmlTagDefinition();
55
+ function getXmlTagDefinition(tagName) {
56
+ return _TAG_DEFINITION;
57
+ }
58
+
37
59
  class XmlParser extends checker.Parser {
38
60
  constructor() {
39
- super(checker.getXmlTagDefinition);
61
+ super(getXmlTagDefinition);
40
62
  }
41
63
  parse(source, url, options = {}) {
42
64
  // Blocks and let declarations aren't supported in an XML context.
@@ -190,9 +212,11 @@ class _WriteVisitor$1 {
190
212
  // TODO(vicb): add error management (structure)
191
213
  // Extract messages as xml nodes from the xliff file
192
214
  class XliffParser {
193
- constructor() {
194
- this._locale = null;
195
- }
215
+ // using non-null assertions because they're re(set) by parse()
216
+ _unitMlString;
217
+ _errors;
218
+ _msgIdToHtml;
219
+ _locale = null;
196
220
  parse(xliff, url) {
197
221
  this._unitMlString = null;
198
222
  this._msgIdToHtml = {};
@@ -268,6 +292,8 @@ class XliffParser {
268
292
  }
269
293
  // Convert ml nodes (xliff syntax) to i18n nodes
270
294
  class XmlToI18n$1 {
295
+ // using non-null assertion because it's re(set) by convert()
296
+ _errors;
271
297
  convert(message, url) {
272
298
  const xmlIcu = new XmlParser().parse(message, url, { tokenizeExpansionForms: true });
273
299
  this._errors = xmlIcu.errors;
@@ -399,13 +425,11 @@ class Xliff2 extends checker.Serializer {
399
425
  return { locale: locale, i18nNodesByMsgId };
400
426
  }
401
427
  digest(message) {
402
- return checker.decimalDigest(message, /* preservePlaceholders */ true);
428
+ return checker.decimalDigest(message);
403
429
  }
404
430
  }
405
431
  class _WriteVisitor {
406
- constructor() {
407
- this._nextPlaceholderId = 0;
408
- }
432
+ _nextPlaceholderId = 0;
409
433
  visitText(text, context) {
410
434
  return [new checker.Text$1(text.value)];
411
435
  }
@@ -498,9 +522,11 @@ class _WriteVisitor {
498
522
  }
499
523
  // Extract messages as xml nodes from the xliff file
500
524
  class Xliff2Parser {
501
- constructor() {
502
- this._locale = null;
503
- }
525
+ // using non-null assertions because they're all (re)set by parse()
526
+ _unitMlString;
527
+ _errors;
528
+ _msgIdToHtml;
529
+ _locale = null;
504
530
  parse(xliff, url) {
505
531
  this._unitMlString = null;
506
532
  this._msgIdToHtml = {};
@@ -581,6 +607,8 @@ class Xliff2Parser {
581
607
  }
582
608
  // Convert ml nodes (xliff syntax) to i18n nodes
583
609
  class XmlToI18n {
610
+ // using non-null assertion because re(set) by convert()
611
+ _errors;
584
612
  convert(message, url) {
585
613
  const xmlIcu = new XmlParser().parse(message, url, { tokenizeExpansionForms: true });
586
614
  this._errors = xmlIcu.errors;
@@ -669,13 +697,18 @@ function getTypeForTag(tag) {
669
697
  * A container for message extracted from the templates.
670
698
  */
671
699
  class MessageBundle {
700
+ _htmlParser;
701
+ _implicitTags;
702
+ _implicitAttrs;
703
+ _locale;
704
+ _preserveWhitespace;
705
+ _messages = [];
672
706
  constructor(_htmlParser, _implicitTags, _implicitAttrs, _locale = null, _preserveWhitespace = true) {
673
707
  this._htmlParser = _htmlParser;
674
708
  this._implicitTags = _implicitTags;
675
709
  this._implicitAttrs = _implicitAttrs;
676
710
  this._locale = _locale;
677
711
  this._preserveWhitespace = _preserveWhitespace;
678
- this._messages = [];
679
712
  }
680
713
  updateFromTemplate(source, url, interpolationConfig) {
681
714
  const htmlParserResult = this._htmlParser.parse(source, url, {
@@ -849,6 +882,96 @@ function compileClassDebugInfo(debugInfo) {
849
882
  return iife.callFn([]);
850
883
  }
851
884
 
885
+ /*!
886
+ * @license
887
+ * Copyright Google LLC All Rights Reserved.
888
+ *
889
+ * Use of this source code is governed by an MIT-style license that can be
890
+ * found in the LICENSE file at https://angular.dev/license
891
+ */
892
+ /**
893
+ * Compiles the expression that initializes HMR for a class.
894
+ * @param meta HMR metadata extracted from the class.
895
+ */
896
+ function compileHmrInitializer(meta) {
897
+ const id = encodeURIComponent(`${meta.filePath}@${meta.className}`);
898
+ const urlPartial = `/@ng/component?c=${id}&t=`;
899
+ const moduleName = 'm';
900
+ const dataName = 'd';
901
+ const timestampName = 't';
902
+ const importCallbackName = `${meta.className}_HmrLoad`;
903
+ const locals = meta.locals.map((localName) => checker.variable(localName));
904
+ // m.default
905
+ const defaultRead = checker.variable(moduleName).prop('default');
906
+ // ɵɵreplaceMetadata(Comp, m.default, [...]);
907
+ const replaceCall = checker.importExpr(checker.Identifiers.replaceMetadata)
908
+ .callFn([meta.type, defaultRead, new checker.ExternalExpr(checker.Identifiers.core), checker.literalArr(locals)]);
909
+ // (m) => m.default && ɵɵreplaceMetadata(...)
910
+ const replaceCallback = checker.arrowFn([new checker.FnParam(moduleName)], defaultRead.and(replaceCall));
911
+ // '<urlPartial>' + encodeURIComponent(t)
912
+ const urlValue = checker.literal(urlPartial)
913
+ .plus(checker.variable('encodeURIComponent').callFn([checker.variable(timestampName)]));
914
+ // function Cmp_HmrLoad(t) {
915
+ // import(/* @vite-ignore */ url).then((m) => m.default && replaceMetadata(...));
916
+ // }
917
+ const importCallback = new checker.DeclareFunctionStmt(importCallbackName, [new checker.FnParam(timestampName)], [
918
+ // The vite-ignore special comment is required to prevent Vite from generating a superfluous
919
+ // warning for each usage within the development code. If Vite provides a method to
920
+ // programmatically avoid this warning in the future, this added comment can be removed here.
921
+ new checker.DynamicImportExpr(urlValue, null, '@vite-ignore')
922
+ .prop('then')
923
+ .callFn([replaceCallback])
924
+ .toStmt(),
925
+ ], null, checker.StmtModifier.Final);
926
+ // (d) => d.id === <id> && Cmp_HmrLoad(d.timestamp)
927
+ const updateCallback = checker.arrowFn([new checker.FnParam(dataName)], checker.variable(dataName)
928
+ .prop('id')
929
+ .identical(checker.literal(id))
930
+ .and(checker.variable(importCallbackName).callFn([checker.variable(dataName).prop('timestamp')])));
931
+ // Cmp_HmrLoad(Date.now());
932
+ // Initial call to kick off the loading in order to avoid edge cases with components
933
+ // coming from lazy chunks that change before the chunk has loaded.
934
+ const initialCall = checker.variable(importCallbackName)
935
+ .callFn([checker.variable('Date').prop('now').callFn([])]);
936
+ // import.meta.hot
937
+ const hotRead = checker.variable('import').prop('meta').prop('hot');
938
+ // import.meta.hot.on('angular:component-update', () => ...);
939
+ const hotListener = hotRead
940
+ .clone()
941
+ .prop('on')
942
+ .callFn([checker.literal('angular:component-update'), updateCallback]);
943
+ return checker.arrowFn([], [
944
+ // function Cmp_HmrLoad() {...}.
945
+ importCallback,
946
+ // ngDevMode && Cmp_HmrLoad(Date.now());
947
+ checker.devOnlyGuardedExpression(initialCall).toStmt(),
948
+ // ngDevMode && import.meta.hot && import.meta.hot.on(...)
949
+ checker.devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
950
+ ])
951
+ .callFn([]);
952
+ }
953
+ /**
954
+ * Compiles the HMR update callback for a class.
955
+ * @param definitions Compiled definitions for the class (e.g. `defineComponent` calls).
956
+ * @param constantStatements Supporting constants statements that were generated alongside
957
+ * the definition.
958
+ * @param meta HMR metadata extracted from the class.
959
+ */
960
+ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
961
+ // The class name should always be first and core should be second.
962
+ const params = [meta.className, meta.coreName, ...meta.locals].map((name) => new checker.FnParam(name, checker.DYNAMIC_TYPE));
963
+ const body = [...constantStatements];
964
+ for (const field of definitions) {
965
+ if (field.initializer !== null) {
966
+ body.push(checker.variable(meta.className).prop(field.name).set(field.initializer).toStmt());
967
+ for (const stmt of field.statements) {
968
+ body.push(stmt);
969
+ }
970
+ }
971
+ }
972
+ return new checker.DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, checker.StmtModifier.Final);
973
+ }
974
+
852
975
  /**
853
976
  * Every time we make a breaking change to the declaration interface or partial-linker behavior, we
854
977
  * must update this constant to prevent old partial-linkers from incorrectly processing the
@@ -864,7 +987,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
864
987
  function compileDeclareClassMetadata(metadata) {
865
988
  const definitionMap = new checker.DefinitionMap();
866
989
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
867
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
990
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
868
991
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
869
992
  definitionMap.set('type', metadata.type);
870
993
  definitionMap.set('decorators', metadata.decorators);
@@ -882,7 +1005,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
882
1005
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? checker.literal(null));
883
1006
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? checker.literal(null));
884
1007
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
885
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1008
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
886
1009
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
887
1010
  definitionMap.set('type', metadata.type);
888
1011
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -977,10 +1100,10 @@ function createDirectiveDefinitionMap(meta) {
977
1100
  const definitionMap = new checker.DefinitionMap();
978
1101
  const minVersion = getMinimumVersionForPartialOutput(meta);
979
1102
  definitionMap.set('minVersion', checker.literal(minVersion));
980
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1103
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
981
1104
  // e.g. `type: MyDirective`
982
1105
  definitionMap.set('type', meta.type.value);
983
- if (meta.isStandalone) {
1106
+ if (meta.isStandalone !== undefined) {
984
1107
  definitionMap.set('isStandalone', checker.literal(meta.isStandalone));
985
1108
  }
986
1109
  if (meta.isSignal) {
@@ -1349,10 +1472,7 @@ function compileUsedDependenciesMetadata(meta) {
1349
1472
  });
1350
1473
  }
1351
1474
  class BlockPresenceVisitor extends checker.RecursiveVisitor$1 {
1352
- constructor() {
1353
- super(...arguments);
1354
- this.hasBlocks = false;
1355
- }
1475
+ hasBlocks = false;
1356
1476
  visitDeferredBlock() {
1357
1477
  this.hasBlocks = true;
1358
1478
  }
@@ -1396,7 +1516,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
1396
1516
  function compileDeclareFactoryFunction(meta) {
1397
1517
  const definitionMap = new checker.DefinitionMap();
1398
1518
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
1399
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1519
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
1400
1520
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
1401
1521
  definitionMap.set('type', meta.type.value);
1402
1522
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -1431,7 +1551,7 @@ function compileDeclareInjectableFromMetadata(meta) {
1431
1551
  function createInjectableDefinitionMap(meta) {
1432
1552
  const definitionMap = new checker.DefinitionMap();
1433
1553
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
1434
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1554
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
1435
1555
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
1436
1556
  definitionMap.set('type', meta.type.value);
1437
1557
  // Only generate providedIn property if it has a non-null value
@@ -1482,7 +1602,7 @@ function compileDeclareInjectorFromMetadata(meta) {
1482
1602
  function createInjectorDefinitionMap(meta) {
1483
1603
  const definitionMap = new checker.DefinitionMap();
1484
1604
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
1485
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1605
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
1486
1606
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
1487
1607
  definitionMap.set('type', meta.type.value);
1488
1608
  definitionMap.set('providers', meta.providers);
@@ -1515,7 +1635,7 @@ function createNgModuleDefinitionMap(meta) {
1515
1635
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
1516
1636
  }
1517
1637
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
1518
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1638
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
1519
1639
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
1520
1640
  definitionMap.set('type', meta.type.value);
1521
1641
  // We only generate the keys in the metadata if the arrays contain values.
@@ -1566,11 +1686,11 @@ function compileDeclarePipeFromMetadata(meta) {
1566
1686
  function createPipeDefinitionMap(meta) {
1567
1687
  const definitionMap = new checker.DefinitionMap();
1568
1688
  definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION));
1569
- definitionMap.set('version', checker.literal('19.0.0-next.9'));
1689
+ definitionMap.set('version', checker.literal('19.0.0-rc.1'));
1570
1690
  definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
1571
1691
  // e.g. `type: MyPipe`
1572
1692
  definitionMap.set('type', meta.type.value);
1573
- if (meta.isStandalone) {
1693
+ if (meta.isStandalone !== undefined) {
1574
1694
  definitionMap.set('isStandalone', checker.literal(meta.isStandalone));
1575
1695
  }
1576
1696
  // e.g. `name: "myPipe"`
@@ -1601,14 +1721,15 @@ const CHARS_TO_ESCAPE = /[^a-zA-Z0-9/_]/g;
1601
1721
  * README.md for more details.
1602
1722
  */
1603
1723
  class UnifiedModulesAliasingHost {
1724
+ unifiedModulesHost;
1604
1725
  constructor(unifiedModulesHost) {
1605
1726
  this.unifiedModulesHost = unifiedModulesHost;
1606
- /**
1607
- * With a `UnifiedModulesHost`, aliases are chosen automatically without the need to look through
1608
- * the exports present in a .d.ts file, so we can avoid cluttering the .d.ts files.
1609
- */
1610
- this.aliasExportsInDts = false;
1611
1727
  }
1728
+ /**
1729
+ * With a `UnifiedModulesHost`, aliases are chosen automatically without the need to look through
1730
+ * the exports present in a .d.ts file, so we can avoid cluttering the .d.ts files.
1731
+ */
1732
+ aliasExportsInDts = false;
1612
1733
  maybeAliasSymbolAs(ref, context, ngModuleName, isReExport) {
1613
1734
  if (!isReExport) {
1614
1735
  // Aliasing is used with a UnifiedModulesHost to prevent transitive dependencies. Thus,
@@ -1654,16 +1775,17 @@ class UnifiedModulesAliasingHost {
1654
1775
  * more details.
1655
1776
  */
1656
1777
  class PrivateExportAliasingHost {
1778
+ host;
1657
1779
  constructor(host) {
1658
1780
  this.host = host;
1659
- /**
1660
- * Under private export aliasing, the `AbsoluteModuleStrategy` used for emitting references will
1661
- * will select aliased exports that it finds in the .d.ts file for an NgModule's file. Thus,
1662
- * emitting these exports in .d.ts is a requirement for the `PrivateExportAliasingHost` to
1663
- * function correctly.
1664
- */
1665
- this.aliasExportsInDts = true;
1666
1781
  }
1782
+ /**
1783
+ * Under private export aliasing, the `AbsoluteModuleStrategy` used for emitting references will
1784
+ * will select aliased exports that it finds in the .d.ts file for an NgModule's file. Thus,
1785
+ * emitting these exports in .d.ts is a requirement for the `PrivateExportAliasingHost` to
1786
+ * function correctly.
1787
+ */
1788
+ aliasExportsInDts = true;
1667
1789
  maybeAliasSymbolAs(ref, context, ngModuleName) {
1668
1790
  if (ref.hasOwningModuleGuess) {
1669
1791
  // Skip nodes that already have an associated absolute module specifier, since they can be
@@ -1731,6 +1853,27 @@ function normalizeSeparators(path) {
1731
1853
  // TODO: normalize path only for OS that need it.
1732
1854
  return path.replace(/\\/g, '/');
1733
1855
  }
1856
+ /**
1857
+ * Attempts to generate a project-relative path
1858
+ * @param sourceFile
1859
+ * @param rootDirs
1860
+ * @param compilerHost
1861
+ * @returns
1862
+ */
1863
+ function getProjectRelativePath(sourceFile, rootDirs, compilerHost) {
1864
+ // Note: we need to pass both the file name and the root directories through getCanonicalFileName,
1865
+ // because the root directories might've been passed through it already while the source files
1866
+ // definitely have not. This can break the relative return value, because in some platforms
1867
+ // getCanonicalFileName lowercases the path.
1868
+ const filePath = compilerHost.getCanonicalFileName(sourceFile.fileName);
1869
+ for (const rootDir of rootDirs) {
1870
+ const rel = checker.relative(compilerHost.getCanonicalFileName(rootDir), filePath);
1871
+ if (!rel.startsWith('..')) {
1872
+ return rel;
1873
+ }
1874
+ }
1875
+ return null;
1876
+ }
1734
1877
 
1735
1878
  /**
1736
1879
  * `ImportRewriter` that does no rewriting.
@@ -1742,6 +1885,9 @@ class NoopImportRewriter {
1742
1885
  rewriteSpecifier(specifier, inContextOfFile) {
1743
1886
  return specifier;
1744
1887
  }
1888
+ rewriteNamespaceImportIdentifier(specifier) {
1889
+ return specifier;
1890
+ }
1745
1891
  }
1746
1892
  /**
1747
1893
  * A mapping of supported symbols that can be imported from within @angular/core, and the names by
@@ -1768,6 +1914,7 @@ const CORE_MODULE = '@angular/core';
1768
1914
  * file instead.
1769
1915
  */
1770
1916
  class R3SymbolsImportRewriter {
1917
+ r3SymbolsPath;
1771
1918
  constructor(r3SymbolsPath) {
1772
1919
  this.r3SymbolsPath = r3SymbolsPath;
1773
1920
  }
@@ -1789,6 +1936,9 @@ class R3SymbolsImportRewriter {
1789
1936
  }
1790
1937
  return relativePathToR3Symbols;
1791
1938
  }
1939
+ rewriteNamespaceImportIdentifier(specifier) {
1940
+ return specifier;
1941
+ }
1792
1942
  }
1793
1943
  function validateAndRewriteCoreSymbol(name) {
1794
1944
  if (!CORE_SUPPORTED_SYMBOLS.has(name)) {
@@ -1806,15 +1956,17 @@ const AssumeEager = 'AssumeEager';
1806
1956
  * in favor of using a dynamic import for cases when defer blocks are used.
1807
1957
  */
1808
1958
  class DeferredSymbolTracker {
1959
+ typeChecker;
1960
+ onlyExplicitDeferDependencyImports;
1961
+ imports = new Map();
1962
+ /**
1963
+ * Map of a component class -> all import declarations that bring symbols
1964
+ * used within `@Component.deferredImports` field.
1965
+ */
1966
+ explicitlyDeferredImports = new Map();
1809
1967
  constructor(typeChecker, onlyExplicitDeferDependencyImports) {
1810
1968
  this.typeChecker = typeChecker;
1811
1969
  this.onlyExplicitDeferDependencyImports = onlyExplicitDeferDependencyImports;
1812
- this.imports = new Map();
1813
- /**
1814
- * Map of a component class -> all import declarations that bring symbols
1815
- * used within `@Component.deferredImports` field.
1816
- */
1817
- this.explicitlyDeferredImports = new Map();
1818
1970
  }
1819
1971
  /**
1820
1972
  * Given an import declaration node, extract the names of all imported symbols
@@ -1993,10 +2145,8 @@ class DeferredSymbolTracker {
1993
2145
  * type checker may be necessary, depending on the context. Also does not track dynamic imports.
1994
2146
  */
1995
2147
  class ImportedSymbolsTracker {
1996
- constructor() {
1997
- this.fileToNamedImports = new WeakMap();
1998
- this.fileToNamespaceImports = new WeakMap();
1999
- }
2148
+ fileToNamedImports = new WeakMap();
2149
+ fileToNamespaceImports = new WeakMap();
2000
2150
  /**
2001
2151
  * Checks if an identifier is a potential reference to a specific named import within the same
2002
2152
  * file.
@@ -2112,12 +2262,13 @@ class ImportedSymbolsTracker {
2112
2262
  *
2113
2263
  */
2114
2264
  class LocalCompilationExtraImportsTracker {
2265
+ typeChecker;
2266
+ localImportsMap = new Map();
2267
+ globalImportsSet = new Set();
2268
+ /** Names of the files marked for extra import generation. */
2269
+ markedFilesSet = new Set();
2115
2270
  constructor(typeChecker) {
2116
2271
  this.typeChecker = typeChecker;
2117
- this.localImportsMap = new Map();
2118
- this.globalImportsSet = new Set();
2119
- /** Names of the files marked for extra import generation. */
2120
- this.markedFilesSet = new Set();
2121
2272
  }
2122
2273
  /**
2123
2274
  * Marks the source file for extra imports generation.
@@ -2192,6 +2343,10 @@ function removeQuotations(s) {
2192
2343
  * definitions).
2193
2344
  */
2194
2345
  class ModuleResolver {
2346
+ program;
2347
+ compilerOptions;
2348
+ host;
2349
+ moduleResolutionCache;
2195
2350
  constructor(program, compilerOptions, host, moduleResolutionCache) {
2196
2351
  this.program = program;
2197
2352
  this.compilerOptions = compilerOptions;
@@ -2401,6 +2556,14 @@ function createUnsuitableInjectionTokenError(clazz, error) {
2401
2556
  * property name, or mapping from a specific class property to its binding property name.
2402
2557
  */
2403
2558
  class ClassPropertyMapping {
2559
+ /**
2560
+ * Mapping from class property names to the single `InputOrOutput` for that class property.
2561
+ */
2562
+ forwardMap;
2563
+ /**
2564
+ * Mapping from property names to one or more `InputOrOutput`s which share that name.
2565
+ */
2566
+ reverseMap;
2404
2567
  constructor(forwardMap) {
2405
2568
  this.forwardMap = forwardMap;
2406
2569
  this.reverseMap = reverseMapFromForwardMap(forwardMap);
@@ -2530,6 +2693,8 @@ function reverseMapFromForwardMap(forwardMap) {
2530
2693
  * from an upstream compilation already.
2531
2694
  */
2532
2695
  class DtsMetadataReader {
2696
+ checker;
2697
+ reflector;
2533
2698
  constructor(checker, reflector) {
2534
2699
  this.checker = checker;
2535
2700
  this.reflector = reflector;
@@ -2560,12 +2725,21 @@ class DtsMetadataReader {
2560
2725
  }
2561
2726
  // Read the ModuleData out of the type arguments.
2562
2727
  const [_, declarationMetadata, importMetadata, exportMetadata] = ngModuleDef.type.typeArguments;
2728
+ const declarations = checker.extractReferencesFromType(this.checker, declarationMetadata, ref.bestGuessOwningModule);
2729
+ const exports = checker.extractReferencesFromType(this.checker, exportMetadata, ref.bestGuessOwningModule);
2730
+ const imports = checker.extractReferencesFromType(this.checker, importMetadata, ref.bestGuessOwningModule);
2731
+ // The module is considered poisoned if it's exports couldn't be
2732
+ // resolved completely. This would make the module not necessarily
2733
+ // usable for scope computation relying on this module; so we propagate
2734
+ // this "incompleteness" information to the caller.
2735
+ const isPoisoned = exports.isIncomplete;
2563
2736
  return {
2564
2737
  kind: checker.MetaKind.NgModule,
2565
2738
  ref,
2566
- declarations: checker.extractReferencesFromType(this.checker, declarationMetadata, ref.bestGuessOwningModule),
2567
- exports: checker.extractReferencesFromType(this.checker, exportMetadata, ref.bestGuessOwningModule),
2568
- imports: checker.extractReferencesFromType(this.checker, importMetadata, ref.bestGuessOwningModule),
2739
+ declarations: declarations.result,
2740
+ isPoisoned,
2741
+ exports: exports.result,
2742
+ imports: imports.result,
2569
2743
  schemas: [],
2570
2744
  rawDeclarations: null,
2571
2745
  rawImports: null,
@@ -2608,6 +2782,8 @@ class DtsMetadataReader {
2608
2782
  param.typeValueReference.importedName === 'TemplateRef');
2609
2783
  });
2610
2784
  const ngContentSelectors = def.type.typeArguments.length > 6 ? checker.readStringArrayType(def.type.typeArguments[6]) : null;
2785
+ // Note: the default value is still `false` here, because only legacy .d.ts files written before
2786
+ // we had so many arguments use this default.
2611
2787
  const isStandalone = def.type.typeArguments.length > 7 && (checker.readBooleanType(def.type.typeArguments[7]) ?? false);
2612
2788
  const inputs = ClassPropertyMapping.fromMappedObject(readInputsType(def.type.typeArguments[3]));
2613
2789
  const outputs = ClassPropertyMapping.fromMappedObject(checker.readMapType(def.type.typeArguments[4], checker.readStringType));
@@ -2615,6 +2791,10 @@ class DtsMetadataReader {
2615
2791
  ? readHostDirectivesType(this.checker, def.type.typeArguments[8], ref.bestGuessOwningModule)
2616
2792
  : null;
2617
2793
  const isSignal = def.type.typeArguments.length > 9 && (checker.readBooleanType(def.type.typeArguments[9]) ?? false);
2794
+ // At this point in time, the `.d.ts` may not be fully extractable when
2795
+ // trying to resolve host directive types to their declarations.
2796
+ // If this cannot be done completely, the metadata is incomplete and "poisoned".
2797
+ const isPoisoned = hostDirectives !== null && hostDirectives?.isIncomplete;
2618
2798
  return {
2619
2799
  kind: checker.MetaKind.Directive,
2620
2800
  matchSource: checker.MatchSource.Selector,
@@ -2625,11 +2805,11 @@ class DtsMetadataReader {
2625
2805
  exportAs: checker.readStringArrayType(def.type.typeArguments[2]),
2626
2806
  inputs,
2627
2807
  outputs,
2628
- hostDirectives,
2808
+ hostDirectives: hostDirectives?.result ?? null,
2629
2809
  queries: checker.readStringArrayType(def.type.typeArguments[5]),
2630
2810
  ...checker.extractDirectiveTypeCheckMeta(clazz, inputs, this.reflector),
2631
2811
  baseClass: readBaseClass(clazz, this.checker, this.reflector),
2632
- isPoisoned: false,
2812
+ isPoisoned,
2633
2813
  isStructural,
2634
2814
  animationTriggerNames: null,
2635
2815
  ngContentSelectors,
@@ -2771,21 +2951,27 @@ function readHostDirectivesType(checker$1, type, bestGuessOwningModule) {
2771
2951
  return null;
2772
2952
  }
2773
2953
  const result = [];
2954
+ let isIncomplete = false;
2774
2955
  for (const hostDirectiveType of type.elements) {
2775
2956
  const { directive, inputs, outputs } = checker.readMapType(hostDirectiveType, (type) => type);
2776
2957
  if (directive) {
2777
2958
  if (!ts__default["default"].isTypeQueryNode(directive)) {
2778
2959
  throw new Error(`Expected TypeQueryNode: ${checker.nodeDebugInfo(directive)}`);
2779
2960
  }
2961
+ const ref = checker.extraReferenceFromTypeQuery(checker$1, directive, type, bestGuessOwningModule);
2962
+ if (ref === null) {
2963
+ isIncomplete = true;
2964
+ continue;
2965
+ }
2780
2966
  result.push({
2781
- directive: checker.extraReferenceFromTypeQuery(checker$1, directive, type, bestGuessOwningModule),
2967
+ directive: ref,
2782
2968
  isForwardReference: false,
2783
2969
  inputs: checker.readMapType(inputs, checker.readStringType),
2784
2970
  outputs: checker.readMapType(outputs, checker.readStringType),
2785
2971
  });
2786
2972
  }
2787
2973
  }
2788
- return result.length > 0 ? result : null;
2974
+ return result.length > 0 ? { result, isIncomplete } : null;
2789
2975
  }
2790
2976
 
2791
2977
  /**
@@ -2867,11 +3053,9 @@ function flattenInheritedDirectiveMetadata(reader, dir) {
2867
3053
  * unit, which supports both reading and registering.
2868
3054
  */
2869
3055
  class LocalMetadataRegistry {
2870
- constructor() {
2871
- this.directives = new Map();
2872
- this.ngModules = new Map();
2873
- this.pipes = new Map();
2874
- }
3056
+ directives = new Map();
3057
+ ngModules = new Map();
3058
+ pipes = new Map();
2875
3059
  getDirectiveMetadata(ref) {
2876
3060
  return this.directives.has(ref.node) ? this.directives.get(ref.node) : null;
2877
3061
  }
@@ -2906,6 +3090,7 @@ class LocalMetadataRegistry {
2906
3090
  * instances.
2907
3091
  */
2908
3092
  class CompoundMetadataRegistry {
3093
+ registries;
2909
3094
  constructor(registries) {
2910
3095
  this.registries = registries;
2911
3096
  }
@@ -2934,12 +3119,10 @@ class CompoundMetadataRegistry {
2934
3119
  * assistance.
2935
3120
  */
2936
3121
  class ResourceRegistry {
2937
- constructor() {
2938
- this.externalTemplateToComponentsMap = new Map();
2939
- this.componentToTemplateMap = new Map();
2940
- this.componentToStylesMap = new Map();
2941
- this.externalStyleToComponentsMap = new Map();
2942
- }
3122
+ externalTemplateToComponentsMap = new Map();
3123
+ componentToTemplateMap = new Map();
3124
+ componentToStylesMap = new Map();
3125
+ externalStyleToComponentsMap = new Map();
2943
3126
  getComponentsWithTemplate(template) {
2944
3127
  if (!this.externalTemplateToComponentsMap.has(template)) {
2945
3128
  return new Set();
@@ -3002,14 +3185,15 @@ class ResourceRegistry {
3002
3185
  * the NgModule & standalone import graph.
3003
3186
  */
3004
3187
  class ExportedProviderStatusResolver {
3188
+ metaReader;
3189
+ /**
3190
+ * `ClassDeclaration`s that we are in the process of determining the provider status for.
3191
+ *
3192
+ * This is used to detect cycles in the import graph and avoid getting stuck in them.
3193
+ */
3194
+ calculating = new Set();
3005
3195
  constructor(metaReader) {
3006
3196
  this.metaReader = metaReader;
3007
- /**
3008
- * `ClassDeclaration`s that we are in the process of determining the provider status for.
3009
- *
3010
- * This is used to detect cycles in the import graph and avoid getting stuck in them.
3011
- */
3012
- this.calculating = new Set();
3013
3197
  }
3014
3198
  /**
3015
3199
  * Determines whether `ref` may or may not export providers to NgModules which import it.
@@ -3080,9 +3264,10 @@ class ExportedProviderStatusResolver {
3080
3264
  const EMPTY_ARRAY$1 = [];
3081
3265
  /** Resolves the host directives of a directive to a flat array of matches. */
3082
3266
  class HostDirectivesResolver {
3267
+ metaReader;
3268
+ cache = new Map();
3083
3269
  constructor(metaReader) {
3084
3270
  this.metaReader = metaReader;
3085
- this.cache = new Map();
3086
3271
  }
3087
3272
  /** Resolves all of the host directives that apply to a directive. */
3088
3273
  resolve(metadata) {
@@ -3226,9 +3411,10 @@ function traceDynamicValue(node, value) {
3226
3411
  return value.accept(new TraceDynamicValueVisitor(node));
3227
3412
  }
3228
3413
  class TraceDynamicValueVisitor {
3414
+ node;
3415
+ currentContainerNode = null;
3229
3416
  constructor(node) {
3230
3417
  this.node = node;
3231
- this.currentContainerNode = null;
3232
3418
  }
3233
3419
  visitDynamicInput(value) {
3234
3420
  const trace = value.reason.accept(this);
@@ -3326,6 +3512,9 @@ function getContainerNode(node) {
3326
3512
  }
3327
3513
 
3328
3514
  class PartialEvaluator {
3515
+ host;
3516
+ checker;
3517
+ dependencyTracker;
3329
3518
  constructor(host, checker, dependencyTracker) {
3330
3519
  this.host = host;
3331
3520
  this.checker = checker;
@@ -3380,6 +3569,12 @@ function timeSinceInMicros(mark) {
3380
3569
  * A `PerfRecorder` that actively tracks performance statistics.
3381
3570
  */
3382
3571
  class ActivePerfRecorder {
3572
+ zeroTime;
3573
+ counters;
3574
+ phaseTime;
3575
+ bytes;
3576
+ currentPhase = checker.PerfPhase.Unaccounted;
3577
+ currentPhaseEntered;
3383
3578
  /**
3384
3579
  * Creates an `ActivePerfRecorder` with its zero point set to the current time.
3385
3580
  */
@@ -3388,7 +3583,6 @@ class ActivePerfRecorder {
3388
3583
  }
3389
3584
  constructor(zeroTime) {
3390
3585
  this.zeroTime = zeroTime;
3391
- this.currentPhase = checker.PerfPhase.Unaccounted;
3392
3586
  this.currentPhaseEntered = this.zeroTime;
3393
3587
  this.counters = Array(checker.PerfEvent.LAST).fill(0);
3394
3588
  this.phaseTime = Array(checker.PerfPhase.LAST).fill(0);
@@ -3463,6 +3657,7 @@ class ActivePerfRecorder {
3463
3657
  * the same `NgCompiler` for a new compilation.
3464
3658
  */
3465
3659
  class DelegatingPerfRecorder {
3660
+ target;
3466
3661
  constructor(target) {
3467
3662
  this.target = target;
3468
3663
  }
@@ -3503,6 +3698,32 @@ class DelegatingPerfRecorder {
3503
3698
  * class (like adding fields or type declarations).
3504
3699
  */
3505
3700
  class TraitCompiler {
3701
+ handlers;
3702
+ reflector;
3703
+ perf;
3704
+ incrementalBuild;
3705
+ compileNonExportedClasses;
3706
+ compilationMode;
3707
+ dtsTransforms;
3708
+ semanticDepGraphUpdater;
3709
+ sourceFileTypeIdentifier;
3710
+ /**
3711
+ * Maps class declarations to their `ClassRecord`, which tracks the Ivy traits being applied to
3712
+ * those classes.
3713
+ */
3714
+ classes = new Map();
3715
+ /**
3716
+ * Maps source files to any class declaration(s) within them which have been discovered to contain
3717
+ * Ivy traits.
3718
+ */
3719
+ fileToClasses = new Map();
3720
+ /**
3721
+ * Tracks which source files have been analyzed but did not contain any traits. This set allows
3722
+ * the compiler to skip analyzing these files in an incremental rebuild.
3723
+ */
3724
+ filesWithoutTraits = new Set();
3725
+ reexportMap = new Map();
3726
+ handlersByName = new Map();
3506
3727
  constructor(handlers, reflector, perf, incrementalBuild, compileNonExportedClasses, compilationMode, dtsTransforms, semanticDepGraphUpdater, sourceFileTypeIdentifier) {
3507
3728
  this.handlers = handlers;
3508
3729
  this.reflector = reflector;
@@ -3513,23 +3734,6 @@ class TraitCompiler {
3513
3734
  this.dtsTransforms = dtsTransforms;
3514
3735
  this.semanticDepGraphUpdater = semanticDepGraphUpdater;
3515
3736
  this.sourceFileTypeIdentifier = sourceFileTypeIdentifier;
3516
- /**
3517
- * Maps class declarations to their `ClassRecord`, which tracks the Ivy traits being applied to
3518
- * those classes.
3519
- */
3520
- this.classes = new Map();
3521
- /**
3522
- * Maps source files to any class declaration(s) within them which have been discovered to contain
3523
- * Ivy traits.
3524
- */
3525
- this.fileToClasses = new Map();
3526
- /**
3527
- * Tracks which source files have been analyzed but did not contain any traits. This set allows
3528
- * the compiler to skip analyzing these files in an incremental rebuild.
3529
- */
3530
- this.filesWithoutTraits = new Set();
3531
- this.reexportMap = new Map();
3532
- this.handlersByName = new Map();
3533
3737
  for (const handler of handlers) {
3534
3738
  this.handlersByName.set(handler.name, handler);
3535
3739
  }
@@ -4024,6 +4228,25 @@ class TraitCompiler {
4024
4228
  // Return the instruction to the transformer so the fields will be added.
4025
4229
  return res.length > 0 ? res : null;
4026
4230
  }
4231
+ compileHmrUpdateCallback(clazz) {
4232
+ const original = ts__default["default"].getOriginalNode(clazz);
4233
+ if (!this.reflector.isClass(clazz) ||
4234
+ !this.reflector.isClass(original) ||
4235
+ !this.classes.has(original)) {
4236
+ return null;
4237
+ }
4238
+ const record = this.classes.get(original);
4239
+ for (const trait of record.traits) {
4240
+ // Cannot compile a trait that is not resolved, or had any errors in its declaration.
4241
+ if (trait.state === checker.TraitState.Resolved &&
4242
+ trait.handler.compileHmrUpdateDeclaration !== undefined &&
4243
+ !containsErrors(trait.analysisDiagnostics) &&
4244
+ !containsErrors(trait.resolveDiagnostics)) {
4245
+ return trait.handler.compileHmrUpdateDeclaration(clazz, trait.analysis, trait.resolution);
4246
+ }
4247
+ }
4248
+ return null;
4249
+ }
4027
4250
  decoratorsFor(node) {
4028
4251
  const original = ts__default["default"].getOriginalNode(node);
4029
4252
  if (!this.reflector.isClass(original) || !this.classes.has(original)) {
@@ -4075,9 +4298,7 @@ function containsErrors(diagnostics) {
4075
4298
  * have their declaration file transformed.
4076
4299
  */
4077
4300
  class DtsTransformRegistry {
4078
- constructor() {
4079
- this.ivyDeclarationTransforms = new Map();
4080
- }
4301
+ ivyDeclarationTransforms = new Map();
4081
4302
  getIvyDeclarationTransform(sf) {
4082
4303
  if (!this.ivyDeclarationTransforms.has(sf)) {
4083
4304
  this.ivyDeclarationTransforms.set(sf, new IvyDeclarationDtsTransform());
@@ -4125,6 +4346,10 @@ function declarationTransformFactory(transformRegistry, reflector, refEmitter, i
4125
4346
  * Processes .d.ts file text and adds static field declarations, with types.
4126
4347
  */
4127
4348
  class DtsTransformer {
4349
+ ctx;
4350
+ reflector;
4351
+ refEmitter;
4352
+ importRewriter;
4128
4353
  constructor(ctx, reflector, refEmitter, importRewriter) {
4129
4354
  this.ctx = ctx;
4130
4355
  this.reflector = reflector;
@@ -4206,9 +4431,7 @@ class DtsTransformer {
4206
4431
  }
4207
4432
  }
4208
4433
  class IvyDeclarationDtsTransform {
4209
- constructor() {
4210
- this.declarationFields = new Map();
4211
- }
4434
+ declarationFields = new Map();
4212
4435
  addFields(decl, fields) {
4213
4436
  this.declarationFields.set(decl, fields);
4214
4437
  }
@@ -4254,16 +4477,14 @@ function visit(node, visitor, context) {
4254
4477
  * of other nodes before them.
4255
4478
  */
4256
4479
  class Visitor {
4257
- constructor() {
4258
- /**
4259
- * Maps statements to an array of statements that should be inserted before them.
4260
- */
4261
- this._before = new Map();
4262
- /**
4263
- * Maps statements to an array of statements that should be inserted after them.
4264
- */
4265
- this._after = new Map();
4266
- }
4480
+ /**
4481
+ * Maps statements to an array of statements that should be inserted before them.
4482
+ */
4483
+ _before = new Map();
4484
+ /**
4485
+ * Maps statements to an array of statements that should be inserted after them.
4486
+ */
4487
+ _after = new Map();
4267
4488
  _visitListEntryNode(node, visitor) {
4268
4489
  const result = visitor(node);
4269
4490
  if (result.before !== undefined) {
@@ -4349,12 +4570,14 @@ function ivyTransformFactory(compilation, reflector, importRewriter, defaultImpo
4349
4570
  * does NOT perform any TS transformations.
4350
4571
  */
4351
4572
  class IvyCompilationVisitor extends Visitor {
4573
+ compilation;
4574
+ constantPool;
4575
+ classCompilationMap = new Map();
4576
+ deferrableImports = new Set();
4352
4577
  constructor(compilation, constantPool) {
4353
4578
  super();
4354
4579
  this.compilation = compilation;
4355
4580
  this.constantPool = constantPool;
4356
- this.classCompilationMap = new Map();
4357
- this.deferrableImports = new Set();
4358
4581
  }
4359
4582
  visitClassDeclaration(node) {
4360
4583
  // Determine if this class has an Ivy field that needs to be added, and compile the field
@@ -4379,6 +4602,14 @@ class IvyCompilationVisitor extends Visitor {
4379
4602
  * compilation results (provided as an argument).
4380
4603
  */
4381
4604
  class IvyTransformationVisitor extends Visitor {
4605
+ compilation;
4606
+ classCompilationMap;
4607
+ reflector;
4608
+ importManager;
4609
+ recordWrappedNodeExpr;
4610
+ isClosureCompilerEnabled;
4611
+ isCore;
4612
+ deferrableImports;
4382
4613
  constructor(compilation, classCompilationMap, reflector, importManager, recordWrappedNodeExpr, isClosureCompilerEnabled, isCore, deferrableImports) {
4383
4614
  super();
4384
4615
  this.compilation = compilation;
@@ -5036,10 +5267,12 @@ function compileDeclareFactory(metadata) {
5036
5267
  * injectables, directives, pipes).
5037
5268
  */
5038
5269
  class InjectableClassRegistry {
5270
+ host;
5271
+ isCore;
5272
+ classes = new Map();
5039
5273
  constructor(host, isCore) {
5040
5274
  this.host = host;
5041
5275
  this.isCore = isCore;
5042
- this.classes = new Map();
5043
5276
  }
5044
5277
  registerInjectable(declaration, meta) {
5045
5278
  this.classes.set(declaration, meta);
@@ -5205,12 +5438,12 @@ function removeIdentifierReferences(node, names) {
5205
5438
  return result.transformed[0];
5206
5439
  }
5207
5440
 
5208
- function extractClassDebugInfo(clazz, reflection, rootDirs, forbidOrphanRendering) {
5441
+ function extractClassDebugInfo(clazz, reflection, compilerHost, rootDirs, forbidOrphanRendering) {
5209
5442
  if (!reflection.isClass(clazz)) {
5210
5443
  return null;
5211
5444
  }
5212
5445
  const srcFile = clazz.getSourceFile();
5213
- const srcFileMaybeRelativePath = computeRelativePathIfPossible(srcFile.fileName, rootDirs);
5446
+ const srcFileMaybeRelativePath = getProjectRelativePath(srcFile, rootDirs, compilerHost);
5214
5447
  return {
5215
5448
  type: new checker.WrappedNodeExpr(clazz.name),
5216
5449
  className: checker.literal(clazz.name.getText()),
@@ -5219,19 +5452,6 @@ function extractClassDebugInfo(clazz, reflection, rootDirs, forbidOrphanRenderin
5219
5452
  forbidOrphanRendering,
5220
5453
  };
5221
5454
  }
5222
- /**
5223
- * Computes a source file path relative to the project root folder if possible, otherwise returns
5224
- * null.
5225
- */
5226
- function computeRelativePathIfPossible(filePath, rootDirs) {
5227
- for (const rootDir of rootDirs) {
5228
- const rel = p__namespace.relative(rootDir, filePath);
5229
- if (!rel.startsWith('..')) {
5230
- return rel;
5231
- }
5232
- }
5233
- return null;
5234
- }
5235
5455
 
5236
5456
  /**
5237
5457
  * This registry does nothing.
@@ -5302,9 +5522,7 @@ function compileInputTransformFields(inputs) {
5302
5522
  * marked for JIT compilation and are skipping compilation by trait handlers.
5303
5523
  */
5304
5524
  class JitDeclarationRegistry {
5305
- constructor() {
5306
- this.jitDeclarations = new Set();
5307
- }
5525
+ jitDeclarations = new Set();
5308
5526
  }
5309
5527
 
5310
5528
  /**
@@ -5314,6 +5532,21 @@ class JitDeclarationRegistry {
5314
5532
  * from the prior compilation.
5315
5533
  */
5316
5534
  class SemanticSymbol {
5535
+ decl;
5536
+ /**
5537
+ * The path of the file that declares this symbol.
5538
+ */
5539
+ path;
5540
+ /**
5541
+ * The identifier of this symbol, or null if no identifier could be determined. It should
5542
+ * uniquely identify the symbol relative to `file`. This is typically just the name of a
5543
+ * top-level class declaration, as that uniquely identifies the class within the file.
5544
+ *
5545
+ * If the identifier is null, then this symbol cannot be recognized across rebuilds. In that
5546
+ * case, the symbol is always assumed to have semantically changed to guarantee a proper
5547
+ * rebuild.
5548
+ */
5549
+ identifier;
5317
5550
  constructor(
5318
5551
  /**
5319
5552
  * The declaration for this symbol.
@@ -5352,14 +5585,12 @@ class OpaqueSymbol extends SemanticSymbol {
5352
5585
  * The semantic dependency graph of a single compilation.
5353
5586
  */
5354
5587
  class SemanticDepGraph {
5355
- constructor() {
5356
- this.files = new Map();
5357
- // Note: the explicit type annotation is used to work around a CI failure on Windows:
5358
- // error TS2742: The inferred type of 'symbolByDecl' cannot be named without a reference to
5359
- // '../../../../../../../external/npm/node_modules/typescript/lib/typescript'. This is likely
5360
- // not portable. A type annotation is necessary.
5361
- this.symbolByDecl = new Map();
5362
- }
5588
+ files = new Map();
5589
+ // Note: the explicit type annotation is used to work around a CI failure on Windows:
5590
+ // error TS2742: The inferred type of 'symbolByDecl' cannot be named without a reference to
5591
+ // '../../../../../../../external/npm/node_modules/typescript/lib/typescript'. This is likely
5592
+ // not portable. A type annotation is necessary.
5593
+ symbolByDecl = new Map();
5363
5594
  /**
5364
5595
  * Registers a symbol in the graph. The symbol is given a unique identifier if possible, such that
5365
5596
  * its equivalent symbol can be obtained from a prior graph even if its declaration node has
@@ -5426,6 +5657,13 @@ class SemanticDepGraph {
5426
5657
  * on which files have been affected.
5427
5658
  */
5428
5659
  class SemanticDepGraphUpdater {
5660
+ priorGraph;
5661
+ newGraph = new SemanticDepGraph();
5662
+ /**
5663
+ * Contains opaque symbols that were created for declarations for which there was no symbol
5664
+ * registered, which happens for e.g. external declarations.
5665
+ */
5666
+ opaqueSymbols = new Map();
5429
5667
  constructor(
5430
5668
  /**
5431
5669
  * The semantic dependency graph of the most recently succeeded compilation, or null if this
@@ -5433,12 +5671,6 @@ class SemanticDepGraphUpdater {
5433
5671
  */
5434
5672
  priorGraph) {
5435
5673
  this.priorGraph = priorGraph;
5436
- this.newGraph = new SemanticDepGraph();
5437
- /**
5438
- * Contains opaque symbols that were created for declarations for which there was no symbol
5439
- * registered, which happens for e.g. external declarations.
5440
- */
5441
- this.opaqueSymbols = new Map();
5442
5674
  }
5443
5675
  /**
5444
5676
  * Registers the symbol in the new graph that is being created.
@@ -5676,6 +5908,7 @@ function isTypeParameterEqual(a, b) {
5676
5908
  * registry and from the incremental state).
5677
5909
  */
5678
5910
  class CompoundComponentScopeReader {
5911
+ readers;
5679
5912
  constructor(readers) {
5680
5913
  this.readers = readers;
5681
5914
  }
@@ -5707,16 +5940,18 @@ class CompoundComponentScopeReader {
5707
5940
  * fields on directives, components, pipes, and NgModules.
5708
5941
  */
5709
5942
  class MetadataDtsModuleScopeResolver {
5943
+ dtsMetaReader;
5944
+ aliasingHost;
5945
+ /**
5946
+ * Cache which holds fully resolved scopes for NgModule classes from .d.ts files.
5947
+ */
5948
+ cache = new Map();
5710
5949
  /**
5711
5950
  * @param dtsMetaReader a `MetadataReader` which can read metadata from `.d.ts` files.
5712
5951
  */
5713
5952
  constructor(dtsMetaReader, aliasingHost) {
5714
5953
  this.dtsMetaReader = dtsMetaReader;
5715
5954
  this.aliasingHost = aliasingHost;
5716
- /**
5717
- * Cache which holds fully resolved scopes for NgModule classes from .d.ts files.
5718
- */
5719
- this.cache = new Map();
5720
5955
  }
5721
5956
  /**
5722
5957
  * Resolve a `Reference`'d NgModule from a .d.ts file and produce a transitive `ExportScope`
@@ -5793,7 +6028,7 @@ class MetadataDtsModuleScopeResolver {
5793
6028
  const exportScope = {
5794
6029
  exported: {
5795
6030
  dependencies,
5796
- isPoisoned: false,
6031
+ isPoisoned: meta.isPoisoned,
5797
6032
  },
5798
6033
  };
5799
6034
  this.cache.set(clazz, exportScope);
@@ -5850,6 +6085,8 @@ function makeUnknownComponentDeferredImportDiagnostic(ref, rawExpr) {
5850
6085
  return checker.makeDiagnostic(checker.ErrorCode.COMPONENT_UNKNOWN_DEFERRED_IMPORT, getDiagnosticNode(ref, rawExpr), `Component deferred imports must be standalone components, directives or pipes.`);
5851
6086
  }
5852
6087
 
6088
+ /** Value used to mark a module whose scope is in the process of being resolved. */
6089
+ const IN_PROGRESS_RESOLUTION = {};
5853
6090
  /**
5854
6091
  * A registry which collects information about NgModules, Directives, Components, and Pipes which
5855
6092
  * are local (declared in the ts.Program being compiled), and can produce `LocalModuleScope`s
@@ -5870,54 +6107,59 @@ function makeUnknownComponentDeferredImportDiagnostic(ref, rawExpr) {
5870
6107
  * semantics are violated.
5871
6108
  */
5872
6109
  class LocalModuleScopeRegistry {
6110
+ localReader;
6111
+ fullReader;
6112
+ dependencyScopeReader;
6113
+ refEmitter;
6114
+ aliasingHost;
6115
+ /**
6116
+ * Tracks whether the registry has been asked to produce scopes for a module or component. Once
6117
+ * this is true, the registry cannot accept registrations of new directives/pipes/modules as it
6118
+ * would invalidate the cached scope data.
6119
+ */
6120
+ sealed = false;
6121
+ /**
6122
+ * A map of components from the current compilation unit to the NgModule which declared them.
6123
+ *
6124
+ * As components and directives are not distinguished at the NgModule level, this map may also
6125
+ * contain directives. This doesn't cause any problems but isn't useful as there is no concept of
6126
+ * a directive's compilation scope.
6127
+ */
6128
+ declarationToModule = new Map();
6129
+ /**
6130
+ * This maps from the directive/pipe class to a map of data for each NgModule that declares the
6131
+ * directive/pipe. This data is needed to produce an error for the given class.
6132
+ */
6133
+ duplicateDeclarations = new Map();
6134
+ moduleToRef = new Map();
6135
+ /**
6136
+ * A cache of calculated `LocalModuleScope`s for each NgModule declared in the current program.
6137
+
6138
+ */
6139
+ cache = new Map();
6140
+ /**
6141
+ * Tracks the `RemoteScope` for components requiring "remote scoping".
6142
+ *
6143
+ * Remote scoping is when the set of directives which apply to a given component is set in the
6144
+ * NgModule's file instead of directly on the component def (which is sometimes needed to get
6145
+ * around cyclic import issues). This is not used in calculation of `LocalModuleScope`s, but is
6146
+ * tracked here for convenience.
6147
+ */
6148
+ remoteScoping = new Map();
6149
+ /**
6150
+ * Tracks errors accumulated in the processing of scopes for each module declaration.
6151
+ */
6152
+ scopeErrors = new Map();
6153
+ /**
6154
+ * Tracks which NgModules have directives/pipes that are declared in more than one module.
6155
+ */
6156
+ modulesWithStructuralErrors = new Set();
5873
6157
  constructor(localReader, fullReader, dependencyScopeReader, refEmitter, aliasingHost) {
5874
6158
  this.localReader = localReader;
5875
6159
  this.fullReader = fullReader;
5876
6160
  this.dependencyScopeReader = dependencyScopeReader;
5877
6161
  this.refEmitter = refEmitter;
5878
6162
  this.aliasingHost = aliasingHost;
5879
- /**
5880
- * Tracks whether the registry has been asked to produce scopes for a module or component. Once
5881
- * this is true, the registry cannot accept registrations of new directives/pipes/modules as it
5882
- * would invalidate the cached scope data.
5883
- */
5884
- this.sealed = false;
5885
- /**
5886
- * A map of components from the current compilation unit to the NgModule which declared them.
5887
- *
5888
- * As components and directives are not distinguished at the NgModule level, this map may also
5889
- * contain directives. This doesn't cause any problems but isn't useful as there is no concept of
5890
- * a directive's compilation scope.
5891
- */
5892
- this.declarationToModule = new Map();
5893
- /**
5894
- * This maps from the directive/pipe class to a map of data for each NgModule that declares the
5895
- * directive/pipe. This data is needed to produce an error for the given class.
5896
- */
5897
- this.duplicateDeclarations = new Map();
5898
- this.moduleToRef = new Map();
5899
- /**
5900
- * A cache of calculated `LocalModuleScope`s for each NgModule declared in the current program.
5901
-
5902
- */
5903
- this.cache = new Map();
5904
- /**
5905
- * Tracks the `RemoteScope` for components requiring "remote scoping".
5906
- *
5907
- * Remote scoping is when the set of directives which apply to a given component is set in the
5908
- * NgModule's file instead of directly on the component def (which is sometimes needed to get
5909
- * around cyclic import issues). This is not used in calculation of `LocalModuleScope`s, but is
5910
- * tracked here for convenience.
5911
- */
5912
- this.remoteScoping = new Map();
5913
- /**
5914
- * Tracks errors accumulated in the processing of scopes for each module declaration.
5915
- */
5916
- this.scopeErrors = new Map();
5917
- /**
5918
- * Tracks which NgModules have directives/pipes that are declared in more than one module.
5919
- */
5920
- this.modulesWithStructuralErrors = new Set();
5921
6163
  }
5922
6164
  /**
5923
6165
  * Add an NgModule's data to the registry.
@@ -6021,8 +6263,12 @@ class LocalModuleScopeRegistry {
6021
6263
  */
6022
6264
  getScopeOfModuleReference(ref) {
6023
6265
  if (this.cache.has(ref.node)) {
6024
- return this.cache.get(ref.node);
6266
+ const cachedValue = this.cache.get(ref.node);
6267
+ if (cachedValue !== IN_PROGRESS_RESOLUTION) {
6268
+ return cachedValue;
6269
+ }
6025
6270
  }
6271
+ this.cache.set(ref.node, IN_PROGRESS_RESOLUTION);
6026
6272
  // Seal the registry to protect the integrity of the `LocalModuleScope` cache.
6027
6273
  this.sealed = true;
6028
6274
  // `ref` should be an NgModule previously added to the registry. If not, a scope for it
@@ -6067,13 +6313,18 @@ class LocalModuleScopeRegistry {
6067
6313
  for (const decl of ngModule.imports) {
6068
6314
  const importScope = this.getExportedScope(decl, diagnostics, ref.node, 'import');
6069
6315
  if (importScope !== null) {
6070
- if (importScope === 'invalid' || importScope.exported.isPoisoned) {
6316
+ if (importScope === 'invalid' ||
6317
+ importScope === 'cycle' ||
6318
+ importScope.exported.isPoisoned) {
6071
6319
  // An import was an NgModule but contained errors of its own. Record this as an error too,
6072
6320
  // because this scope is always going to be incorrect if one of its imports could not be
6073
6321
  // read.
6074
- diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, 'import'));
6075
6322
  isPoisoned = true;
6076
- if (importScope === 'invalid') {
6323
+ // Prevent the module from reporting a diagnostic about itself when there's a cycle.
6324
+ if (importScope !== 'cycle') {
6325
+ diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, 'import'));
6326
+ }
6327
+ if (importScope === 'invalid' || importScope === 'cycle') {
6077
6328
  continue;
6078
6329
  }
6079
6330
  }
@@ -6159,13 +6410,18 @@ class LocalModuleScopeRegistry {
6159
6410
  for (const decl of ngModule.exports) {
6160
6411
  // Attempt to resolve decl as an NgModule.
6161
6412
  const exportScope = this.getExportedScope(decl, diagnostics, ref.node, 'export');
6162
- if (exportScope === 'invalid' || (exportScope !== null && exportScope.exported.isPoisoned)) {
6413
+ if (exportScope === 'invalid' ||
6414
+ exportScope === 'cycle' ||
6415
+ (exportScope !== null && exportScope.exported.isPoisoned)) {
6163
6416
  // An export was an NgModule but contained errors of its own. Record this as an error too,
6164
6417
  // because this scope is always going to be incorrect if one of its exports could not be
6165
6418
  // read.
6166
- diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, 'export'));
6167
6419
  isPoisoned = true;
6168
- if (exportScope === 'invalid') {
6420
+ // Prevent the module from reporting a diagnostic about itself when there's a cycle.
6421
+ if (exportScope !== 'cycle') {
6422
+ diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, 'export'));
6423
+ }
6424
+ if (exportScope === 'invalid' || exportScope === 'cycle') {
6169
6425
  continue;
6170
6426
  }
6171
6427
  }
@@ -6270,6 +6526,12 @@ class LocalModuleScopeRegistry {
6270
6526
  return this.dependencyScopeReader.resolve(ref);
6271
6527
  }
6272
6528
  else {
6529
+ if (this.cache.get(ref.node) === IN_PROGRESS_RESOLUTION) {
6530
+ diagnostics.push(checker.makeDiagnostic(type === 'import'
6531
+ ? checker.ErrorCode.NGMODULE_INVALID_IMPORT
6532
+ : checker.ErrorCode.NGMODULE_INVALID_EXPORT, checker.identifierOfNode(ref.node) || ref.node, `NgModule "${type}" field contains a cycle`));
6533
+ return 'cycle';
6534
+ }
6273
6535
  // The NgModule is declared locally in the current program. Resolve it from the registry.
6274
6536
  return this.getScopeOfModuleReference(ref);
6275
6537
  }
@@ -6423,19 +6685,22 @@ function reexportCollision(module, refA, refB) {
6423
6685
  * Computes scope information to be used in template type checking.
6424
6686
  */
6425
6687
  class TypeCheckScopeRegistry {
6688
+ scopeReader;
6689
+ metaReader;
6690
+ hostDirectivesResolver;
6691
+ /**
6692
+ * Cache of flattened directive metadata. Because flattened metadata is scope-invariant it's
6693
+ * cached individually, such that all scopes refer to the same flattened metadata.
6694
+ */
6695
+ flattenedDirectiveMetaCache = new Map();
6696
+ /**
6697
+ * Cache of the computed type check scope per NgModule declaration.
6698
+ */
6699
+ scopeCache = new Map();
6426
6700
  constructor(scopeReader, metaReader, hostDirectivesResolver) {
6427
6701
  this.scopeReader = scopeReader;
6428
6702
  this.metaReader = metaReader;
6429
6703
  this.hostDirectivesResolver = hostDirectivesResolver;
6430
- /**
6431
- * Cache of flattened directive metadata. Because flattened metadata is scope-invariant it's
6432
- * cached individually, such that all scopes refer to the same flattened metadata.
6433
- */
6434
- this.flattenedDirectiveMetaCache = new Map();
6435
- /**
6436
- * Cache of the computed type check scope per NgModule declaration.
6437
- */
6438
- this.scopeCache = new Map();
6439
6704
  }
6440
6705
  /**
6441
6706
  * Computes the type-check scope information for the component declaration. If the NgModule
@@ -6532,7 +6797,7 @@ const QUERY_TYPES = new Set(queryDecoratorNames);
6532
6797
  * appear in the declarations of an `NgModule` and additional verification is done when processing
6533
6798
  * the module.
6534
6799
  */
6535
- function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, evaluator, refEmitter, referencesRegistry, isCore, annotateForClosureCompiler, compilationMode, defaultSelector, strictStandalone) {
6800
+ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, evaluator, refEmitter, referencesRegistry, isCore, annotateForClosureCompiler, compilationMode, defaultSelector, strictStandalone, implicitStandaloneValue) {
6536
6801
  let directive;
6537
6802
  if (decorator.args === null || decorator.args.length === 0) {
6538
6803
  directive = new Map();
@@ -6636,7 +6901,7 @@ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, ev
6636
6901
  ctorDeps.some((dep) => dep.token instanceof checker.ExternalExpr &&
6637
6902
  dep.token.value.moduleName === '@angular/core' &&
6638
6903
  dep.token.value.name === 'TemplateRef');
6639
- let isStandalone = false;
6904
+ let isStandalone = implicitStandaloneValue;
6640
6905
  if (directive.has('standalone')) {
6641
6906
  const expr = directive.get('standalone');
6642
6907
  const resolved = evaluator.evaluate(expr);
@@ -7513,6 +7778,13 @@ function toR3InputMetadata(mapping) {
7513
7778
  * from this symbol.
7514
7779
  */
7515
7780
  class DirectiveSymbol extends SemanticSymbol {
7781
+ selector;
7782
+ inputs;
7783
+ outputs;
7784
+ exportAs;
7785
+ typeCheckMeta;
7786
+ typeParameters;
7787
+ baseClass = null;
7516
7788
  constructor(decl, selector, inputs, outputs, exportAs, typeCheckMeta, typeParameters) {
7517
7789
  super(decl);
7518
7790
  this.selector = selector;
@@ -7521,7 +7793,6 @@ class DirectiveSymbol extends SemanticSymbol {
7521
7793
  this.exportAs = exportAs;
7522
7794
  this.typeCheckMeta = typeCheckMeta;
7523
7795
  this.typeParameters = typeParameters;
7524
- this.baseClass = null;
7525
7796
  }
7526
7797
  isPublicApiAffected(previousSymbol) {
7527
7798
  // Note: since components and directives have exactly the same items contributing to their
@@ -7640,7 +7911,26 @@ const LIFECYCLE_HOOKS = new Set([
7640
7911
  'ngAfterContentChecked',
7641
7912
  ]);
7642
7913
  class DirectiveDecoratorHandler {
7643
- constructor(reflector, evaluator, metaRegistry, scopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, annotateForClosureCompiler, perf, importTracker, includeClassMetadata, compilationMode, jitDeclarationRegistry, strictStandalone) {
7914
+ reflector;
7915
+ evaluator;
7916
+ metaRegistry;
7917
+ scopeRegistry;
7918
+ metaReader;
7919
+ injectableRegistry;
7920
+ refEmitter;
7921
+ referencesRegistry;
7922
+ isCore;
7923
+ strictCtorDeps;
7924
+ semanticDepGraphUpdater;
7925
+ annotateForClosureCompiler;
7926
+ perf;
7927
+ importTracker;
7928
+ includeClassMetadata;
7929
+ compilationMode;
7930
+ jitDeclarationRegistry;
7931
+ strictStandalone;
7932
+ implicitStandaloneValue;
7933
+ constructor(reflector, evaluator, metaRegistry, scopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, annotateForClosureCompiler, perf, importTracker, includeClassMetadata, compilationMode, jitDeclarationRegistry, strictStandalone, implicitStandaloneValue) {
7644
7934
  this.reflector = reflector;
7645
7935
  this.evaluator = evaluator;
7646
7936
  this.metaRegistry = metaRegistry;
@@ -7659,9 +7949,10 @@ class DirectiveDecoratorHandler {
7659
7949
  this.compilationMode = compilationMode;
7660
7950
  this.jitDeclarationRegistry = jitDeclarationRegistry;
7661
7951
  this.strictStandalone = strictStandalone;
7662
- this.precedence = checker.HandlerPrecedence.PRIMARY;
7663
- this.name = 'DirectiveDecoratorHandler';
7952
+ this.implicitStandaloneValue = implicitStandaloneValue;
7664
7953
  }
7954
+ precedence = checker.HandlerPrecedence.PRIMARY;
7955
+ name = 'DirectiveDecoratorHandler';
7665
7956
  detect(node, decorators) {
7666
7957
  // If a class is undecorated but uses Angular features, we detect it as an
7667
7958
  // abstract directive. This is an unsupported pattern as of v10, but we want
@@ -7692,7 +7983,7 @@ class DirectiveDecoratorHandler {
7692
7983
  }
7693
7984
  this.perf.eventCount(checker.PerfEvent.AnalyzeDirective);
7694
7985
  const directiveResult = extractDirectiveMetadata(node, decorator, this.reflector, this.importTracker, this.evaluator, this.refEmitter, this.referencesRegistry, this.isCore, this.annotateForClosureCompiler, this.compilationMode,
7695
- /* defaultSelector */ null, this.strictStandalone);
7986
+ /* defaultSelector */ null, this.strictStandalone, this.implicitStandaloneValue);
7696
7987
  // `extractDirectiveMetadata` returns `jitForced = true` when the `@Directive` has
7697
7988
  // set `jit: true`. In this case, compilation of the decorator is skipped. Returning
7698
7989
  // an empty object signifies that no analysis was produced.
@@ -7955,20 +8246,21 @@ function isResolvedModuleWithProviders(sv) {
7955
8246
  * Represents an Angular NgModule.
7956
8247
  */
7957
8248
  class NgModuleSymbol extends SemanticSymbol {
8249
+ hasProviders;
8250
+ remotelyScopedComponents = [];
8251
+ /**
8252
+ * `SemanticSymbol`s of the transitive imports of this NgModule which came from imported
8253
+ * standalone components.
8254
+ *
8255
+ * Standalone components are excluded/included in the `InjectorDef` emit output of the NgModule
8256
+ * based on whether the compiler can prove that their transitive imports may contain exported
8257
+ * providers, so a change in this set of symbols may affect the compilation output of this
8258
+ * NgModule.
8259
+ */
8260
+ transitiveImportsFromStandaloneComponents = new Set();
7958
8261
  constructor(decl, hasProviders) {
7959
8262
  super(decl);
7960
8263
  this.hasProviders = hasProviders;
7961
- this.remotelyScopedComponents = [];
7962
- /**
7963
- * `SemanticSymbol`s of the transitive imports of this NgModule which came from imported
7964
- * standalone components.
7965
- *
7966
- * Standalone components are excluded/included in the `InjectorDef` emit output of the NgModule
7967
- * based on whether the compiler can prove that their transitive imports may contain exported
7968
- * providers, so a change in this set of symbols may affect the compilation output of this
7969
- * NgModule.
7970
- */
7971
- this.transitiveImportsFromStandaloneComponents = new Set();
7972
8264
  }
7973
8265
  isPublicApiAffected(previousSymbol) {
7974
8266
  if (!(previousSymbol instanceof NgModuleSymbol)) {
@@ -8043,6 +8335,25 @@ class NgModuleSymbol extends SemanticSymbol {
8043
8335
  * Compiles @NgModule annotations to ngModuleDef fields.
8044
8336
  */
8045
8337
  class NgModuleDecoratorHandler {
8338
+ reflector;
8339
+ evaluator;
8340
+ metaReader;
8341
+ metaRegistry;
8342
+ scopeRegistry;
8343
+ referencesRegistry;
8344
+ exportedProviderStatusResolver;
8345
+ semanticDepGraphUpdater;
8346
+ isCore;
8347
+ refEmitter;
8348
+ annotateForClosureCompiler;
8349
+ onlyPublishPublicTypings;
8350
+ injectableRegistry;
8351
+ perf;
8352
+ includeClassMetadata;
8353
+ includeSelectorScope;
8354
+ compilationMode;
8355
+ localCompilationExtraImportsTracker;
8356
+ jitDeclarationRegistry;
8046
8357
  constructor(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, exportedProviderStatusResolver, semanticDepGraphUpdater, isCore, refEmitter, annotateForClosureCompiler, onlyPublishPublicTypings, injectableRegistry, perf, includeClassMetadata, includeSelectorScope, compilationMode, localCompilationExtraImportsTracker, jitDeclarationRegistry) {
8047
8358
  this.reflector = reflector;
8048
8359
  this.evaluator = evaluator;
@@ -8063,9 +8374,9 @@ class NgModuleDecoratorHandler {
8063
8374
  this.compilationMode = compilationMode;
8064
8375
  this.localCompilationExtraImportsTracker = localCompilationExtraImportsTracker;
8065
8376
  this.jitDeclarationRegistry = jitDeclarationRegistry;
8066
- this.precedence = checker.HandlerPrecedence.PRIMARY;
8067
- this.name = 'NgModuleDecoratorHandler';
8068
8377
  }
8378
+ precedence = checker.HandlerPrecedence.PRIMARY;
8379
+ name = 'NgModuleDecoratorHandler';
8069
8380
  detect(node, decorators) {
8070
8381
  if (!decorators) {
8071
8382
  return undefined;
@@ -8388,6 +8699,7 @@ class NgModuleDecoratorHandler {
8388
8699
  rawExports: analysis.rawExports,
8389
8700
  decorator: analysis.decorator,
8390
8701
  mayDeclareProviders: analysis.providers !== null,
8702
+ isPoisoned: false,
8391
8703
  });
8392
8704
  this.injectableRegistry.registerInjectable(node, {
8393
8705
  ctorDeps: analysis.fac.deps,
@@ -9166,12 +9478,9 @@ function _extractTemplateStyleUrls(template) {
9166
9478
  * Represents an Angular component.
9167
9479
  */
9168
9480
  class ComponentSymbol extends DirectiveSymbol {
9169
- constructor() {
9170
- super(...arguments);
9171
- this.usedDirectives = [];
9172
- this.usedPipes = [];
9173
- this.isRemotelyScoped = false;
9174
- }
9481
+ usedDirectives = [];
9482
+ usedPipes = [];
9483
+ isRemotelyScoped = false;
9175
9484
  isEmitAffected(previousSymbol, publicApiAffected) {
9176
9485
  if (!(previousSymbol instanceof ComponentSymbol)) {
9177
9486
  return true;
@@ -9346,39 +9655,47 @@ function makeShimFileName(fileName, suffix) {
9346
9655
  * (which already may contain shim files and thus have a different creation flow).
9347
9656
  */
9348
9657
  class ShimAdapter {
9658
+ delegate;
9659
+ /**
9660
+ * A map of shim file names to the `ts.SourceFile` generated for those shims.
9661
+ */
9662
+ shims = new Map();
9663
+ /**
9664
+ * A map of shim file names to existing shims which were part of a previous iteration of this
9665
+ * program.
9666
+ *
9667
+ * Not all of these shims will be inherited into this program.
9668
+ */
9669
+ priorShims = new Map();
9670
+ /**
9671
+ * File names which are already known to not be shims.
9672
+ *
9673
+ * This allows for short-circuit returns without the expense of running regular expressions
9674
+ * against the filename repeatedly.
9675
+ */
9676
+ notShims = new Set();
9677
+ /**
9678
+ * The shim generators supported by this adapter as well as extra precalculated data facilitating
9679
+ * their use.
9680
+ */
9681
+ generators = [];
9682
+ /**
9683
+ * A `Set` of shim `ts.SourceFile`s which should not be emitted.
9684
+ */
9685
+ ignoreForEmit = new Set();
9686
+ /**
9687
+ * A list of extra filenames which should be considered inputs to program creation.
9688
+ *
9689
+ * This includes any top-level shims generated for the program, as well as per-file shim names for
9690
+ * those files which are included in the root files of the program.
9691
+ */
9692
+ extraInputFiles;
9693
+ /**
9694
+ * Extension prefixes of all installed per-file shims.
9695
+ */
9696
+ extensionPrefixes = [];
9349
9697
  constructor(delegate, tsRootFiles, topLevelGenerators, perFileGenerators, oldProgram) {
9350
9698
  this.delegate = delegate;
9351
- /**
9352
- * A map of shim file names to the `ts.SourceFile` generated for those shims.
9353
- */
9354
- this.shims = new Map();
9355
- /**
9356
- * A map of shim file names to existing shims which were part of a previous iteration of this
9357
- * program.
9358
- *
9359
- * Not all of these shims will be inherited into this program.
9360
- */
9361
- this.priorShims = new Map();
9362
- /**
9363
- * File names which are already known to not be shims.
9364
- *
9365
- * This allows for short-circuit returns without the expense of running regular expressions
9366
- * against the filename repeatedly.
9367
- */
9368
- this.notShims = new Set();
9369
- /**
9370
- * The shim generators supported by this adapter as well as extra precalculated data facilitating
9371
- * their use.
9372
- */
9373
- this.generators = [];
9374
- /**
9375
- * A `Set` of shim `ts.SourceFile`s which should not be emitted.
9376
- */
9377
- this.ignoreForEmit = new Set();
9378
- /**
9379
- * Extension prefixes of all installed per-file shims.
9380
- */
9381
- this.extensionPrefixes = [];
9382
9699
  // Initialize `this.generators` with a regex that matches each generator's paths.
9383
9700
  for (const gen of perFileGenerators) {
9384
9701
  // This regex matches paths for shims from this generator. The first (and only) capture group
@@ -9516,17 +9833,18 @@ class ShimAdapter {
9516
9833
  * `ShimReferenceTagger`s are intended to operate during program creation only.
9517
9834
  */
9518
9835
  class ShimReferenceTagger {
9836
+ suffixes;
9837
+ /**
9838
+ * Tracks which original files have been processed and had shims generated if necessary.
9839
+ *
9840
+ * This is used to avoid generating shims twice for the same file.
9841
+ */
9842
+ tagged = new Set();
9843
+ /**
9844
+ * Whether shim tagging is currently being performed.
9845
+ */
9846
+ enabled = true;
9519
9847
  constructor(shimExtensions) {
9520
- /**
9521
- * Tracks which original files have been processed and had shims generated if necessary.
9522
- *
9523
- * This is used to avoid generating shims twice for the same file.
9524
- */
9525
- this.tagged = new Set();
9526
- /**
9527
- * Whether shim tagging is currently being performed.
9528
- */
9529
- this.enabled = true;
9530
9848
  this.suffixes = shimExtensions.map((extension) => `.${extension}.ts`);
9531
9849
  }
9532
9850
  /**
@@ -9576,6 +9894,30 @@ class ShimReferenceTagger {
9576
9894
  * generated for this class.
9577
9895
  */
9578
9896
  class DelegatingCompilerHost$1 {
9897
+ delegate;
9898
+ createHash;
9899
+ directoryExists;
9900
+ getCancellationToken;
9901
+ getCanonicalFileName;
9902
+ getCurrentDirectory;
9903
+ getDefaultLibFileName;
9904
+ getDefaultLibLocation;
9905
+ getDirectories;
9906
+ getEnvironmentVariable;
9907
+ getNewLine;
9908
+ getParsedCommandLine;
9909
+ getSourceFileByPath;
9910
+ readDirectory;
9911
+ readFile;
9912
+ realpath;
9913
+ resolveModuleNames;
9914
+ resolveTypeReferenceDirectives;
9915
+ trace;
9916
+ useCaseSensitiveFileNames;
9917
+ getModuleResolutionCache;
9918
+ hasInvalidatedResolutions;
9919
+ resolveModuleNameLiterals;
9920
+ resolveTypeReferenceDirectiveReferences;
9579
9921
  // jsDocParsingMode is not a method like the other elements above
9580
9922
  // TODO: ignore usage can be dropped once 5.2 support is dropped
9581
9923
  get jsDocParsingMode() {
@@ -9624,6 +9966,23 @@ class DelegatingCompilerHost$1 {
9624
9966
  * A `ts.CompilerHost` which augments source files.
9625
9967
  */
9626
9968
  class UpdatedProgramHost extends DelegatingCompilerHost$1 {
9969
+ originalProgram;
9970
+ shimExtensionPrefixes;
9971
+ /**
9972
+ * Map of source file names to `ts.SourceFile` instances.
9973
+ */
9974
+ sfMap;
9975
+ /**
9976
+ * The `ShimReferenceTagger` responsible for tagging `ts.SourceFile`s loaded via this host.
9977
+ *
9978
+ * The `UpdatedProgramHost` is used in the creation of a new `ts.Program`. Even though this new
9979
+ * program is based on a prior one, TypeScript will still start from the root files and enumerate
9980
+ * all source files to include in the new program. This means that just like during the original
9981
+ * program's creation, these source files must be tagged with references to per-file shims in
9982
+ * order for those shims to be loaded, and then cleaned up afterwards. Thus the
9983
+ * `UpdatedProgramHost` has its own `ShimReferenceTagger` to perform this function.
9984
+ */
9985
+ shimTagger;
9627
9986
  constructor(sfMap, originalProgram, delegate, shimExtensionPrefixes) {
9628
9987
  super(delegate);
9629
9988
  this.originalProgram = originalProgram;
@@ -9673,21 +10032,26 @@ class UpdatedProgramHost extends DelegatingCompilerHost$1 {
9673
10032
  * TypeScript compiler APIs for incremental program creation.
9674
10033
  */
9675
10034
  class TsCreateProgramDriver {
10035
+ originalProgram;
10036
+ originalHost;
10037
+ options;
10038
+ shimExtensionPrefixes;
10039
+ /**
10040
+ * A map of source file paths to replacement `ts.SourceFile`s for those paths.
10041
+ *
10042
+ * Effectively, this tracks the delta between the user's program (represented by the
10043
+ * `originalHost`) and the template type-checking program being managed.
10044
+ */
10045
+ sfMap = new Map();
10046
+ program;
9676
10047
  constructor(originalProgram, originalHost, options, shimExtensionPrefixes) {
9677
10048
  this.originalProgram = originalProgram;
9678
10049
  this.originalHost = originalHost;
9679
10050
  this.options = options;
9680
10051
  this.shimExtensionPrefixes = shimExtensionPrefixes;
9681
- /**
9682
- * A map of source file paths to replacement `ts.SourceFile`s for those paths.
9683
- *
9684
- * Effectively, this tracks the delta between the user's program (represented by the
9685
- * `originalHost`) and the template type-checking program being managed.
9686
- */
9687
- this.sfMap = new Map();
9688
- this.supportsInlineOperations = true;
9689
10052
  this.program = this.originalProgram;
9690
10053
  }
10054
+ supportsInlineOperations = true;
9691
10055
  getProgram() {
9692
10056
  return this.program;
9693
10057
  }
@@ -9730,6 +10094,275 @@ class TsCreateProgramDriver {
9730
10094
  }
9731
10095
  }
9732
10096
 
10097
+ /*!
10098
+ * @license
10099
+ * Copyright Google LLC All Rights Reserved.
10100
+ *
10101
+ * Use of this source code is governed by an MIT-style license that can be
10102
+ * found in the LICENSE file at https://angular.dev/license
10103
+ */
10104
+ /**
10105
+ * Determines the names of the file-level locals that the HMR
10106
+ * initializer needs to capture and pass along.
10107
+ * @param sourceFile File in which the file is being compiled.
10108
+ * @param definition Compiled component definition.
10109
+ * @param factory Compiled component factory.
10110
+ * @param classMetadata Compiled `setClassMetadata` expression, if any.
10111
+ * @param debugInfo Compiled `setClassDebugInfo` expression, if any.
10112
+ */
10113
+ function extractHmrLocals(node, definition, factory, classMetadata, debugInfo) {
10114
+ const name = ts__default["default"].isClassDeclaration(node) && node.name ? node.name.text : null;
10115
+ const visitor = new PotentialTopLevelReadsVisitor();
10116
+ const sourceFile = node.getSourceFile();
10117
+ // Visit all of the compiled expression to look for potential
10118
+ // local references that would have to be retained.
10119
+ definition.expression.visitExpression(visitor, null);
10120
+ definition.statements.forEach((statement) => statement.visitStatement(visitor, null));
10121
+ factory.initializer?.visitExpression(visitor, null);
10122
+ factory.statements.forEach((statement) => statement.visitStatement(visitor, null));
10123
+ classMetadata?.visitStatement(visitor, null);
10124
+ debugInfo?.visitStatement(visitor, null);
10125
+ // Filter out only the references to defined top-level symbols. This allows us to ignore local
10126
+ // variables inside of functions. Note that we filter out the class name since it is always
10127
+ // defined and it saves us having to repeat this logic wherever the locals are consumed.
10128
+ const availableTopLevel = getTopLevelDeclarationNames(sourceFile);
10129
+ return Array.from(visitor.allReads).filter((r) => r !== name && availableTopLevel.has(r));
10130
+ }
10131
+ /**
10132
+ * Gets the names of all top-level declarations within the file (imports, declared classes etc).
10133
+ * @param sourceFile File in which to search for locals.
10134
+ */
10135
+ function getTopLevelDeclarationNames(sourceFile) {
10136
+ const results = new Set();
10137
+ // Only look through the top-level statements.
10138
+ for (const node of sourceFile.statements) {
10139
+ // Class, function and const enum declarations need to be captured since they correspond
10140
+ // to runtime code. Intentionally excludes interfaces and type declarations.
10141
+ if (ts__default["default"].isClassDeclaration(node) ||
10142
+ ts__default["default"].isFunctionDeclaration(node) ||
10143
+ (ts__default["default"].isEnumDeclaration(node) &&
10144
+ !node.modifiers?.some((m) => m.kind === ts__default["default"].SyntaxKind.ConstKeyword))) {
10145
+ if (node.name) {
10146
+ results.add(node.name.text);
10147
+ }
10148
+ continue;
10149
+ }
10150
+ // Variable declarations.
10151
+ if (ts__default["default"].isVariableStatement(node)) {
10152
+ for (const decl of node.declarationList.declarations) {
10153
+ trackBindingName(decl.name, results);
10154
+ }
10155
+ continue;
10156
+ }
10157
+ // Import declarations.
10158
+ if (ts__default["default"].isImportDeclaration(node) && node.importClause) {
10159
+ const importClause = node.importClause;
10160
+ // Skip over type-only imports since they won't be emitted to JS.
10161
+ if (importClause.isTypeOnly) {
10162
+ continue;
10163
+ }
10164
+ // import foo from 'foo'
10165
+ if (importClause.name) {
10166
+ results.add(importClause.name.text);
10167
+ }
10168
+ if (importClause.namedBindings) {
10169
+ const namedBindings = importClause.namedBindings;
10170
+ if (ts__default["default"].isNamespaceImport(namedBindings)) {
10171
+ // import * as foo from 'foo';
10172
+ results.add(namedBindings.name.text);
10173
+ }
10174
+ else {
10175
+ // import {foo} from 'foo';
10176
+ namedBindings.elements.forEach((el) => {
10177
+ if (!el.isTypeOnly) {
10178
+ results.add(el.name.text);
10179
+ }
10180
+ });
10181
+ }
10182
+ }
10183
+ continue;
10184
+ }
10185
+ }
10186
+ return results;
10187
+ }
10188
+ /**
10189
+ * Adds all the variables declared through a `ts.BindingName` to a set of results.
10190
+ * @param node Node from which to start searching for variables.
10191
+ * @param results Set to which to add the matches.
10192
+ */
10193
+ function trackBindingName(node, results) {
10194
+ if (ts__default["default"].isIdentifier(node)) {
10195
+ results.add(node.text);
10196
+ }
10197
+ else {
10198
+ for (const el of node.elements) {
10199
+ if (!ts__default["default"].isOmittedExpression(el)) {
10200
+ trackBindingName(el.name, results);
10201
+ }
10202
+ }
10203
+ }
10204
+ }
10205
+ /**
10206
+ * Visitor that will traverse an AST looking for potential top-level variable reads.
10207
+ * The reads are "potential", because the visitor doesn't account for local variables
10208
+ * inside functions.
10209
+ */
10210
+ class PotentialTopLevelReadsVisitor extends checker.RecursiveAstVisitor {
10211
+ allReads = new Set();
10212
+ visitReadVarExpr(ast, context) {
10213
+ this.allReads.add(ast.name);
10214
+ super.visitReadVarExpr(ast, context);
10215
+ }
10216
+ visitWrappedNodeExpr(ast, context) {
10217
+ if (this.isTypeScriptNode(ast.node)) {
10218
+ this.addAllTopLevelIdentifiers(ast.node);
10219
+ }
10220
+ super.visitWrappedNodeExpr(ast, context);
10221
+ }
10222
+ /**
10223
+ * Traverses a TypeScript AST and tracks all the top-level reads.
10224
+ * @param node Node from which to start the traversal.
10225
+ */
10226
+ addAllTopLevelIdentifiers = (node) => {
10227
+ if (ts__default["default"].isIdentifier(node) && this.isTopLevelIdentifierReference(node)) {
10228
+ this.allReads.add(node.text);
10229
+ }
10230
+ else {
10231
+ ts__default["default"].forEachChild(node, this.addAllTopLevelIdentifiers);
10232
+ }
10233
+ };
10234
+ /**
10235
+ * TypeScript identifiers are used both when referring to a variable (e.g. `console.log(foo)`)
10236
+ * and for names (e.g. `{foo: 123}`). This function determines if the identifier is a top-level
10237
+ * variable read, rather than a nested name.
10238
+ * @param node Identifier to check.
10239
+ */
10240
+ isTopLevelIdentifierReference(node) {
10241
+ const parent = node.parent;
10242
+ // The parent might be undefined for a synthetic node or if `setParentNodes` is set to false
10243
+ // when the SourceFile was created. We can account for such cases using the type checker, at
10244
+ // the expense of performance. At the moment of writing, we're keeping it simple since the
10245
+ // compiler sets `setParentNodes: true`.
10246
+ if (!parent) {
10247
+ return false;
10248
+ }
10249
+ // Identifier referenced at the top level. Unlikely.
10250
+ if (ts__default["default"].isSourceFile(parent) ||
10251
+ (ts__default["default"].isExpressionStatement(parent) && parent.expression === node)) {
10252
+ return true;
10253
+ }
10254
+ // Identifier used inside a call is only top-level if it's an argument.
10255
+ // This also covers decorators since their expression is usually a call.
10256
+ if (ts__default["default"].isCallExpression(parent)) {
10257
+ return parent.expression === node || parent.arguments.includes(node);
10258
+ }
10259
+ // Identifier used in a property read is only top-level if it's the expression.
10260
+ if (ts__default["default"].isPropertyAccessExpression(parent)) {
10261
+ return parent.expression === node;
10262
+ }
10263
+ // Identifier used in an array is only top-level if it's one of the elements.
10264
+ if (ts__default["default"].isArrayLiteralExpression(parent)) {
10265
+ return parent.elements.includes(node);
10266
+ }
10267
+ // Identifier in a property assignment is only top level if it's the initializer.
10268
+ if (ts__default["default"].isPropertyAssignment(parent)) {
10269
+ return parent.initializer === node;
10270
+ }
10271
+ // Identifier in a class is only top level if it's the name.
10272
+ if (ts__default["default"].isClassDeclaration(parent)) {
10273
+ return parent.name === node;
10274
+ }
10275
+ // Otherwise it's not top-level.
10276
+ return false;
10277
+ }
10278
+ /** Checks if a value is a TypeScript AST node. */
10279
+ isTypeScriptNode(value) {
10280
+ // If this is too permissive, we can also check for `getSourceFile`. This code runs
10281
+ // on a narrow set of use cases so checking for `kind` should be enough.
10282
+ return !!value && typeof value.kind === 'number';
10283
+ }
10284
+ }
10285
+
10286
+ /*!
10287
+ * @license
10288
+ * Copyright Google LLC All Rights Reserved.
10289
+ *
10290
+ * Use of this source code is governed by an MIT-style license that can be
10291
+ * found in the LICENSE file at https://angular.dev/license
10292
+ */
10293
+ /**
10294
+ * Extracts the HMR metadata for a class declaration.
10295
+ * @param clazz Class being analyzed.
10296
+ * @param reflection Reflection host.
10297
+ * @param compilerHost Compiler host to use when resolving file names.
10298
+ * @param rootDirs Root directories configured by the user.
10299
+ * @param definition Analyzed component definition.
10300
+ * @param factory Analyzed component factory.
10301
+ * @param classMetadata Analyzed `setClassMetadata` expression, if any.
10302
+ * @param debugInfo Analyzed `setClassDebugInfo` expression, if any.
10303
+ */
10304
+ function extractHmrMetatadata(clazz, reflection, compilerHost, rootDirs, definition, factory, classMetadata, debugInfo) {
10305
+ if (!reflection.isClass(clazz)) {
10306
+ return null;
10307
+ }
10308
+ const sourceFile = clazz.getSourceFile();
10309
+ const filePath = getProjectRelativePath(sourceFile, rootDirs, compilerHost) ||
10310
+ compilerHost.getCanonicalFileName(sourceFile.fileName);
10311
+ const meta = {
10312
+ type: new checker.WrappedNodeExpr(clazz.name),
10313
+ className: clazz.name.text,
10314
+ filePath,
10315
+ locals: extractHmrLocals(clazz, definition, factory, classMetadata, debugInfo),
10316
+ coreName: '__ngCore__',
10317
+ };
10318
+ return meta;
10319
+ }
10320
+
10321
+ /*!
10322
+ * @license
10323
+ * Copyright Google LLC All Rights Reserved.
10324
+ *
10325
+ * Use of this source code is governed by an MIT-style license that can be
10326
+ * found in the LICENSE file at https://angular.dev/license
10327
+ */
10328
+ /**
10329
+ * Gets the declaration for the function that replaces the metadata of a class during HMR.
10330
+ * @param compilationResults Code generated for the class during compilation.
10331
+ * @param meta HMR metadata about the class.
10332
+ * @param sourceFile File in which the class is defined.
10333
+ */
10334
+ function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, sourceFile) {
10335
+ const importRewriter = new HmrModuleImportRewriter(meta.coreName);
10336
+ const importManager = new checker.ImportManager({
10337
+ ...checker.presetImportManagerForceNamespaceImports,
10338
+ rewriter: importRewriter,
10339
+ });
10340
+ const callback = compileHmrUpdateCallback(compilationResults, constantStatements, meta);
10341
+ const node = checker.translateStatement(sourceFile, callback, importManager);
10342
+ // The output AST doesn't support modifiers so we have to emit to
10343
+ // TS and then update the declaration to add `export default`.
10344
+ return ts__default["default"].factory.updateFunctionDeclaration(node, [
10345
+ ts__default["default"].factory.createToken(ts__default["default"].SyntaxKind.ExportKeyword),
10346
+ ts__default["default"].factory.createToken(ts__default["default"].SyntaxKind.DefaultKeyword),
10347
+ ], node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
10348
+ }
10349
+ /** Rewriter that replaces namespace imports to `@angular/core` with a specifier identifier. */
10350
+ class HmrModuleImportRewriter {
10351
+ coreName;
10352
+ constructor(coreName) {
10353
+ this.coreName = coreName;
10354
+ }
10355
+ rewriteNamespaceImportIdentifier(specifier, moduleName) {
10356
+ return moduleName === '@angular/core' ? this.coreName : specifier;
10357
+ }
10358
+ rewriteSymbol(symbol) {
10359
+ return symbol;
10360
+ }
10361
+ rewriteSpecifier(specifier) {
10362
+ return specifier;
10363
+ }
10364
+ }
10365
+
9733
10366
  const EMPTY_ARRAY = [];
9734
10367
  const isUsedDirective = (decl) => decl.kind === checker.R3TemplateDependencyKind.Directive;
9735
10368
  const isUsedPipe = (decl) => decl.kind === checker.R3TemplateDependencyKind.Pipe;
@@ -9737,13 +10370,56 @@ const isUsedPipe = (decl) => decl.kind === checker.R3TemplateDependencyKind.Pipe
9737
10370
  * `DecoratorHandler` which handles the `@Component` annotation.
9738
10371
  */
9739
10372
  class ComponentDecoratorHandler {
9740
- constructor(reflector, evaluator, metaRegistry, metaReader, scopeReader, dtsScopeReader, scopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, strictCtorDeps, resourceLoader, rootDirs, defaultPreserveWhitespaces, i18nUseExternalIds, enableI18nLegacyMessageIdFormat, usePoisonedData, i18nNormalizeLineEndingsInICUs, moduleResolver, cycleAnalyzer, cycleHandlingStrategy, refEmitter, referencesRegistry, depTracker, injectableRegistry, semanticDepGraphUpdater, annotateForClosureCompiler, perf, hostDirectivesResolver, importTracker, includeClassMetadata, compilationMode, deferredSymbolTracker, forbidOrphanRendering, enableBlockSyntax, enableLetSyntax, externalRuntimeStyles, localCompilationExtraImportsTracker, jitDeclarationRegistry, i18nPreserveSignificantWhitespace, strictStandalone) {
10373
+ reflector;
10374
+ evaluator;
10375
+ metaRegistry;
10376
+ metaReader;
10377
+ scopeReader;
10378
+ compilerHost;
10379
+ scopeRegistry;
10380
+ typeCheckScopeRegistry;
10381
+ resourceRegistry;
10382
+ isCore;
10383
+ strictCtorDeps;
10384
+ resourceLoader;
10385
+ rootDirs;
10386
+ defaultPreserveWhitespaces;
10387
+ i18nUseExternalIds;
10388
+ enableI18nLegacyMessageIdFormat;
10389
+ usePoisonedData;
10390
+ i18nNormalizeLineEndingsInICUs;
10391
+ moduleResolver;
10392
+ cycleAnalyzer;
10393
+ cycleHandlingStrategy;
10394
+ refEmitter;
10395
+ referencesRegistry;
10396
+ depTracker;
10397
+ injectableRegistry;
10398
+ semanticDepGraphUpdater;
10399
+ annotateForClosureCompiler;
10400
+ perf;
10401
+ hostDirectivesResolver;
10402
+ importTracker;
10403
+ includeClassMetadata;
10404
+ compilationMode;
10405
+ deferredSymbolTracker;
10406
+ forbidOrphanRendering;
10407
+ enableBlockSyntax;
10408
+ enableLetSyntax;
10409
+ externalRuntimeStyles;
10410
+ localCompilationExtraImportsTracker;
10411
+ jitDeclarationRegistry;
10412
+ i18nPreserveSignificantWhitespace;
10413
+ strictStandalone;
10414
+ enableHmr;
10415
+ implicitStandaloneValue;
10416
+ constructor(reflector, evaluator, metaRegistry, metaReader, scopeReader, compilerHost, scopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, strictCtorDeps, resourceLoader, rootDirs, defaultPreserveWhitespaces, i18nUseExternalIds, enableI18nLegacyMessageIdFormat, usePoisonedData, i18nNormalizeLineEndingsInICUs, moduleResolver, cycleAnalyzer, cycleHandlingStrategy, refEmitter, referencesRegistry, depTracker, injectableRegistry, semanticDepGraphUpdater, annotateForClosureCompiler, perf, hostDirectivesResolver, importTracker, includeClassMetadata, compilationMode, deferredSymbolTracker, forbidOrphanRendering, enableBlockSyntax, enableLetSyntax, externalRuntimeStyles, localCompilationExtraImportsTracker, jitDeclarationRegistry, i18nPreserveSignificantWhitespace, strictStandalone, enableHmr, implicitStandaloneValue) {
9741
10417
  this.reflector = reflector;
9742
10418
  this.evaluator = evaluator;
9743
10419
  this.metaRegistry = metaRegistry;
9744
10420
  this.metaReader = metaReader;
9745
10421
  this.scopeReader = scopeReader;
9746
- this.dtsScopeReader = dtsScopeReader;
10422
+ this.compilerHost = compilerHost;
9747
10423
  this.scopeRegistry = scopeRegistry;
9748
10424
  this.typeCheckScopeRegistry = typeCheckScopeRegistry;
9749
10425
  this.resourceRegistry = resourceRegistry;
@@ -9779,17 +10455,8 @@ class ComponentDecoratorHandler {
9779
10455
  this.jitDeclarationRegistry = jitDeclarationRegistry;
9780
10456
  this.i18nPreserveSignificantWhitespace = i18nPreserveSignificantWhitespace;
9781
10457
  this.strictStandalone = strictStandalone;
9782
- this.literalCache = new Map();
9783
- this.elementSchemaRegistry = new checker.DomElementSchemaRegistry();
9784
- /**
9785
- * During the asynchronous preanalyze phase, it's necessary to parse the template to extract
9786
- * any potential <link> tags which might need to be loaded. This cache ensures that work is not
9787
- * thrown away, and the parsed template is reused during the analyze phase.
9788
- */
9789
- this.preanalyzeTemplateCache = new Map();
9790
- this.preanalyzeStylesCache = new Map();
9791
- this.precedence = checker.HandlerPrecedence.PRIMARY;
9792
- this.name = 'ComponentDecoratorHandler';
10458
+ this.enableHmr = enableHmr;
10459
+ this.implicitStandaloneValue = implicitStandaloneValue;
9793
10460
  this.extractTemplateOptions = {
9794
10461
  enableI18nLegacyMessageIdFormat: this.enableI18nLegacyMessageIdFormat,
9795
10462
  i18nNormalizeLineEndingsInICUs: this.i18nNormalizeLineEndingsInICUs,
@@ -9798,7 +10465,25 @@ class ComponentDecoratorHandler {
9798
10465
  enableLetSyntax: this.enableLetSyntax,
9799
10466
  preserveSignificantWhitespace: this.i18nPreserveSignificantWhitespace,
9800
10467
  };
10468
+ // Dependencies can't be deferred during HMR, because the HMR update module can't have
10469
+ // dynamic imports and its dependencies need to be passed in directly. If dependencies
10470
+ // are deferred, their imports will be deleted so we won't may lose the reference to them.
10471
+ this.canDeferDeps = !enableHmr;
9801
10472
  }
10473
+ literalCache = new Map();
10474
+ elementSchemaRegistry = new checker.DomElementSchemaRegistry();
10475
+ /**
10476
+ * During the asynchronous preanalyze phase, it's necessary to parse the template to extract
10477
+ * any potential <link> tags which might need to be loaded. This cache ensures that work is not
10478
+ * thrown away, and the parsed template is reused during the analyze phase.
10479
+ */
10480
+ preanalyzeTemplateCache = new Map();
10481
+ preanalyzeStylesCache = new Map();
10482
+ /** Whether generated code for a component can defer its dependencies. */
10483
+ canDeferDeps;
10484
+ extractTemplateOptions;
10485
+ precedence = checker.HandlerPrecedence.PRIMARY;
10486
+ name = 'ComponentDecoratorHandler';
9802
10487
  detect(node, decorators) {
9803
10488
  if (!decorators) {
9804
10489
  return undefined;
@@ -9908,7 +10593,7 @@ class ComponentDecoratorHandler {
9908
10593
  let isPoisoned = false;
9909
10594
  // @Component inherits @Directive, so begin by extracting the @Directive metadata and building
9910
10595
  // on it.
9911
- const directiveResult = extractDirectiveMetadata(node, decorator, this.reflector, this.importTracker, this.evaluator, this.refEmitter, this.referencesRegistry, this.isCore, this.annotateForClosureCompiler, this.compilationMode, this.elementSchemaRegistry.getDefaultComponentElementName(), this.strictStandalone);
10596
+ const directiveResult = extractDirectiveMetadata(node, decorator, this.reflector, this.importTracker, this.evaluator, this.refEmitter, this.referencesRegistry, this.isCore, this.annotateForClosureCompiler, this.compilationMode, this.elementSchemaRegistry.getDefaultComponentElementName(), this.strictStandalone, this.implicitStandaloneValue);
9912
10597
  // `extractDirectiveMetadata` returns `jitForced = true` when the `@Component` has
9913
10598
  // set `jit: true`. In this case, compilation of the decorator is skipped. Returning
9914
10599
  // an empty object signifies that no analysis was produced.
@@ -10200,7 +10885,7 @@ class ComponentDecoratorHandler {
10200
10885
  classMetadata: this.includeClassMetadata
10201
10886
  ? extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler, (dec) => transformDecoratorResources(dec, component, styles, template))
10202
10887
  : null,
10203
- classDebugInfo: extractClassDebugInfo(node, this.reflector, this.rootDirs,
10888
+ classDebugInfo: extractClassDebugInfo(node, this.reflector, this.compilerHost, this.rootDirs,
10204
10889
  /* forbidOrphanRenderering */ this.forbidOrphanRendering),
10205
10890
  template,
10206
10891
  providersRequiringFactory,
@@ -10715,14 +11400,18 @@ class ComponentDecoratorHandler {
10715
11400
  if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
10716
11401
  return [];
10717
11402
  }
10718
- const perComponentDeferredDeps = this.resolveAllDeferredDependencies(resolution);
11403
+ const perComponentDeferredDeps = this.canDeferDeps
11404
+ ? this.resolveAllDeferredDependencies(resolution)
11405
+ : null;
10719
11406
  const meta = {
10720
11407
  ...analysis.meta,
10721
11408
  ...resolution,
10722
11409
  defer: this.compileDeferBlocks(resolution),
10723
11410
  };
10724
11411
  const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
10725
- removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
11412
+ if (perComponentDeferredDeps !== null) {
11413
+ removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
11414
+ }
10726
11415
  const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
10727
11416
  const inputTransformFields = compileInputTransformFields(analysis.inputs);
10728
11417
  const classMetadata = analysis.classMetadata !== null
@@ -10731,8 +11420,14 @@ class ComponentDecoratorHandler {
10731
11420
  const debugInfo = analysis.classDebugInfo !== null
10732
11421
  ? compileClassDebugInfo(analysis.classDebugInfo).toStmt()
10733
11422
  : null;
10734
- const deferrableImports = this.deferredSymbolTracker.getDeferrableImportDecls();
10735
- return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports, debugInfo);
11423
+ const hmrMeta = this.enableHmr
11424
+ ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, classMetadata, debugInfo)
11425
+ : null;
11426
+ const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
11427
+ const deferrableImports = this.canDeferDeps
11428
+ ? this.deferredSymbolTracker.getDeferrableImportDecls()
11429
+ : null;
11430
+ return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
10736
11431
  }
10737
11432
  compilePartial(node, analysis, resolution) {
10738
11433
  if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
@@ -10746,7 +11441,9 @@ class ComponentDecoratorHandler {
10746
11441
  ? new checker.WrappedNodeExpr(analysis.template.sourceMapping.node)
10747
11442
  : null,
10748
11443
  };
10749
- const perComponentDeferredDeps = this.resolveAllDeferredDependencies(resolution);
11444
+ const perComponentDeferredDeps = this.canDeferDeps
11445
+ ? this.resolveAllDeferredDependencies(resolution)
11446
+ : null;
10750
11447
  const meta = {
10751
11448
  ...analysis.meta,
10752
11449
  ...resolution,
@@ -10758,21 +11455,27 @@ class ComponentDecoratorHandler {
10758
11455
  const classMetadata = analysis.classMetadata !== null
10759
11456
  ? compileComponentDeclareClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt()
10760
11457
  : null;
10761
- const deferrableImports = this.deferredSymbolTracker.getDeferrableImportDecls();
10762
- return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports);
11458
+ const hmrMeta = this.enableHmr
11459
+ ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, classMetadata, null)
11460
+ : null;
11461
+ const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
11462
+ const deferrableImports = this.canDeferDeps
11463
+ ? this.deferredSymbolTracker.getDeferrableImportDecls()
11464
+ : null;
11465
+ return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports, null, hmrInitializer);
10763
11466
  }
10764
11467
  compileLocal(node, analysis, resolution, pool) {
10765
11468
  // In the local compilation mode we can only rely on the information available
10766
11469
  // within the `@Component.deferredImports` array, because in this mode compiler
10767
11470
  // doesn't have information on which dependencies belong to which defer blocks.
10768
- const deferrableTypes = analysis.explicitlyDeferredTypes;
11471
+ const deferrableTypes = this.canDeferDeps ? analysis.explicitlyDeferredTypes : null;
10769
11472
  const meta = {
10770
11473
  ...analysis.meta,
10771
11474
  ...resolution,
10772
11475
  defer: this.compileDeferBlocks(resolution),
10773
11476
  };
10774
- if (analysis.explicitlyDeferredTypes !== null) {
10775
- removeDeferrableTypesFromComponentDecorator(analysis, analysis.explicitlyDeferredTypes);
11477
+ if (deferrableTypes !== null) {
11478
+ removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes);
10776
11479
  }
10777
11480
  const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
10778
11481
  const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
@@ -10783,8 +11486,41 @@ class ComponentDecoratorHandler {
10783
11486
  const debugInfo = analysis.classDebugInfo !== null
10784
11487
  ? compileClassDebugInfo(analysis.classDebugInfo).toStmt()
10785
11488
  : null;
10786
- const deferrableImports = this.deferredSymbolTracker.getDeferrableImportDecls();
10787
- return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports, debugInfo);
11489
+ const hmrMeta = this.enableHmr
11490
+ ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, classMetadata, debugInfo)
11491
+ : null;
11492
+ const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
11493
+ const deferrableImports = this.canDeferDeps
11494
+ ? this.deferredSymbolTracker.getDeferrableImportDecls()
11495
+ : null;
11496
+ return checker.compileResults(fac, def, classMetadata, 'ɵcmp', inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
11497
+ }
11498
+ compileHmrUpdateDeclaration(node, analysis, resolution) {
11499
+ if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
11500
+ return null;
11501
+ }
11502
+ // Create a brand-new constant pool since there shouldn't be any constant sharing.
11503
+ const pool = new checker.ConstantPool();
11504
+ const meta = {
11505
+ ...analysis.meta,
11506
+ ...resolution,
11507
+ defer: this.compileDeferBlocks(resolution),
11508
+ };
11509
+ const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
11510
+ const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
11511
+ const classMetadata = analysis.classMetadata !== null
11512
+ ? compileComponentClassMetadata(analysis.classMetadata, null).toStmt()
11513
+ : null;
11514
+ const debugInfo = analysis.classDebugInfo !== null
11515
+ ? compileClassDebugInfo(analysis.classDebugInfo).toStmt()
11516
+ : null;
11517
+ const hmrMeta = this.enableHmr
11518
+ ? extractHmrMetatadata(node, this.reflector, this.compilerHost, this.rootDirs, def, fac, classMetadata, debugInfo)
11519
+ : null;
11520
+ const res = checker.compileResults(fac, def, classMetadata, 'ɵcmp', null, null, debugInfo, null);
11521
+ return hmrMeta === null || res.length === 0
11522
+ ? null
11523
+ : getHmrUpdateDeclaration(res, pool.statements, hmrMeta, node.getSourceFile());
10788
11524
  }
10789
11525
  /**
10790
11526
  * Locates defer blocks in case scope information is not available.
@@ -11110,6 +11846,15 @@ function isDefaultImport(node) {
11110
11846
  * Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
11111
11847
  */
11112
11848
  class InjectableDecoratorHandler {
11849
+ reflector;
11850
+ evaluator;
11851
+ isCore;
11852
+ strictCtorDeps;
11853
+ injectableRegistry;
11854
+ perf;
11855
+ includeClassMetadata;
11856
+ compilationMode;
11857
+ errorOnDuplicateProv;
11113
11858
  constructor(reflector, evaluator, isCore, strictCtorDeps, injectableRegistry, perf, includeClassMetadata, compilationMode,
11114
11859
  /**
11115
11860
  * What to do if the injectable already contains a ɵprov property.
@@ -11127,9 +11872,9 @@ class InjectableDecoratorHandler {
11127
11872
  this.includeClassMetadata = includeClassMetadata;
11128
11873
  this.compilationMode = compilationMode;
11129
11874
  this.errorOnDuplicateProv = errorOnDuplicateProv;
11130
- this.precedence = checker.HandlerPrecedence.SHARED;
11131
- this.name = 'InjectableDecoratorHandler';
11132
11875
  }
11876
+ precedence = checker.HandlerPrecedence.SHARED;
11877
+ name = 'InjectableDecoratorHandler';
11133
11878
  detect(node, decorators) {
11134
11879
  if (!decorators) {
11135
11880
  return undefined;
@@ -11397,6 +12142,7 @@ function getDep(dep, reflector) {
11397
12142
  * Represents an Angular pipe.
11398
12143
  */
11399
12144
  class PipeSymbol extends SemanticSymbol {
12145
+ name;
11400
12146
  constructor(decl, name) {
11401
12147
  super(decl);
11402
12148
  this.name = name;
@@ -11412,7 +12158,19 @@ class PipeSymbol extends SemanticSymbol {
11412
12158
  }
11413
12159
  }
11414
12160
  class PipeDecoratorHandler {
11415
- constructor(reflector, evaluator, metaRegistry, scopeRegistry, injectableRegistry, isCore, perf, includeClassMetadata, compilationMode, generateExtraImportsInLocalMode, strictStandalone) {
12161
+ reflector;
12162
+ evaluator;
12163
+ metaRegistry;
12164
+ scopeRegistry;
12165
+ injectableRegistry;
12166
+ isCore;
12167
+ perf;
12168
+ includeClassMetadata;
12169
+ compilationMode;
12170
+ generateExtraImportsInLocalMode;
12171
+ strictStandalone;
12172
+ implicitStandaloneValue;
12173
+ constructor(reflector, evaluator, metaRegistry, scopeRegistry, injectableRegistry, isCore, perf, includeClassMetadata, compilationMode, generateExtraImportsInLocalMode, strictStandalone, implicitStandaloneValue) {
11416
12174
  this.reflector = reflector;
11417
12175
  this.evaluator = evaluator;
11418
12176
  this.metaRegistry = metaRegistry;
@@ -11424,9 +12182,10 @@ class PipeDecoratorHandler {
11424
12182
  this.compilationMode = compilationMode;
11425
12183
  this.generateExtraImportsInLocalMode = generateExtraImportsInLocalMode;
11426
12184
  this.strictStandalone = strictStandalone;
11427
- this.precedence = checker.HandlerPrecedence.PRIMARY;
11428
- this.name = 'PipeDecoratorHandler';
12185
+ this.implicitStandaloneValue = implicitStandaloneValue;
11429
12186
  }
12187
+ precedence = checker.HandlerPrecedence.PRIMARY;
12188
+ name = 'PipeDecoratorHandler';
11430
12189
  detect(node, decorators) {
11431
12190
  if (!decorators) {
11432
12191
  return undefined;
@@ -11475,7 +12234,7 @@ class PipeDecoratorHandler {
11475
12234
  }
11476
12235
  pure = pureValue;
11477
12236
  }
11478
- let isStandalone = false;
12237
+ let isStandalone = this.implicitStandaloneValue;
11479
12238
  if (pipe.has('standalone')) {
11480
12239
  const expr = pipe.get('standalone');
11481
12240
  const resolved = this.evaluator.evaluate(expr);
@@ -12356,12 +13115,7 @@ function i18nSerialize(bundle, formatName, options) {
12356
13115
  let serializer;
12357
13116
  switch (format) {
12358
13117
  case 'xmb':
12359
- serializer = new checker.Xmb(
12360
- // Whenever we disable whitespace preservation, we also want to stop preserving
12361
- // placeholders because they contain whitespace we want to drop too. Whitespace
12362
- // inside `{{ name }}` should be ignored for the same reasons as whitespace
12363
- // outside placeholders.
12364
- /* preservePlaceholders */ options.i18nPreserveWhitespaceForLegacyExtraction);
13118
+ serializer = new checker.Xmb();
12365
13119
  break;
12366
13120
  case 'xliff2':
12367
13121
  case 'xlf2':
@@ -12494,15 +13248,16 @@ function verifySupportedTypeScriptVersion() {
12494
13248
  * Analyzes a `ts.Program` for cycles.
12495
13249
  */
12496
13250
  class CycleAnalyzer {
13251
+ importGraph;
13252
+ /**
13253
+ * Cycle detection is requested with the same `from` source file for all used directives and pipes
13254
+ * within a component, which makes it beneficial to cache the results as long as the `from` source
13255
+ * file has not changed. This avoids visiting the import graph that is reachable from multiple
13256
+ * directives/pipes more than once.
13257
+ */
13258
+ cachedResults = null;
12497
13259
  constructor(importGraph) {
12498
13260
  this.importGraph = importGraph;
12499
- /**
12500
- * Cycle detection is requested with the same `from` source file for all used directives and pipes
12501
- * within a component, which makes it beneficial to cache the results as long as the `from` source
12502
- * file has not changed. This avoids visiting the import graph that is reachable from multiple
12503
- * directives/pipes more than once.
12504
- */
12505
- this.cachedResults = null;
12506
13261
  }
12507
13262
  /**
12508
13263
  * Check for a cycle to be created in the `ts.Program` by adding an import between `from` and
@@ -12539,11 +13294,13 @@ const NgCyclicResult = Symbol('NgCyclicResult');
12539
13294
  * on the source file) as earlier executions.
12540
13295
  */
12541
13296
  class CycleResults {
13297
+ from;
13298
+ importGraph;
13299
+ cyclic = {};
13300
+ acyclic = {};
12542
13301
  constructor(from, importGraph) {
12543
13302
  this.from = from;
12544
13303
  this.importGraph = importGraph;
12545
- this.cyclic = {};
12546
- this.acyclic = {};
12547
13304
  }
12548
13305
  wouldBeCyclic(sf) {
12549
13306
  const cached = this.getCachedResult(sf);
@@ -12600,6 +13357,9 @@ class CycleResults {
12600
13357
  * needed.
12601
13358
  */
12602
13359
  class Cycle {
13360
+ importGraph;
13361
+ from;
13362
+ to;
12603
13363
  constructor(importGraph, from, to) {
12604
13364
  this.importGraph = importGraph;
12605
13365
  this.from = from;
@@ -12623,10 +13383,12 @@ class Cycle {
12623
13383
  * dependencies within the same program are tracked; imports into packages on NPM are not.
12624
13384
  */
12625
13385
  class ImportGraph {
13386
+ checker;
13387
+ perf;
13388
+ imports = new Map();
12626
13389
  constructor(checker, perf) {
12627
13390
  this.checker = checker;
12628
13391
  this.perf = perf;
12629
- this.imports = new Map();
12630
13392
  }
12631
13393
  /**
12632
13394
  * List the direct (not transitive) imports of a given `ts.SourceFile`.
@@ -12735,6 +13497,8 @@ function isTypeOnlyImportClause(node) {
12735
13497
  * `getPath()` above.
12736
13498
  */
12737
13499
  class Found {
13500
+ sourceFile;
13501
+ parent;
12738
13502
  constructor(sourceFile, parent) {
12739
13503
  this.sourceFile = sourceFile;
12740
13504
  this.parent = parent;
@@ -12889,6 +13653,9 @@ function extractResolvedTypeString(node, checker) {
12889
13653
  }
12890
13654
 
12891
13655
  class FunctionExtractor {
13656
+ name;
13657
+ exportDeclaration;
13658
+ typeChecker;
12892
13659
  constructor(name, exportDeclaration, typeChecker) {
12893
13660
  this.name = name;
12894
13661
  this.exportDeclaration = exportDeclaration;
@@ -13000,6 +13767,8 @@ function hasLeadingInternalComment(member) {
13000
13767
 
13001
13768
  /** Extractor to pull info for API reference documentation for a TypeScript class or interface. */
13002
13769
  class ClassExtractor {
13770
+ declaration;
13771
+ typeChecker;
13003
13772
  constructor(declaration, typeChecker) {
13004
13773
  this.declaration = declaration;
13005
13774
  this.typeChecker = typeChecker;
@@ -13162,9 +13931,22 @@ class ClassExtractor {
13162
13931
  }
13163
13932
  /** The result only contains properties, method implementations and abstracts */
13164
13933
  filterMethodOverloads(declarations) {
13165
- return declarations.filter((declaration) => {
13934
+ return declarations.filter((declaration, index) => {
13166
13935
  if (ts__default["default"].isFunctionDeclaration(declaration) || ts__default["default"].isMethodDeclaration(declaration)) {
13167
- return (!!declaration.body || ts__default["default"].getCombinedModifierFlags(declaration) & ts__default["default"].ModifierFlags.Abstract);
13936
+ if (ts__default["default"].getCombinedModifierFlags(declaration) & ts__default["default"].ModifierFlags.Abstract) {
13937
+ // TS enforces that all declarations of an abstract method are consecutive
13938
+ const previousDeclaration = declarations[index - 1];
13939
+ const samePreviousAbstractMethod = previousDeclaration &&
13940
+ ts__default["default"].isMethodDeclaration(previousDeclaration) &&
13941
+ ts__default["default"].getCombinedModifierFlags(previousDeclaration) & ts__default["default"].ModifierFlags.Abstract &&
13942
+ previousDeclaration.name.getText() === declaration.name?.getText();
13943
+ // We just need a reference to one member
13944
+ // In the case of Abstract Methods we only want to return the first abstract.
13945
+ // Others with the same name are considered as overloads
13946
+ // Later on, the function extractor will handle overloads and implementation detection
13947
+ return !samePreviousAbstractMethod;
13948
+ }
13949
+ return !!declaration.body;
13168
13950
  }
13169
13951
  return true;
13170
13952
  });
@@ -13259,6 +14041,8 @@ class ClassExtractor {
13259
14041
  }
13260
14042
  /** Extractor to pull info for API reference documentation for an Angular directive. */
13261
14043
  class DirectiveExtractor extends ClassExtractor {
14044
+ reference;
14045
+ metadata;
13262
14046
  constructor(declaration, reference, metadata, checker) {
13263
14047
  super(declaration, checker);
13264
14048
  this.reference = reference;
@@ -13303,6 +14087,8 @@ class DirectiveExtractor extends ClassExtractor {
13303
14087
  }
13304
14088
  /** Extractor to pull info for API reference documentation for an Angular pipe. */
13305
14089
  class PipeExtractor extends ClassExtractor {
14090
+ reference;
14091
+ metadata;
13306
14092
  constructor(declaration, reference, metadata, typeChecker) {
13307
14093
  super(declaration, typeChecker);
13308
14094
  this.reference = reference;
@@ -13319,6 +14105,8 @@ class PipeExtractor extends ClassExtractor {
13319
14105
  }
13320
14106
  /** Extractor to pull info for API reference documentation for an Angular pipe. */
13321
14107
  class NgModuleExtractor extends ClassExtractor {
14108
+ reference;
14109
+ metadata;
13322
14110
  constructor(declaration, reference, metadata, typeChecker) {
13323
14111
  super(declaration, typeChecker);
13324
14112
  this.reference = reference;
@@ -13770,6 +14558,8 @@ function getImportedSymbols(sourceFile) {
13770
14558
  * public API documentation.
13771
14559
  */
13772
14560
  class DocsExtractor {
14561
+ typeChecker;
14562
+ metadataReader;
13773
14563
  constructor(typeChecker, metadataReader) {
13774
14564
  this.typeChecker = typeChecker;
13775
14565
  this.metadataReader = metadataReader;
@@ -13903,10 +14693,13 @@ function getRelativeFilePath(sourceFile, rootDir) {
13903
14693
 
13904
14694
  /// <reference types="node" />
13905
14695
  class FlatIndexGenerator {
14696
+ entryPoint;
14697
+ moduleName;
14698
+ flatIndexPath;
14699
+ shouldEmit = true;
13906
14700
  constructor(entryPoint, relativeFlatIndexPath, moduleName) {
13907
14701
  this.entryPoint = entryPoint;
13908
14702
  this.moduleName = moduleName;
13909
- this.shouldEmit = true;
13910
14703
  this.flatIndexPath =
13911
14704
  checker.join(checker.dirname(entryPoint), relativeFlatIndexPath).replace(/\.js$/, '') + '.ts';
13912
14705
  }
@@ -14074,9 +14867,7 @@ function getDescriptorOfDeclaration(decl) {
14074
14867
  }
14075
14868
 
14076
14869
  class ReferenceGraph {
14077
- constructor() {
14078
- this.references = new Map();
14079
- }
14870
+ references = new Map();
14080
14871
  add(from, to) {
14081
14872
  if (!this.references.has(from)) {
14082
14873
  this.references.set(from, new Set());
@@ -14152,9 +14943,7 @@ class ReferenceGraph {
14152
14943
  * 3. One of its resource dependencies has physically changed.
14153
14944
  */
14154
14945
  class FileDependencyGraph {
14155
- constructor() {
14156
- this.nodes = new Map();
14157
- }
14946
+ nodes = new Map();
14158
14947
  addDependency(from, on) {
14159
14948
  this.nodeFor(from).dependsOn.add(checker.absoluteFromSourceFile(on));
14160
14949
  }
@@ -14272,6 +15061,17 @@ var PhaseKind;
14272
15061
  * future one.
14273
15062
  */
14274
15063
  class IncrementalCompilation {
15064
+ depGraph;
15065
+ versions;
15066
+ step;
15067
+ phase;
15068
+ /**
15069
+ * `IncrementalState` of this compilation if it were to be reused in a subsequent incremental
15070
+ * compilation at the current moment.
15071
+ *
15072
+ * Exposed via the `state` read-only getter.
15073
+ */
15074
+ _state;
14275
15075
  constructor(state, depGraph, versions, step) {
14276
15076
  this.depGraph = depGraph;
14277
15077
  this.versions = versions;
@@ -14550,10 +15350,8 @@ function toOriginalSourceFile(sf) {
14550
15350
  * Tracks an `IncrementalState` within the strategy itself.
14551
15351
  */
14552
15352
  class TrackedIncrementalBuildStrategy {
14553
- constructor() {
14554
- this.state = null;
14555
- this.isSet = false;
14556
- }
15353
+ state = null;
15354
+ isSet = false;
14557
15355
  getIncrementalState() {
14558
15356
  return this.state;
14559
15357
  }
@@ -14587,6 +15385,8 @@ var IdentifierKind;
14587
15385
  * Describes the absolute byte offsets of a text anchor in a source code.
14588
15386
  */
14589
15387
  class AbsoluteSourceSpan {
15388
+ start;
15389
+ end;
14590
15390
  constructor(start, end) {
14591
15391
  this.start = start;
14592
15392
  this.end = end;
@@ -14600,9 +15400,7 @@ class AbsoluteSourceSpan {
14600
15400
  * `DecoratorHandler`s and exposes them to be indexed.
14601
15401
  */
14602
15402
  class IndexingContext {
14603
- constructor() {
14604
- this.components = new Set();
14605
- }
15403
+ components = new Set();
14606
15404
  /**
14607
15405
  * Adds a component to the context.
14608
15406
  */
@@ -14620,15 +15418,19 @@ class IndexingContext {
14620
15418
  * Visiting `text {{prop}}` will return
14621
15419
  * `[TopLevelIdentifier {name: 'prop', span: {start: 7, end: 11}}]`.
14622
15420
  */
14623
- class ExpressionVisitor extends checker.RecursiveAstVisitor {
15421
+ class ExpressionVisitor extends checker.RecursiveAstVisitor$1 {
15422
+ expressionStr;
15423
+ absoluteOffset;
15424
+ boundTemplate;
15425
+ targetToIdentifier;
15426
+ identifiers = [];
15427
+ errors = [];
14624
15428
  constructor(expressionStr, absoluteOffset, boundTemplate, targetToIdentifier) {
14625
15429
  super();
14626
15430
  this.expressionStr = expressionStr;
14627
15431
  this.absoluteOffset = absoluteOffset;
14628
15432
  this.boundTemplate = boundTemplate;
14629
15433
  this.targetToIdentifier = targetToIdentifier;
14630
- this.identifiers = [];
14631
- this.errors = [];
14632
15434
  }
14633
15435
  /**
14634
15436
  * Returns identifiers discovered in an expression.
@@ -14702,6 +15504,14 @@ class ExpressionVisitor extends checker.RecursiveAstVisitor {
14702
15504
  * identifiers of interest, deferring to an `ExpressionVisitor` as needed.
14703
15505
  */
14704
15506
  class TemplateVisitor$1 extends checker.RecursiveVisitor$1 {
15507
+ boundTemplate;
15508
+ // Identifiers of interest found in the template.
15509
+ identifiers = new Set();
15510
+ errors = [];
15511
+ // Map of targets in a template to their identifiers.
15512
+ targetIdentifierCache = new Map();
15513
+ // Map of elements and templates to their identifiers.
15514
+ elementAndTemplateIdentifierCache = new Map();
14705
15515
  /**
14706
15516
  * Creates a template visitor for a bound template target. The bound target can be used when
14707
15517
  * deferred to the expression visitor to get information about the target of an expression.
@@ -14711,13 +15521,6 @@ class TemplateVisitor$1 extends checker.RecursiveVisitor$1 {
14711
15521
  constructor(boundTemplate) {
14712
15522
  super();
14713
15523
  this.boundTemplate = boundTemplate;
14714
- // Identifiers of interest found in the template.
14715
- this.identifiers = new Set();
14716
- this.errors = [];
14717
- // Map of targets in a template to their identifiers.
14718
- this.targetIdentifierCache = new Map();
14719
- // Map of elements and templates to their identifiers.
14720
- this.elementAndTemplateIdentifierCache = new Map();
14721
15524
  }
14722
15525
  /**
14723
15526
  * Visits a node in the template.
@@ -15043,17 +15846,19 @@ function generateAnalysis(context) {
15043
15846
  * An index of all NgModules that export or re-export a given trait.
15044
15847
  */
15045
15848
  class NgModuleIndexImpl {
15849
+ metaReader;
15850
+ localReader;
15046
15851
  constructor(metaReader, localReader) {
15047
15852
  this.metaReader = metaReader;
15048
15853
  this.localReader = localReader;
15049
- // A map from an NgModule's Class Declaration to the "main" reference to that module, aka the one
15050
- // present in the reader metadata object
15051
- this.ngModuleAuthoritativeReference = new Map();
15052
- // A map from a Directive/Pipe's class declaration to the class declarations of all re-exporting
15053
- // NgModules
15054
- this.typeToExportingModules = new Map();
15055
- this.indexed = false;
15056
15854
  }
15855
+ // A map from an NgModule's Class Declaration to the "main" reference to that module, aka the one
15856
+ // present in the reader metadata object
15857
+ ngModuleAuthoritativeReference = new Map();
15858
+ // A map from a Directive/Pipe's class declaration to the class declarations of all re-exporting
15859
+ // NgModules
15860
+ typeToExportingModules = new Map();
15861
+ indexed = false;
15057
15862
  updateWith(cache, key, elem) {
15058
15863
  if (cache.has(key)) {
15059
15864
  cache.get(key).add(elem);
@@ -15146,11 +15951,16 @@ const RESOURCE_MARKER_TS = RESOURCE_MARKER + '.ts';
15146
15951
  * `ResourceLoader` which delegates to an `NgCompilerAdapter`'s resource loading methods.
15147
15952
  */
15148
15953
  class AdapterResourceLoader {
15954
+ adapter;
15955
+ options;
15956
+ cache = new Map();
15957
+ fetching = new Map();
15958
+ lookupResolutionHost;
15959
+ canPreload;
15960
+ canPreprocess;
15149
15961
  constructor(adapter, options) {
15150
15962
  this.adapter = adapter;
15151
15963
  this.options = options;
15152
- this.cache = new Map();
15153
- this.fetching = new Map();
15154
15964
  this.lookupResolutionHost = createLookupResolutionHost(this.adapter);
15155
15965
  this.canPreload = !!this.adapter.readResource;
15156
15966
  this.canPreprocess = !!this.adapter.transformResource;
@@ -15382,11 +16192,14 @@ function createLookupResolutionHost(adapter) {
15382
16192
  * scopes where necessary.
15383
16193
  */
15384
16194
  class StandaloneComponentScopeReader {
16195
+ metaReader;
16196
+ localModuleReader;
16197
+ dtsModuleReader;
16198
+ cache = new Map();
15385
16199
  constructor(metaReader, localModuleReader, dtsModuleReader) {
15386
16200
  this.metaReader = metaReader;
15387
16201
  this.localModuleReader = localModuleReader;
15388
16202
  this.dtsModuleReader = dtsModuleReader;
15389
- this.cache = new Map();
15390
16203
  }
15391
16204
  getScopeForComponent(clazz) {
15392
16205
  if (!this.cache.has(clazz)) {
@@ -15522,18 +16335,16 @@ function isSignalSymbol(symbol) {
15522
16335
  * This abstract class provides a base implementation for the run method.
15523
16336
  */
15524
16337
  class TemplateCheckWithVisitor {
15525
- constructor() {
15526
- /**
15527
- * When extended diagnostics were first introduced, the visitor wasn't implemented correctly
15528
- * which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
15529
- * the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
15530
- * need to be done in a major version to avoid external breakages. This flag is used to opt out
15531
- * pre-existing diagnostics from the correct behavior until the breakages have been fixed while
15532
- * ensuring that newly-written diagnostics are correct from the beginning.
15533
- * TODO(crisbeto): remove this flag and fix the internal brekages.
15534
- */
15535
- this.canVisitStructuralAttributes = true;
15536
- }
16338
+ /**
16339
+ * When extended diagnostics were first introduced, the visitor wasn't implemented correctly
16340
+ * which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
16341
+ * the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
16342
+ * need to be done in a major version to avoid external breakages. This flag is used to opt out
16343
+ * pre-existing diagnostics from the correct behavior until the breakages have been fixed while
16344
+ * ensuring that newly-written diagnostics are correct from the beginning.
16345
+ * TODO(crisbeto): remove this flag and fix the internal brekages.
16346
+ */
16347
+ canVisitStructuralAttributes = true;
15537
16348
  /**
15538
16349
  * Base implementation for run function, visits all nodes in template and calls
15539
16350
  * `visitNode()` for each one.
@@ -15546,13 +16357,16 @@ class TemplateCheckWithVisitor {
15546
16357
  /**
15547
16358
  * Visits all nodes in a template (TmplAstNode and AST) and calls `visitNode` for each one.
15548
16359
  */
15549
- class TemplateVisitor extends checker.RecursiveAstVisitor {
16360
+ class TemplateVisitor extends checker.RecursiveAstVisitor$1 {
16361
+ ctx;
16362
+ component;
16363
+ check;
16364
+ diagnostics = [];
15550
16365
  constructor(ctx, component, check) {
15551
16366
  super();
15552
16367
  this.ctx = ctx;
15553
16368
  this.component = component;
15554
16369
  this.check = check;
15555
- this.diagnostics = [];
15556
16370
  }
15557
16371
  visit(node, context) {
15558
16372
  this.diagnostics.push(...this.check.visitNode(this.ctx, this.component, node));
@@ -15680,10 +16494,7 @@ const FUNCTION_INSTANCE_PROPERTIES = new Set(['name', 'length', 'prototype']);
15680
16494
  * Ensures Signals are invoked when used in template interpolations.
15681
16495
  */
15682
16496
  class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
15683
- constructor() {
15684
- super(...arguments);
15685
- this.code = checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
15686
- }
16497
+ code = checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
15687
16498
  visitNode(ctx, component, node) {
15688
16499
  // interpolations like `{{ mySignal }}`
15689
16500
  if (node instanceof checker.Interpolation) {
@@ -15763,10 +16574,7 @@ const factory$9 = {
15763
16574
  * Will return diagnostic information when "([])" is found.
15764
16575
  */
15765
16576
  class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
15766
- constructor() {
15767
- super(...arguments);
15768
- this.code = checker.ErrorCode.INVALID_BANANA_IN_BOX;
15769
- }
16577
+ code = checker.ErrorCode.INVALID_BANANA_IN_BOX;
15770
16578
  visitNode(ctx, component, node) {
15771
16579
  if (!(node instanceof checker.BoundEvent))
15772
16580
  return [];
@@ -15811,10 +16619,7 @@ const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
15811
16619
  * hard error instead of a warning.
15812
16620
  */
15813
16621
  class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor {
15814
- constructor() {
15815
- super(...arguments);
15816
- this.code = checker.ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE;
15817
- }
16622
+ code = checker.ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE;
15818
16623
  run(ctx, component, template) {
15819
16624
  const componentMetadata = ctx.templateTypeChecker.getDirectiveMetadata(component);
15820
16625
  // Avoid running this check for non-standalone components.
@@ -15857,10 +16662,7 @@ const factory$7 = {
15857
16662
  * Will return diagnostic information when `let` is missing.
15858
16663
  */
15859
16664
  class MissingNgForOfLetCheck extends TemplateCheckWithVisitor {
15860
- constructor() {
15861
- super(...arguments);
15862
- this.code = checker.ErrorCode.MISSING_NGFOROF_LET;
15863
- }
16665
+ code = checker.ErrorCode.MISSING_NGFOROF_LET;
15864
16666
  visitNode(ctx, component, node) {
15865
16667
  if (!(node instanceof checker.Template)) {
15866
16668
  return [];
@@ -15893,11 +16695,8 @@ const factory$6 = {
15893
16695
  * otherwise it would produce inaccurate results.
15894
16696
  */
15895
16697
  class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
15896
- constructor() {
15897
- super(...arguments);
15898
- this.canVisitStructuralAttributes = false;
15899
- this.code = checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
15900
- }
16698
+ canVisitStructuralAttributes = false;
16699
+ code = checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
15901
16700
  visitNode(ctx, component, node) {
15902
16701
  if (!(node instanceof checker.Binary) || node.operation !== '??')
15903
16702
  return [];
@@ -15948,11 +16747,8 @@ const factory$5 = {
15948
16747
  * otherwise it would produce inaccurate results.
15949
16748
  */
15950
16749
  class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
15951
- constructor() {
15952
- super(...arguments);
15953
- this.canVisitStructuralAttributes = false;
15954
- this.code = checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
15955
- }
16750
+ canVisitStructuralAttributes = false;
16751
+ code = checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
15956
16752
  visitNode(ctx, component, node) {
15957
16753
  if (!(node instanceof checker.SafeCall) &&
15958
16754
  !(node instanceof checker.SafePropertyRead) &&
@@ -16007,10 +16803,7 @@ const STYLE_SUFFIXES = ['px', '%', 'em'];
16007
16803
  * binding. These suffixes are only available for style bindings.
16008
16804
  */
16009
16805
  class SuffixNotSupportedCheck extends TemplateCheckWithVisitor {
16010
- constructor() {
16011
- super(...arguments);
16012
- this.code = checker.ErrorCode.SUFFIX_NOT_SUPPORTED;
16013
- }
16806
+ code = checker.ErrorCode.SUFFIX_NOT_SUPPORTED;
16014
16807
  visitNode(ctx, component, node) {
16015
16808
  if (!(node instanceof checker.BoundAttribute))
16016
16809
  return [];
@@ -16036,10 +16829,7 @@ const factory$3 = {
16036
16829
  * to 'my-id'.
16037
16830
  */
16038
16831
  class TextAttributeNotBindingSpec extends TemplateCheckWithVisitor {
16039
- constructor() {
16040
- super(...arguments);
16041
- this.code = checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
16042
- }
16832
+ code = checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
16043
16833
  visitNode(ctx, component, node) {
16044
16834
  if (!(node instanceof checker.TextAttribute))
16045
16835
  return [];
@@ -16082,10 +16872,7 @@ const factory$2 = {
16082
16872
  * This is likely not the intent of the developer. Instead, the intent is likely to call `myFunc`.
16083
16873
  */
16084
16874
  class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
16085
- constructor() {
16086
- super(...arguments);
16087
- this.code = checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
16088
- }
16875
+ code = checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
16089
16876
  visitNode(ctx, component, node) {
16090
16877
  // If the node is not a bound event, skip it.
16091
16878
  if (!(node instanceof checker.BoundEvent))
@@ -16143,11 +16930,8 @@ const factory$1 = {
16143
16930
  * Ensures that all `@let` declarations in a template are used.
16144
16931
  */
16145
16932
  class UnusedLetDeclarationCheck extends TemplateCheckWithVisitor {
16146
- constructor() {
16147
- super(...arguments);
16148
- this.code = checker.ErrorCode.UNUSED_LET_DECLARATION;
16149
- this.analysis = new Map();
16150
- }
16933
+ code = checker.ErrorCode.UNUSED_LET_DECLARATION;
16934
+ analysis = new Map();
16151
16935
  run(ctx, component, template) {
16152
16936
  super.run(ctx, component, template);
16153
16937
  const diagnostics = [];
@@ -16203,6 +16987,8 @@ var DiagnosticCategoryLabel;
16203
16987
  })(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
16204
16988
 
16205
16989
  class ExtendedTemplateCheckerImpl {
16990
+ partialCtx;
16991
+ templateChecks;
16206
16992
  constructor(templateTypeChecker, typeChecker, templateCheckFactories, options) {
16207
16993
  this.partialCtx = { templateTypeChecker, typeChecker };
16208
16994
  this.templateChecks = new Map();
@@ -16289,6 +17075,7 @@ const SUPPORTED_DIAGNOSTIC_NAMES = new Set([
16289
17075
  ]);
16290
17076
 
16291
17077
  class TemplateSemanticsCheckerImpl {
17078
+ templateTypeChecker;
16292
17079
  constructor(templateTypeChecker) {
16293
17080
  this.templateTypeChecker = templateTypeChecker;
16294
17081
  }
@@ -16301,6 +17088,7 @@ class TemplateSemanticsCheckerImpl {
16301
17088
  }
16302
17089
  /** Visitor that verifies the semantics of a template. */
16303
17090
  class TemplateSemanticsVisitor extends checker.RecursiveVisitor$1 {
17091
+ expressionVisitor;
16304
17092
  constructor(expressionVisitor) {
16305
17093
  super();
16306
17094
  this.expressionVisitor = expressionVisitor;
@@ -16318,7 +17106,10 @@ class TemplateSemanticsVisitor extends checker.RecursiveVisitor$1 {
16318
17106
  }
16319
17107
  }
16320
17108
  /** Visitor that verifies the semantics of the expressions within a template. */
16321
- class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
17109
+ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor$1 {
17110
+ templateTypeChecker;
17111
+ component;
17112
+ diagnostics;
16322
17113
  constructor(templateTypeChecker, component, diagnostics) {
16323
17114
  super();
16324
17115
  this.templateTypeChecker = templateTypeChecker;
@@ -16404,6 +17195,8 @@ const APIS_TO_CHECK = [
16404
17195
  * Rule that flags any initializer APIs that are used outside of an initializer.
16405
17196
  */
16406
17197
  class InitializerApiUsageRule {
17198
+ reflector;
17199
+ importedSymbolsTracker;
16407
17200
  constructor(reflector, importedSymbolsTracker) {
16408
17201
  this.reflector = reflector;
16409
17202
  this.importedSymbolsTracker = importedSymbolsTracker;
@@ -16467,6 +17260,9 @@ class InitializerApiUsageRule {
16467
17260
  * Rule that flags unused symbols inside of the `imports` array of a component.
16468
17261
  */
16469
17262
  class UnusedStandaloneImportsRule {
17263
+ templateTypeChecker;
17264
+ typeCheckingConfig;
17265
+ importedSymbolsTracker;
16470
17266
  constructor(templateTypeChecker, typeCheckingConfig, importedSymbolsTracker) {
16471
17267
  this.templateTypeChecker = templateTypeChecker;
16472
17268
  this.typeCheckingConfig = typeCheckingConfig;
@@ -16503,9 +17299,17 @@ class UnusedStandaloneImportsRule {
16503
17299
  ? ts__default["default"].DiagnosticCategory.Error
16504
17300
  : ts__default["default"].DiagnosticCategory.Warning;
16505
17301
  if (unused.length === metadata.imports.length) {
16506
- return checker.makeDiagnostic(checker.ErrorCode.UNUSED_STANDALONE_IMPORTS, metadata.rawImports, 'All imports are unused', undefined, category);
16507
- }
16508
- return checker.makeDiagnostic(checker.ErrorCode.UNUSED_STANDALONE_IMPORTS, metadata.rawImports, 'Imports array contains unused imports', unused.map(([ref, type, name]) => checker.makeRelatedInformation(ref.getOriginForDiagnostics(metadata.rawImports), `${type} "${name}" is not used within the template`)), category);
17302
+ return checker.makeDiagnostic(checker.ErrorCode.UNUSED_STANDALONE_IMPORTS, this.getDiagnosticNode(metadata.rawImports), 'All imports are unused', undefined, category);
17303
+ }
17304
+ return checker.makeDiagnostic(checker.ErrorCode.UNUSED_STANDALONE_IMPORTS, this.getDiagnosticNode(metadata.rawImports), 'Imports array contains unused imports', unused.map((ref) => {
17305
+ return checker.makeRelatedInformation(
17306
+ // Intentionally don't pass a message to `makeRelatedInformation` to make the diagnostic
17307
+ // less noisy. The node will already be highlighted so the user can see which node is
17308
+ // unused. Note that in the case where an origin can't be resolved, we fall back to
17309
+ // the original node's identifier so the user can still see the name. This can happen
17310
+ // when the unused is coming from an imports array within the same file.
17311
+ ref.getOriginForDiagnostics(metadata.rawImports, ref.node.name), '');
17312
+ }), category);
16509
17313
  }
16510
17314
  getUnusedSymbols(metadata, usedDirectives, usedPipes) {
16511
17315
  const { imports, rawImports } = metadata;
@@ -16521,7 +17325,7 @@ class UnusedStandaloneImportsRule {
16521
17325
  !usedDirectives.has(currentNode) &&
16522
17326
  !this.isPotentialSharedReference(current, rawImports)) {
16523
17327
  unused ??= [];
16524
- unused.push([current, dirMeta.isComponent ? 'Component' : 'Directive', dirMeta.name]);
17328
+ unused.push(current);
16525
17329
  }
16526
17330
  continue;
16527
17331
  }
@@ -16531,7 +17335,7 @@ class UnusedStandaloneImportsRule {
16531
17335
  !usedPipes.has(pipeMeta.name) &&
16532
17336
  !this.isPotentialSharedReference(current, rawImports)) {
16533
17337
  unused ??= [];
16534
- unused.push([current, 'Pipe', pipeMeta.ref.node.name.text]);
17338
+ unused.push(current);
16535
17339
  }
16536
17340
  }
16537
17341
  return unused;
@@ -16563,6 +17367,21 @@ class UnusedStandaloneImportsRule {
16563
17367
  // symbol like an array of shared common components.
16564
17368
  return true;
16565
17369
  }
17370
+ /** Gets the node on which to report the diagnostic. */
17371
+ getDiagnosticNode(importsExpression) {
17372
+ let current = importsExpression.parent;
17373
+ while (current) {
17374
+ // Highlight the `imports:` part of the node instead of the entire node, because
17375
+ // imports arrays can be long which makes the diagnostic harder to scan visually.
17376
+ if (ts__default["default"].isPropertyAssignment(current)) {
17377
+ return current.name;
17378
+ }
17379
+ else {
17380
+ current = current.parent;
17381
+ }
17382
+ }
17383
+ return importsExpression;
17384
+ }
16566
17385
  }
16567
17386
 
16568
17387
  /*!
@@ -16576,6 +17395,7 @@ class UnusedStandaloneImportsRule {
16576
17395
  * Validates that TypeScript files match a specific set of rules set by the Angular compiler.
16577
17396
  */
16578
17397
  class SourceFileValidator {
17398
+ rules;
16579
17399
  constructor(reflector, importedSymbolsTracker, templateTypeChecker, typeCheckingConfig) {
16580
17400
  this.rules = [new InitializerApiUsageRule(reflector, importedSymbolsTracker)];
16581
17401
  {
@@ -19307,7 +20127,7 @@ var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
19307
20127
  * @param minVersion Minimum required version for the feature.
19308
20128
  */
19309
20129
  function coreVersionSupportsFeature(coreVersion, minVersion) {
19310
- // A version of `19.0.0-next.9` usually means that core is at head so it supports
20130
+ // A version of `19.0.0-rc.1` usually means that core is at head so it supports
19311
20131
  // all features. Use string interpolation prevent the placeholder from being replaced
19312
20132
  // with the current version during build time.
19313
20133
  if (coreVersion === `0.0.0-${'PLACEHOLDER'}`) {
@@ -19381,6 +20201,54 @@ function incrementalFromCompilerTicket(oldCompiler, newProgram, incrementalBuild
19381
20201
  * See the README.md for more information.
19382
20202
  */
19383
20203
  class NgCompiler {
20204
+ adapter;
20205
+ options;
20206
+ inputProgram;
20207
+ programDriver;
20208
+ incrementalStrategy;
20209
+ incrementalCompilation;
20210
+ usePoisonedData;
20211
+ livePerfRecorder;
20212
+ /**
20213
+ * Lazily evaluated state of the compilation.
20214
+ *
20215
+ * This is created on demand by calling `ensureAnalyzed`.
20216
+ */
20217
+ compilation = null;
20218
+ /**
20219
+ * Any diagnostics related to the construction of the compilation.
20220
+ *
20221
+ * These are diagnostics which arose during setup of the host and/or program.
20222
+ */
20223
+ constructionDiagnostics = [];
20224
+ /**
20225
+ * Non-template diagnostics related to the program itself. Does not include template
20226
+ * diagnostics because the template type checker memoizes them itself.
20227
+ *
20228
+ * This is set by (and memoizes) `getNonTemplateDiagnostics`.
20229
+ */
20230
+ nonTemplateDiagnostics = null;
20231
+ closureCompilerEnabled;
20232
+ currentProgram;
20233
+ entryPoint;
20234
+ moduleResolver;
20235
+ resourceManager;
20236
+ cycleAnalyzer;
20237
+ ignoreForDiagnostics;
20238
+ ignoreForEmit;
20239
+ enableTemplateTypeChecker;
20240
+ enableBlockSyntax;
20241
+ enableLetSyntax;
20242
+ angularCoreVersion;
20243
+ enableHmr;
20244
+ implicitStandaloneValue;
20245
+ /**
20246
+ * `NgCompiler` can be reused for multiple compilations (for resource-only changes), and each
20247
+ * new compilation uses a fresh `PerfRecorder`. Thus, classes created with a lifespan of the
20248
+ * `NgCompiler` use a `DelegatingPerfRecorder` so the `PerfRecorder` they write to can be updated
20249
+ * with each fresh compilation.
20250
+ */
20251
+ delegatingPerfRecorder;
19384
20252
  /**
19385
20253
  * Convert a `CompilationTicket` into an `NgCompiler` instance for the requested compilation.
19386
20254
  *
@@ -19410,25 +20278,7 @@ class NgCompiler {
19410
20278
  this.incrementalCompilation = incrementalCompilation;
19411
20279
  this.usePoisonedData = usePoisonedData;
19412
20280
  this.livePerfRecorder = livePerfRecorder;
19413
- /**
19414
- * Lazily evaluated state of the compilation.
19415
- *
19416
- * This is created on demand by calling `ensureAnalyzed`.
19417
- */
19418
- this.compilation = null;
19419
- /**
19420
- * Any diagnostics related to the construction of the compilation.
19421
- *
19422
- * These are diagnostics which arose during setup of the host and/or program.
19423
- */
19424
- this.constructionDiagnostics = [];
19425
- /**
19426
- * Non-template diagnostics related to the program itself. Does not include template
19427
- * diagnostics because the template type checker memoizes them itself.
19428
- *
19429
- * This is set by (and memoizes) `getNonTemplateDiagnostics`.
19430
- */
19431
- this.nonTemplateDiagnostics = null;
20281
+ this.angularCoreVersion = options['_angularCoreVersion'] ?? null;
19432
20282
  this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder);
19433
20283
  this.usePoisonedData = usePoisonedData || !!options._compilePoisonedComponents;
19434
20284
  this.enableTemplateTypeChecker =
@@ -19436,7 +20286,13 @@ class NgCompiler {
19436
20286
  // TODO(crisbeto): remove this flag and base `enableBlockSyntax` on the `angularCoreVersion`.
19437
20287
  this.enableBlockSyntax = options['_enableBlockSyntax'] ?? true;
19438
20288
  this.enableLetSyntax = options['_enableLetSyntax'] ?? true;
19439
- this.angularCoreVersion = options['_angularCoreVersion'] ?? null;
20289
+ // Standalone by default is enabled since v19. We need to toggle it here,
20290
+ // because the language service extension may be running with the latest
20291
+ // version of the compiler against an older version of Angular.
20292
+ this.implicitStandaloneValue =
20293
+ this.angularCoreVersion === null ||
20294
+ coreVersionSupportsFeature(this.angularCoreVersion, '>= 19.0.0-0');
20295
+ this.enableHmr = !!options['_enableHmr'];
19440
20296
  this.constructionDiagnostics.push(...this.adapter.constructionDiagnostics, ...verifyCompatibleTypeCheckOptions(this.options));
19441
20297
  this.currentProgram = inputProgram;
19442
20298
  this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
@@ -19804,6 +20660,28 @@ class NgCompiler {
19804
20660
  const compilation = this.ensureAnalyzed();
19805
20661
  compilation.traitCompiler.xi18n(ctx);
19806
20662
  }
20663
+ /**
20664
+ * Emits the JavaScript module that can be used to replace the metadata of a class during HMR.
20665
+ * @param node Class for which to generate the update module.
20666
+ */
20667
+ emitHmrUpdateModule(node) {
20668
+ const { traitCompiler, reflector } = this.ensureAnalyzed();
20669
+ if (!reflector.isClass(node)) {
20670
+ return null;
20671
+ }
20672
+ const callback = traitCompiler.compileHmrUpdateCallback(node);
20673
+ if (callback === null) {
20674
+ return null;
20675
+ }
20676
+ const sourceFile = node.getSourceFile();
20677
+ const printer = ts__default["default"].createPrinter();
20678
+ const nodeText = printer.printNode(ts__default["default"].EmitHint.Unspecified, callback, sourceFile);
20679
+ return ts__default["default"].transpileModule(nodeText, {
20680
+ compilerOptions: this.options,
20681
+ fileName: sourceFile.fileName,
20682
+ reportDiagnostics: false,
20683
+ }).outputText;
20684
+ }
19807
20685
  ensureAnalyzed() {
19808
20686
  if (this.compilation === null) {
19809
20687
  this.analyzeSync();
@@ -20182,13 +21060,13 @@ class NgCompiler {
20182
21060
  const jitDeclarationRegistry = new JitDeclarationRegistry();
20183
21061
  // Set up the IvyCompilation, which manages state for the Ivy transformer.
20184
21062
  const handlers = [
20185
- new ComponentDecoratorHandler(reflector, evaluator, metaRegistry, metaReader, scopeReader, depScopeReader, 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),
21063
+ 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),
20186
21064
  // TODO(alxhub): understand why the cast here is necessary (something to do with `null`
20187
21065
  // not being assignable to `unknown` when wrapped in `Readonly`).
20188
- new DirectiveDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder, importTracker, supportTestBed, compilationMode, jitDeclarationRegistry, !!this.options.strictStandalone),
21066
+ new DirectiveDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder, importTracker, supportTestBed, compilationMode, jitDeclarationRegistry, !!this.options.strictStandalone, this.implicitStandaloneValue),
20189
21067
  // Pipe handler must be before injectable handler in list so pipe factories are printed
20190
21068
  // before injectable factories (so injectable factories can delegate to them)
20191
- new PipeDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, injectableRegistry, isCore, this.delegatingPerfRecorder, supportTestBed, compilationMode, !!this.options.generateExtraImportsInLocalMode, !!this.options.strictStandalone),
21069
+ new PipeDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, injectableRegistry, isCore, this.delegatingPerfRecorder, supportTestBed, compilationMode, !!this.options.generateExtraImportsInLocalMode, !!this.options.strictStandalone, this.implicitStandaloneValue),
20192
21070
  new InjectableDecoratorHandler(reflector, evaluator, isCore, strictCtorDeps, injectableRegistry, this.delegatingPerfRecorder, supportTestBed, compilationMode),
20193
21071
  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),
20194
21072
  ];
@@ -20367,6 +21245,7 @@ function makeConfigDiagnostic({ category, code, messageText, }) {
20367
21245
  };
20368
21246
  }
20369
21247
  class ReferenceGraphAdapter {
21248
+ graph;
20370
21249
  constructor(graph) {
20371
21250
  this.graph = graph;
20372
21251
  }
@@ -20384,6 +21263,9 @@ class ReferenceGraphAdapter {
20384
21263
  }
20385
21264
  }
20386
21265
  class NotifyingProgramDriverWrapper {
21266
+ delegate;
21267
+ notifyNewProgram;
21268
+ getSourceFileVersion;
20387
21269
  constructor(delegate, notifyNewProgram) {
20388
21270
  this.delegate = delegate;
20389
21271
  this.notifyNewProgram = notifyNewProgram;
@@ -20424,6 +21306,36 @@ function versionMapFromProgram(program, driver) {
20424
21306
  * generated for this class.
20425
21307
  */
20426
21308
  class DelegatingCompilerHost {
21309
+ delegate;
21310
+ createHash;
21311
+ directoryExists;
21312
+ fileNameToModuleName;
21313
+ getCancellationToken;
21314
+ getCanonicalFileName;
21315
+ getCurrentDirectory;
21316
+ getDefaultLibFileName;
21317
+ getDefaultLibLocation;
21318
+ getDirectories;
21319
+ getEnvironmentVariable;
21320
+ getModifiedResourceFiles;
21321
+ getNewLine;
21322
+ getParsedCommandLine;
21323
+ getSourceFileByPath;
21324
+ readDirectory;
21325
+ readFile;
21326
+ readResource;
21327
+ transformResource;
21328
+ realpath;
21329
+ resolveModuleNames;
21330
+ resolveTypeReferenceDirectives;
21331
+ resourceNameToFileName;
21332
+ trace;
21333
+ useCaseSensitiveFileNames;
21334
+ writeFile;
21335
+ getModuleResolutionCache;
21336
+ hasInvalidatedResolutions;
21337
+ resolveModuleNameLiterals;
21338
+ resolveTypeReferenceDirectiveReferences;
20427
21339
  // jsDocParsingMode is not a method like the other elements above
20428
21340
  // TODO: ignore usage can be dropped once 5.2 support is dropped
20429
21341
  get jsDocParsingMode() {
@@ -20487,11 +21399,16 @@ class DelegatingCompilerHost {
20487
21399
  * `ExtendedTsCompilerHost` methods whenever present.
20488
21400
  */
20489
21401
  class NgCompilerHost extends DelegatingCompilerHost {
21402
+ shimAdapter;
21403
+ shimTagger;
21404
+ entryPoint = null;
21405
+ constructionDiagnostics;
21406
+ inputFiles;
21407
+ rootDirs;
20490
21408
  constructor(delegate, inputFiles, rootDirs, shimAdapter, shimTagger, entryPoint, diagnostics) {
20491
21409
  super(delegate);
20492
21410
  this.shimAdapter = shimAdapter;
20493
21411
  this.shimTagger = shimTagger;
20494
- this.entryPoint = null;
20495
21412
  this.entryPoint = entryPoint;
20496
21413
  this.constructionDiagnostics = diagnostics;
20497
21414
  this.inputFiles = [...inputFiles, ...shimAdapter.extraInputFiles];
@@ -20636,6 +21553,14 @@ class NgCompilerHost extends DelegatingCompilerHost {
20636
21553
  * command-line main() function or the Angular CLI.
20637
21554
  */
20638
21555
  class NgtscProgram {
21556
+ options;
21557
+ compiler;
21558
+ /**
21559
+ * The primary TypeScript program, which is used for analysis and emit.
21560
+ */
21561
+ tsProgram;
21562
+ host;
21563
+ incrementalStrategy;
20639
21564
  constructor(rootNames, options, delegateHost, oldProgram) {
20640
21565
  this.options = options;
20641
21566
  const perfRecorder = ActivePerfRecorder.zeroedToNow();