@angular/compiler 19.2.0-rc.0 → 20.0.0-next.0

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.2.0-rc.0
2
+ * @license Angular v20.0.0-next.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -923,6 +923,7 @@ var BinaryOperator;
923
923
  BinaryOperator[BinaryOperator["Bigger"] = 15] = "Bigger";
924
924
  BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
925
925
  BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
926
+ BinaryOperator[BinaryOperator["Exponentiation"] = 18] = "Exponentiation";
926
927
  })(BinaryOperator || (BinaryOperator = {}));
927
928
  function nullSafeIsEquivalent(base, other) {
928
929
  if (base == null || other == null) {
@@ -994,6 +995,9 @@ class Expression {
994
995
  modulo(rhs, sourceSpan) {
995
996
  return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
996
997
  }
998
+ power(rhs, sourceSpan) {
999
+ return new BinaryOperatorExpr(BinaryOperator.Exponentiation, this, rhs, null, sourceSpan);
1000
+ }
997
1001
  and(rhs, sourceSpan) {
998
1002
  return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
999
1003
  }
@@ -1071,6 +1075,25 @@ class TypeofExpr extends Expression {
1071
1075
  return new TypeofExpr(this.expr.clone());
1072
1076
  }
1073
1077
  }
1078
+ class VoidExpr extends Expression {
1079
+ expr;
1080
+ constructor(expr, type, sourceSpan) {
1081
+ super(type, sourceSpan);
1082
+ this.expr = expr;
1083
+ }
1084
+ visitExpression(visitor, context) {
1085
+ return visitor.visitVoidExpr(this, context);
1086
+ }
1087
+ isEquivalent(e) {
1088
+ return e instanceof VoidExpr && e.expr.isEquivalent(this.expr);
1089
+ }
1090
+ isConstant() {
1091
+ return this.expr.isConstant();
1092
+ }
1093
+ clone() {
1094
+ return new VoidExpr(this.expr.clone());
1095
+ }
1096
+ }
1074
1097
  class WrappedNodeExpr extends Expression {
1075
1098
  node;
1076
1099
  constructor(node, type, sourceSpan) {
@@ -1987,6 +2010,9 @@ class RecursiveAstVisitor$1 {
1987
2010
  visitTypeofExpr(ast, context) {
1988
2011
  return this.visitExpression(ast, context);
1989
2012
  }
2013
+ visitVoidExpr(ast, context) {
2014
+ return this.visitExpression(ast, context);
2015
+ }
1990
2016
  visitReadVarExpr(ast, context) {
1991
2017
  return this.visitExpression(ast, context);
1992
2018
  }
@@ -2252,6 +2278,7 @@ var output_ast = /*#__PURE__*/Object.freeze({
2252
2278
  Expression: Expression,
2253
2279
  ReadVarExpr: ReadVarExpr,
2254
2280
  TypeofExpr: TypeofExpr,
2281
+ VoidExpr: VoidExpr,
2255
2282
  WrappedNodeExpr: WrappedNodeExpr,
2256
2283
  WriteVarExpr: WriteVarExpr,
2257
2284
  WriteKeyExpr: WriteKeyExpr,
@@ -3666,6 +3693,10 @@ class AbstractEmitterVisitor {
3666
3693
  ctx.print(expr, 'typeof ');
3667
3694
  expr.expr.visitExpression(this, ctx);
3668
3695
  }
3696
+ visitVoidExpr(expr, ctx) {
3697
+ ctx.print(expr, 'void ');
3698
+ expr.expr.visitExpression(this, ctx);
3699
+ }
3669
3700
  visitReadVarExpr(ast, ctx) {
3670
3701
  ctx.print(ast, ast.name);
3671
3702
  return null;
@@ -3779,6 +3810,9 @@ class AbstractEmitterVisitor {
3779
3810
  case BinaryOperator.Modulo:
3780
3811
  opStr = '%';
3781
3812
  break;
3813
+ case BinaryOperator.Exponentiation:
3814
+ opStr = '**';
3815
+ break;
3782
3816
  case BinaryOperator.Lower:
3783
3817
  opStr = '<';
3784
3818
  break;
@@ -4481,6 +4515,16 @@ class TypeofExpression extends AST {
4481
4515
  return visitor.visitTypeofExpression(this, context);
4482
4516
  }
4483
4517
  }
4518
+ class VoidExpression extends AST {
4519
+ expression;
4520
+ constructor(span, sourceSpan, expression) {
4521
+ super(span, sourceSpan);
4522
+ this.expression = expression;
4523
+ }
4524
+ visit(visitor, context = null) {
4525
+ return visitor.visitVoidExpression(this, context);
4526
+ }
4527
+ }
4484
4528
  class NonNullAssert extends AST {
4485
4529
  expression;
4486
4530
  constructor(span, sourceSpan, expression) {
@@ -4663,6 +4707,9 @@ class RecursiveAstVisitor {
4663
4707
  visitTypeofExpression(ast, context) {
4664
4708
  this.visit(ast.expression, context);
4665
4709
  }
4710
+ visitVoidExpression(ast, context) {
4711
+ this.visit(ast.expression, context);
4712
+ }
4666
4713
  visitNonNullAssert(ast, context) {
4667
4714
  this.visit(ast.expression, context);
4668
4715
  }
@@ -10420,6 +10467,9 @@ function transformExpressionsInExpression(expr, transform, flags) {
10420
10467
  else if (expr instanceof TypeofExpr) {
10421
10468
  expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);
10422
10469
  }
10470
+ else if (expr instanceof VoidExpr) {
10471
+ expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);
10472
+ }
10423
10473
  else if (expr instanceof WriteVarExpr) {
10424
10474
  expr.value = transformExpressionsInExpression(expr.value, transform, flags);
10425
10475
  }
@@ -11927,6 +11977,7 @@ const BINARY_OPERATORS = new Map([
11927
11977
  ['<=', BinaryOperator.LowerEquals],
11928
11978
  ['-', BinaryOperator.Minus],
11929
11979
  ['%', BinaryOperator.Modulo],
11980
+ ['**', BinaryOperator.Exponentiation],
11930
11981
  ['*', BinaryOperator.Multiply],
11931
11982
  ['!=', BinaryOperator.NotEquals],
11932
11983
  ['!==', BinaryOperator.NotIdentical],
@@ -17636,6 +17687,7 @@ const KEYWORDS = [
17636
17687
  'else',
17637
17688
  'this',
17638
17689
  'typeof',
17690
+ 'void',
17639
17691
  ];
17640
17692
  class Lexer {
17641
17693
  tokenize(text) {
@@ -17700,6 +17752,9 @@ class Token {
17700
17752
  isKeywordTypeof() {
17701
17753
  return this.type === TokenType.Keyword && this.strValue === 'typeof';
17702
17754
  }
17755
+ isKeywordVoid() {
17756
+ return this.type === TokenType.Keyword && this.strValue === 'void';
17757
+ }
17703
17758
  isError() {
17704
17759
  return this.type === TokenType.Error;
17705
17760
  }
@@ -17844,11 +17899,12 @@ class _Scanner {
17844
17899
  return this.scanPrivateIdentifier();
17845
17900
  case $PLUS:
17846
17901
  case $MINUS:
17847
- case $STAR:
17848
17902
  case $SLASH:
17849
17903
  case $PERCENT:
17850
17904
  case $CARET:
17851
17905
  return this.scanOperator(start, String.fromCharCode(peek));
17906
+ case $STAR:
17907
+ return this.scanComplexOperator(start, '*', $STAR, '*');
17852
17908
  case $QUESTION:
17853
17909
  return this.scanQuestion(start);
17854
17910
  case $LT:
@@ -18418,6 +18474,7 @@ class _ParseAST {
18418
18474
  parseFlags;
18419
18475
  errors;
18420
18476
  offset;
18477
+ lastUnary = null;
18421
18478
  rparensExpected = 0;
18422
18479
  rbracketsExpected = 0;
18423
18480
  rbracesExpected = 0;
@@ -18784,7 +18841,7 @@ class _ParseAST {
18784
18841
  parseMultiplicative() {
18785
18842
  // '*', '%', '/'
18786
18843
  const start = this.inputIndex;
18787
- let result = this.parsePrefix();
18844
+ let result = this.parseExponentiation();
18788
18845
  while (this.next.type == TokenType.Operator) {
18789
18846
  const operator = this.next.strValue;
18790
18847
  switch (operator) {
@@ -18792,7 +18849,7 @@ class _ParseAST {
18792
18849
  case '%':
18793
18850
  case '/':
18794
18851
  this.advance();
18795
- let right = this.parsePrefix();
18852
+ const right = this.parseExponentiation();
18796
18853
  result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);
18797
18854
  continue;
18798
18855
  }
@@ -18800,6 +18857,23 @@ class _ParseAST {
18800
18857
  }
18801
18858
  return result;
18802
18859
  }
18860
+ parseExponentiation() {
18861
+ // '**'
18862
+ const start = this.inputIndex;
18863
+ let result = this.parsePrefix();
18864
+ while (this.next.type == TokenType.Operator && this.next.strValue === '**') {
18865
+ // This aligns with Javascript semantics which require any unary operator preceeding the
18866
+ // exponentiation operation to be explicitly grouped as either applying to the base or result
18867
+ // of the exponentiation operation.
18868
+ if (result === this.lastUnary) {
18869
+ this.error('Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence');
18870
+ }
18871
+ this.advance();
18872
+ const right = this.parsePrefix();
18873
+ result = new Binary(this.span(start), this.sourceSpan(start), '**', result, right);
18874
+ }
18875
+ return result;
18876
+ }
18803
18877
  parsePrefix() {
18804
18878
  if (this.next.type == TokenType.Operator) {
18805
18879
  const start = this.inputIndex;
@@ -18809,22 +18883,28 @@ class _ParseAST {
18809
18883
  case '+':
18810
18884
  this.advance();
18811
18885
  result = this.parsePrefix();
18812
- return Unary.createPlus(this.span(start), this.sourceSpan(start), result);
18886
+ return (this.lastUnary = Unary.createPlus(this.span(start), this.sourceSpan(start), result));
18813
18887
  case '-':
18814
18888
  this.advance();
18815
18889
  result = this.parsePrefix();
18816
- return Unary.createMinus(this.span(start), this.sourceSpan(start), result);
18890
+ return (this.lastUnary = Unary.createMinus(this.span(start), this.sourceSpan(start), result));
18817
18891
  case '!':
18818
18892
  this.advance();
18819
18893
  result = this.parsePrefix();
18820
- return new PrefixNot(this.span(start), this.sourceSpan(start), result);
18894
+ return (this.lastUnary = new PrefixNot(this.span(start), this.sourceSpan(start), result));
18821
18895
  }
18822
18896
  }
18823
18897
  else if (this.next.isKeywordTypeof()) {
18824
18898
  this.advance();
18825
18899
  const start = this.inputIndex;
18826
18900
  let result = this.parsePrefix();
18827
- return new TypeofExpression(this.span(start), this.sourceSpan(start), result);
18901
+ return (this.lastUnary = new TypeofExpression(this.span(start), this.sourceSpan(start), result));
18902
+ }
18903
+ else if (this.next.isKeywordVoid()) {
18904
+ this.advance();
18905
+ const start = this.inputIndex;
18906
+ let result = this.parsePrefix();
18907
+ return (this.lastUnary = new VoidExpression(this.span(start), this.sourceSpan(start), result));
18828
18908
  }
18829
18909
  return this.parseCallChain();
18830
18910
  }
@@ -18865,6 +18945,7 @@ class _ParseAST {
18865
18945
  this.rparensExpected++;
18866
18946
  const result = this.parsePipe();
18867
18947
  this.rparensExpected--;
18948
+ this.lastUnary = null;
18868
18949
  this.expectCharacter($RPAREN);
18869
18950
  return result;
18870
18951
  }
@@ -19488,6 +19569,9 @@ class SerializeExpressionVisitor {
19488
19569
  visitTypeofExpression(ast, context) {
19489
19570
  return `typeof ${ast.expression.visit(this, context)}`;
19490
19571
  }
19572
+ visitVoidExpression(ast, context) {
19573
+ return `void ${ast.expression.visit(this, context)}`;
19574
+ }
19491
19575
  visitASTWithSource(ast, context) {
19492
19576
  return ast.ast.visit(this, context);
19493
19577
  }
@@ -26194,6 +26278,9 @@ function convertAst(ast, job, baseSourceSpan) {
26194
26278
  else if (ast instanceof TypeofExpression) {
26195
26279
  return typeofExpr(convertAst(ast.expression, job, baseSourceSpan));
26196
26280
  }
26281
+ else if (ast instanceof VoidExpression) {
26282
+ return new VoidExpr(convertAst(ast.expression, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
26283
+ }
26197
26284
  else if (ast instanceof TemplateLiteral) {
26198
26285
  return new TemplateLiteralExpr(ast.elements.map((el) => {
26199
26286
  return new TemplateLiteralElementExpr(el.text, convertSourceSpan(el.span, baseSourceSpan));
@@ -31029,13 +31116,6 @@ function publishFacade(global) {
31029
31116
  ng.ɵcompilerFacade = new CompilerFacadeImpl();
31030
31117
  }
31031
31118
 
31032
- /**
31033
- * @module
31034
- * @description
31035
- * Entry point for all public APIs of the compiler package.
31036
- */
31037
- const VERSION = new Version('19.2.0-rc.0');
31038
-
31039
31119
  class CompilerConfig {
31040
31120
  defaultEncapsulation;
31041
31121
  preserveWhitespaces;
@@ -32750,143 +32830,6 @@ function compileComponentMetadataAsyncResolver(dependencies) {
32750
32830
  return arrowFn([], literalArr(dynamicImports));
32751
32831
  }
32752
32832
 
32753
- /**
32754
- * Generate an ngDevMode guarded call to setClassDebugInfo with the debug info about the class
32755
- * (e.g., the file name in which the class is defined)
32756
- */
32757
- function compileClassDebugInfo(debugInfo) {
32758
- const debugInfoObject = {
32759
- className: debugInfo.className,
32760
- };
32761
- // Include file path and line number only if the file relative path is calculated successfully.
32762
- if (debugInfo.filePath) {
32763
- debugInfoObject.filePath = debugInfo.filePath;
32764
- debugInfoObject.lineNumber = debugInfo.lineNumber;
32765
- }
32766
- // Include forbidOrphanRendering only if it's set to true (to reduce generated code)
32767
- if (debugInfo.forbidOrphanRendering) {
32768
- debugInfoObject.forbidOrphanRendering = literal(true);
32769
- }
32770
- const fnCall = importExpr(Identifiers.setClassDebugInfo)
32771
- .callFn([debugInfo.type, mapLiteral(debugInfoObject)]);
32772
- const iife = arrowFn([], [devOnlyGuardedExpression(fnCall).toStmt()]);
32773
- return iife.callFn([]);
32774
- }
32775
-
32776
- /*!
32777
- * @license
32778
- * Copyright Google LLC All Rights Reserved.
32779
- *
32780
- * Use of this source code is governed by an MIT-style license that can be
32781
- * found in the LICENSE file at https://angular.dev/license
32782
- */
32783
- /**
32784
- * Compiles the expression that initializes HMR for a class.
32785
- * @param meta HMR metadata extracted from the class.
32786
- */
32787
- function compileHmrInitializer(meta) {
32788
- const moduleName = 'm';
32789
- const dataName = 'd';
32790
- const timestampName = 't';
32791
- const idName = 'id';
32792
- const importCallbackName = `${meta.className}_HmrLoad`;
32793
- const namespaces = meta.namespaceDependencies.map((dep) => {
32794
- return new ExternalExpr({ moduleName: dep.moduleName, name: null });
32795
- });
32796
- // m.default
32797
- const defaultRead = variable(moduleName).prop('default');
32798
- // ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals], import.meta, id);
32799
- const replaceCall = importExpr(Identifiers.replaceMetadata)
32800
- .callFn([
32801
- meta.type,
32802
- defaultRead,
32803
- literalArr(namespaces),
32804
- literalArr(meta.localDependencies.map((l) => l.runtimeRepresentation)),
32805
- variable('import').prop('meta'),
32806
- variable(idName),
32807
- ]);
32808
- // (m) => m.default && ɵɵreplaceMetadata(...)
32809
- const replaceCallback = arrowFn([new FnParam(moduleName)], defaultRead.and(replaceCall));
32810
- // '<url>?c=' + id + '&t=' + encodeURIComponent(t)
32811
- const urlValue = literal(`./@ng/component?c=`)
32812
- .plus(variable(idName))
32813
- .plus(literal('&t='))
32814
- .plus(variable('encodeURIComponent').callFn([variable(timestampName)]));
32815
- // import.meta.url
32816
- const urlBase = variable('import').prop('meta').prop('url');
32817
- // new URL(urlValue, urlBase).href
32818
- const urlHref = new InstantiateExpr(variable('URL'), [urlValue, urlBase]).prop('href');
32819
- // function Cmp_HmrLoad(t) {
32820
- // import(/* @vite-ignore */ urlHref).then((m) => m.default && replaceMetadata(...));
32821
- // }
32822
- const importCallback = new DeclareFunctionStmt(importCallbackName, [new FnParam(timestampName)], [
32823
- // The vite-ignore special comment is required to prevent Vite from generating a superfluous
32824
- // warning for each usage within the development code. If Vite provides a method to
32825
- // programmatically avoid this warning in the future, this added comment can be removed here.
32826
- new DynamicImportExpr(urlHref, null, '@vite-ignore')
32827
- .prop('then')
32828
- .callFn([replaceCallback])
32829
- .toStmt(),
32830
- ], null, StmtModifier.Final);
32831
- // (d) => d.id === id && Cmp_HmrLoad(d.timestamp)
32832
- const updateCallback = arrowFn([new FnParam(dataName)], variable(dataName)
32833
- .prop('id')
32834
- .identical(variable(idName))
32835
- .and(variable(importCallbackName).callFn([variable(dataName).prop('timestamp')])));
32836
- // Cmp_HmrLoad(Date.now());
32837
- // Initial call to kick off the loading in order to avoid edge cases with components
32838
- // coming from lazy chunks that change before the chunk has loaded.
32839
- const initialCall = variable(importCallbackName)
32840
- .callFn([variable('Date').prop('now').callFn([])]);
32841
- // import.meta.hot
32842
- const hotRead = variable('import').prop('meta').prop('hot');
32843
- // import.meta.hot.on('angular:component-update', () => ...);
32844
- const hotListener = hotRead
32845
- .clone()
32846
- .prop('on')
32847
- .callFn([literal('angular:component-update'), updateCallback]);
32848
- return arrowFn([], [
32849
- // const id = <id>;
32850
- new DeclareVarStmt(idName, literal(encodeURIComponent(`${meta.filePath}@${meta.className}`)), null, StmtModifier.Final),
32851
- // function Cmp_HmrLoad() {...}.
32852
- importCallback,
32853
- // ngDevMode && Cmp_HmrLoad(Date.now());
32854
- devOnlyGuardedExpression(initialCall).toStmt(),
32855
- // ngDevMode && import.meta.hot && import.meta.hot.on(...)
32856
- devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
32857
- ])
32858
- .callFn([]);
32859
- }
32860
- /**
32861
- * Compiles the HMR update callback for a class.
32862
- * @param definitions Compiled definitions for the class (e.g. `defineComponent` calls).
32863
- * @param constantStatements Supporting constants statements that were generated alongside
32864
- * the definition.
32865
- * @param meta HMR metadata extracted from the class.
32866
- */
32867
- function compileHmrUpdateCallback(definitions, constantStatements, meta) {
32868
- const namespaces = 'ɵɵnamespaces';
32869
- const params = [meta.className, namespaces].map((name) => new FnParam(name, DYNAMIC_TYPE));
32870
- const body = [];
32871
- for (const local of meta.localDependencies) {
32872
- params.push(new FnParam(local.name));
32873
- }
32874
- // Declare variables that read out the individual namespaces.
32875
- for (let i = 0; i < meta.namespaceDependencies.length; i++) {
32876
- body.push(new DeclareVarStmt(meta.namespaceDependencies[i].assignedName, variable(namespaces).key(literal(i)), DYNAMIC_TYPE, StmtModifier.Final));
32877
- }
32878
- body.push(...constantStatements);
32879
- for (const field of definitions) {
32880
- if (field.initializer !== null) {
32881
- body.push(variable(meta.className).prop(field.name).set(field.initializer).toStmt());
32882
- for (const stmt of field.statements) {
32883
- body.push(stmt);
32884
- }
32885
- }
32886
- }
32887
- return new DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, StmtModifier.Final);
32888
- }
32889
-
32890
32833
  /**
32891
32834
  * Every time we make a breaking change to the declaration interface or partial-linker behavior, we
32892
32835
  * must update this constant to prevent old partial-linkers from incorrectly processing the
@@ -32902,7 +32845,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
32902
32845
  function compileDeclareClassMetadata(metadata) {
32903
32846
  const definitionMap = new DefinitionMap();
32904
32847
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
32905
- definitionMap.set('version', literal('19.2.0-rc.0'));
32848
+ definitionMap.set('version', literal('20.0.0-next.0'));
32906
32849
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32907
32850
  definitionMap.set('type', metadata.type);
32908
32851
  definitionMap.set('decorators', metadata.decorators);
@@ -32920,7 +32863,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
32920
32863
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
32921
32864
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
32922
32865
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
32923
- definitionMap.set('version', literal('19.2.0-rc.0'));
32866
+ definitionMap.set('version', literal('20.0.0-next.0'));
32924
32867
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32925
32868
  definitionMap.set('type', metadata.type);
32926
32869
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -33015,7 +32958,7 @@ function createDirectiveDefinitionMap(meta) {
33015
32958
  const definitionMap = new DefinitionMap();
33016
32959
  const minVersion = getMinimumVersionForPartialOutput(meta);
33017
32960
  definitionMap.set('minVersion', literal(minVersion));
33018
- definitionMap.set('version', literal('19.2.0-rc.0'));
32961
+ definitionMap.set('version', literal('20.0.0-next.0'));
33019
32962
  // e.g. `type: MyDirective`
33020
32963
  definitionMap.set('type', meta.type.value);
33021
32964
  if (meta.isStandalone !== undefined) {
@@ -33434,7 +33377,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
33434
33377
  function compileDeclareFactoryFunction(meta) {
33435
33378
  const definitionMap = new DefinitionMap();
33436
33379
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
33437
- definitionMap.set('version', literal('19.2.0-rc.0'));
33380
+ definitionMap.set('version', literal('20.0.0-next.0'));
33438
33381
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33439
33382
  definitionMap.set('type', meta.type.value);
33440
33383
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -33469,7 +33412,7 @@ function compileDeclareInjectableFromMetadata(meta) {
33469
33412
  function createInjectableDefinitionMap(meta) {
33470
33413
  const definitionMap = new DefinitionMap();
33471
33414
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
33472
- definitionMap.set('version', literal('19.2.0-rc.0'));
33415
+ definitionMap.set('version', literal('20.0.0-next.0'));
33473
33416
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33474
33417
  definitionMap.set('type', meta.type.value);
33475
33418
  // Only generate providedIn property if it has a non-null value
@@ -33520,7 +33463,7 @@ function compileDeclareInjectorFromMetadata(meta) {
33520
33463
  function createInjectorDefinitionMap(meta) {
33521
33464
  const definitionMap = new DefinitionMap();
33522
33465
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
33523
- definitionMap.set('version', literal('19.2.0-rc.0'));
33466
+ definitionMap.set('version', literal('20.0.0-next.0'));
33524
33467
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33525
33468
  definitionMap.set('type', meta.type.value);
33526
33469
  definitionMap.set('providers', meta.providers);
@@ -33553,7 +33496,7 @@ function createNgModuleDefinitionMap(meta) {
33553
33496
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
33554
33497
  }
33555
33498
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
33556
- definitionMap.set('version', literal('19.2.0-rc.0'));
33499
+ definitionMap.set('version', literal('20.0.0-next.0'));
33557
33500
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33558
33501
  definitionMap.set('type', meta.type.value);
33559
33502
  // We only generate the keys in the metadata if the arrays contain values.
@@ -33604,7 +33547,7 @@ function compileDeclarePipeFromMetadata(meta) {
33604
33547
  function createPipeDefinitionMap(meta) {
33605
33548
  const definitionMap = new DefinitionMap();
33606
33549
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
33607
- definitionMap.set('version', literal('19.2.0-rc.0'));
33550
+ definitionMap.set('version', literal('20.0.0-next.0'));
33608
33551
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33609
33552
  // e.g. `type: MyPipe`
33610
33553
  definitionMap.set('type', meta.type.value);
@@ -33620,6 +33563,150 @@ function createPipeDefinitionMap(meta) {
33620
33563
  return definitionMap;
33621
33564
  }
33622
33565
 
33566
+ /**
33567
+ * Generate an ngDevMode guarded call to setClassDebugInfo with the debug info about the class
33568
+ * (e.g., the file name in which the class is defined)
33569
+ */
33570
+ function compileClassDebugInfo(debugInfo) {
33571
+ const debugInfoObject = {
33572
+ className: debugInfo.className,
33573
+ };
33574
+ // Include file path and line number only if the file relative path is calculated successfully.
33575
+ if (debugInfo.filePath) {
33576
+ debugInfoObject.filePath = debugInfo.filePath;
33577
+ debugInfoObject.lineNumber = debugInfo.lineNumber;
33578
+ }
33579
+ // Include forbidOrphanRendering only if it's set to true (to reduce generated code)
33580
+ if (debugInfo.forbidOrphanRendering) {
33581
+ debugInfoObject.forbidOrphanRendering = literal(true);
33582
+ }
33583
+ const fnCall = importExpr(Identifiers.setClassDebugInfo)
33584
+ .callFn([debugInfo.type, mapLiteral(debugInfoObject)]);
33585
+ const iife = arrowFn([], [devOnlyGuardedExpression(fnCall).toStmt()]);
33586
+ return iife.callFn([]);
33587
+ }
33588
+
33589
+ /*!
33590
+ * @license
33591
+ * Copyright Google LLC All Rights Reserved.
33592
+ *
33593
+ * Use of this source code is governed by an MIT-style license that can be
33594
+ * found in the LICENSE file at https://angular.dev/license
33595
+ */
33596
+ /**
33597
+ * Compiles the expression that initializes HMR for a class.
33598
+ * @param meta HMR metadata extracted from the class.
33599
+ */
33600
+ function compileHmrInitializer(meta) {
33601
+ const moduleName = 'm';
33602
+ const dataName = 'd';
33603
+ const timestampName = 't';
33604
+ const idName = 'id';
33605
+ const importCallbackName = `${meta.className}_HmrLoad`;
33606
+ const namespaces = meta.namespaceDependencies.map((dep) => {
33607
+ return new ExternalExpr({ moduleName: dep.moduleName, name: null });
33608
+ });
33609
+ // m.default
33610
+ const defaultRead = variable(moduleName).prop('default');
33611
+ // ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals], import.meta, id);
33612
+ const replaceCall = importExpr(Identifiers.replaceMetadata)
33613
+ .callFn([
33614
+ meta.type,
33615
+ defaultRead,
33616
+ literalArr(namespaces),
33617
+ literalArr(meta.localDependencies.map((l) => l.runtimeRepresentation)),
33618
+ variable('import').prop('meta'),
33619
+ variable(idName),
33620
+ ]);
33621
+ // (m) => m.default && ɵɵreplaceMetadata(...)
33622
+ const replaceCallback = arrowFn([new FnParam(moduleName)], defaultRead.and(replaceCall));
33623
+ // '<url>?c=' + id + '&t=' + encodeURIComponent(t)
33624
+ const urlValue = literal(`./@ng/component?c=`)
33625
+ .plus(variable(idName))
33626
+ .plus(literal('&t='))
33627
+ .plus(variable('encodeURIComponent').callFn([variable(timestampName)]));
33628
+ // import.meta.url
33629
+ const urlBase = variable('import').prop('meta').prop('url');
33630
+ // new URL(urlValue, urlBase).href
33631
+ const urlHref = new InstantiateExpr(variable('URL'), [urlValue, urlBase]).prop('href');
33632
+ // function Cmp_HmrLoad(t) {
33633
+ // import(/* @vite-ignore */ urlHref).then((m) => m.default && replaceMetadata(...));
33634
+ // }
33635
+ const importCallback = new DeclareFunctionStmt(importCallbackName, [new FnParam(timestampName)], [
33636
+ // The vite-ignore special comment is required to prevent Vite from generating a superfluous
33637
+ // warning for each usage within the development code. If Vite provides a method to
33638
+ // programmatically avoid this warning in the future, this added comment can be removed here.
33639
+ new DynamicImportExpr(urlHref, null, '@vite-ignore')
33640
+ .prop('then')
33641
+ .callFn([replaceCallback])
33642
+ .toStmt(),
33643
+ ], null, StmtModifier.Final);
33644
+ // (d) => d.id === id && Cmp_HmrLoad(d.timestamp)
33645
+ const updateCallback = arrowFn([new FnParam(dataName)], variable(dataName)
33646
+ .prop('id')
33647
+ .identical(variable(idName))
33648
+ .and(variable(importCallbackName).callFn([variable(dataName).prop('timestamp')])));
33649
+ // Cmp_HmrLoad(Date.now());
33650
+ // Initial call to kick off the loading in order to avoid edge cases with components
33651
+ // coming from lazy chunks that change before the chunk has loaded.
33652
+ const initialCall = variable(importCallbackName)
33653
+ .callFn([variable('Date').prop('now').callFn([])]);
33654
+ // import.meta.hot
33655
+ const hotRead = variable('import').prop('meta').prop('hot');
33656
+ // import.meta.hot.on('angular:component-update', () => ...);
33657
+ const hotListener = hotRead
33658
+ .clone()
33659
+ .prop('on')
33660
+ .callFn([literal('angular:component-update'), updateCallback]);
33661
+ return arrowFn([], [
33662
+ // const id = <id>;
33663
+ new DeclareVarStmt(idName, literal(encodeURIComponent(`${meta.filePath}@${meta.className}`)), null, StmtModifier.Final),
33664
+ // function Cmp_HmrLoad() {...}.
33665
+ importCallback,
33666
+ // ngDevMode && Cmp_HmrLoad(Date.now());
33667
+ devOnlyGuardedExpression(initialCall).toStmt(),
33668
+ // ngDevMode && import.meta.hot && import.meta.hot.on(...)
33669
+ devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
33670
+ ])
33671
+ .callFn([]);
33672
+ }
33673
+ /**
33674
+ * Compiles the HMR update callback for a class.
33675
+ * @param definitions Compiled definitions for the class (e.g. `defineComponent` calls).
33676
+ * @param constantStatements Supporting constants statements that were generated alongside
33677
+ * the definition.
33678
+ * @param meta HMR metadata extracted from the class.
33679
+ */
33680
+ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
33681
+ const namespaces = 'ɵɵnamespaces';
33682
+ const params = [meta.className, namespaces].map((name) => new FnParam(name, DYNAMIC_TYPE));
33683
+ const body = [];
33684
+ for (const local of meta.localDependencies) {
33685
+ params.push(new FnParam(local.name));
33686
+ }
33687
+ // Declare variables that read out the individual namespaces.
33688
+ for (let i = 0; i < meta.namespaceDependencies.length; i++) {
33689
+ body.push(new DeclareVarStmt(meta.namespaceDependencies[i].assignedName, variable(namespaces).key(literal(i)), DYNAMIC_TYPE, StmtModifier.Final));
33690
+ }
33691
+ body.push(...constantStatements);
33692
+ for (const field of definitions) {
33693
+ if (field.initializer !== null) {
33694
+ body.push(variable(meta.className).prop(field.name).set(field.initializer).toStmt());
33695
+ for (const stmt of field.statements) {
33696
+ body.push(stmt);
33697
+ }
33698
+ }
33699
+ }
33700
+ return new DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, StmtModifier.Final);
33701
+ }
33702
+
33703
+ /**
33704
+ * @module
33705
+ * @description
33706
+ * Entry point for all public APIs of the compiler package.
33707
+ */
33708
+ const VERSION = new Version('20.0.0-next.0');
33709
+
33623
33710
  //////////////////////////////////////
33624
33711
  // This file only reexports content of the `src` folder. Keep it that way.
33625
33712
  // This function call has a global side effects and publishes the compiler into global namespace for
@@ -33637,5 +33724,5 @@ publishFacade(_global);
33637
33724
 
33638
33725
  // This file is not used to build this module. It is only used during editing
33639
33726
 
33640
- export { AST, ASTWithName, ASTWithSource, AbsoluteSourceSpan, ArrayType, ArrowFunctionExpr, Attribute, Binary, BinaryOperator, BinaryOperatorExpr, BindingPipe, BindingType, Block, BlockParameter, BoundElementProperty, BuiltinType, BuiltinTypeName, CUSTOM_ELEMENTS_SCHEMA, Call, Chain, ChangeDetectionStrategy, CommaExpr, Comment, CompilerConfig, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget$1 as FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead, KeyedWrite, LeadingComment, LetDeclaration, Lexer, LiteralArray, LiteralArrayExpr, LiteralExpr, LiteralMap, LiteralMapExpr, LiteralPrimitive, LocalizedString, MapType, MessageBundle, NONE_TYPE, NO_ERRORS_SCHEMA, NodeWithI18n, NonNullAssert, NotExpr, ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseSpan, ParseTreeResult, ParsedEvent, ParsedEventType, ParsedProperty, ParsedPropertyType, ParsedVariable, Parser, ParserError, PrefixNot, PropertyRead, PropertyWrite, R3BoundTarget, Identifiers as R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, R3TargetBinder, R3TemplateDependencyKind, ReadKeyExpr, ReadPropExpr, ReadVarExpr, RecursiveAstVisitor, RecursiveVisitor, ResourceLoader, ReturnStatement, STRING_TYPE, SafeCall, SafeKeyedRead, SafePropertyRead, SelectorContext, SelectorListContext, SelectorMatcher, Serializer, SplitInterpolation, Statement, StmtModifier, StringToken, StringTokenKind, TagContentType, TaggedTemplateLiteralExpr, TemplateBindingParseResult, TemplateLiteral, TemplateLiteralElement, TemplateLiteralElementExpr, TemplateLiteralExpr, Text, ThisReceiver, BlockNode as TmplAstBlockNode, BoundAttribute as TmplAstBoundAttribute, BoundDeferredTrigger as TmplAstBoundDeferredTrigger, BoundEvent as TmplAstBoundEvent, BoundText as TmplAstBoundText, Content as TmplAstContent, DeferredBlock as TmplAstDeferredBlock, DeferredBlockError as TmplAstDeferredBlockError, DeferredBlockLoading as TmplAstDeferredBlockLoading, DeferredBlockPlaceholder as TmplAstDeferredBlockPlaceholder, DeferredTrigger as TmplAstDeferredTrigger, Element$1 as TmplAstElement, ForLoopBlock as TmplAstForLoopBlock, ForLoopBlockEmpty as TmplAstForLoopBlockEmpty, HoverDeferredTrigger as TmplAstHoverDeferredTrigger, Icu$1 as TmplAstIcu, IdleDeferredTrigger as TmplAstIdleDeferredTrigger, IfBlock as TmplAstIfBlock, IfBlockBranch as TmplAstIfBlockBranch, ImmediateDeferredTrigger as TmplAstImmediateDeferredTrigger, InteractionDeferredTrigger as TmplAstInteractionDeferredTrigger, LetDeclaration$1 as TmplAstLetDeclaration, NeverDeferredTrigger as TmplAstNeverDeferredTrigger, RecursiveVisitor$1 as TmplAstRecursiveVisitor, Reference as TmplAstReference, SwitchBlock as TmplAstSwitchBlock, SwitchBlockCase as TmplAstSwitchBlockCase, Template as TmplAstTemplate, Text$3 as TmplAstText, TextAttribute as TmplAstTextAttribute, TimerDeferredTrigger as TmplAstTimerDeferredTrigger, UnknownBlock as TmplAstUnknownBlock, Variable as TmplAstVariable, ViewportDeferredTrigger as TmplAstViewportDeferredTrigger, Token, TokenType, TransplantedType, TreeError, Type, TypeModifier, TypeofExpr, TypeofExpression, Unary, UnaryOperator, UnaryOperatorExpr, VERSION, VariableBinding, Version, ViewEncapsulation, WrappedNodeExpr, WriteKeyExpr, WritePropExpr, WriteVarExpr, Xliff, Xliff2, Xmb, XmlParser, Xtb, compileClassDebugInfo, compileClassMetadata, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDeferResolverFunction, compileDirectiveFromMetadata, compileFactoryFunction, compileHmrInitializer, compileHmrUpdateCallback, compileInjectable, compileInjector, compileNgModule, compileOpaqueAsyncClassMetadata, compilePipeFromMetadata, computeMsgId, core, createCssSelectorFromNode, createInjectableType, createMayBeForwardRefExpression, devOnlyGuardedExpression, emitDistinctChangesOnlyDefaultValue, encapsulateStyle, findMatchingDirectivesAndPipes, getHtmlTagDefinition, getNsPrefix, getSafePropertyAccessString, identifierName, isNgContainer, isNgContent, isNgTemplate, jsDocComment, leadingComment, literal, literalMap, makeBindingParser, mergeNsAndName, output_ast as outputAst, parseHostBindings, parseTemplate, preserveWhitespacesDefault, publishFacade, r3JitTypeSourceSpan, sanitizeIdentifier, splitNsName, visitAll$1 as tmplAstVisitAll, verifyHostBindings, visitAll };
33727
+ export { AST, ASTWithName, ASTWithSource, AbsoluteSourceSpan, ArrayType, ArrowFunctionExpr, Attribute, Binary, BinaryOperator, BinaryOperatorExpr, BindingPipe, BindingType, Block, BlockParameter, BoundElementProperty, BuiltinType, BuiltinTypeName, CUSTOM_ELEMENTS_SCHEMA, Call, Chain, ChangeDetectionStrategy, CommaExpr, Comment, CompilerConfig, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget$1 as FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead, KeyedWrite, LeadingComment, LetDeclaration, Lexer, LiteralArray, LiteralArrayExpr, LiteralExpr, LiteralMap, LiteralMapExpr, LiteralPrimitive, LocalizedString, MapType, MessageBundle, NONE_TYPE, NO_ERRORS_SCHEMA, NodeWithI18n, NonNullAssert, NotExpr, ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseSpan, ParseTreeResult, ParsedEvent, ParsedEventType, ParsedProperty, ParsedPropertyType, ParsedVariable, Parser, ParserError, PrefixNot, PropertyRead, PropertyWrite, R3BoundTarget, Identifiers as R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, R3TargetBinder, R3TemplateDependencyKind, ReadKeyExpr, ReadPropExpr, ReadVarExpr, RecursiveAstVisitor, RecursiveVisitor, ResourceLoader, ReturnStatement, STRING_TYPE, SafeCall, SafeKeyedRead, SafePropertyRead, SelectorContext, SelectorListContext, SelectorMatcher, Serializer, SplitInterpolation, Statement, StmtModifier, StringToken, StringTokenKind, TagContentType, TaggedTemplateLiteralExpr, TemplateBindingParseResult, TemplateLiteral, TemplateLiteralElement, TemplateLiteralElementExpr, TemplateLiteralExpr, Text, ThisReceiver, BlockNode as TmplAstBlockNode, BoundAttribute as TmplAstBoundAttribute, BoundDeferredTrigger as TmplAstBoundDeferredTrigger, BoundEvent as TmplAstBoundEvent, BoundText as TmplAstBoundText, Content as TmplAstContent, DeferredBlock as TmplAstDeferredBlock, DeferredBlockError as TmplAstDeferredBlockError, DeferredBlockLoading as TmplAstDeferredBlockLoading, DeferredBlockPlaceholder as TmplAstDeferredBlockPlaceholder, DeferredTrigger as TmplAstDeferredTrigger, Element$1 as TmplAstElement, ForLoopBlock as TmplAstForLoopBlock, ForLoopBlockEmpty as TmplAstForLoopBlockEmpty, HoverDeferredTrigger as TmplAstHoverDeferredTrigger, Icu$1 as TmplAstIcu, IdleDeferredTrigger as TmplAstIdleDeferredTrigger, IfBlock as TmplAstIfBlock, IfBlockBranch as TmplAstIfBlockBranch, ImmediateDeferredTrigger as TmplAstImmediateDeferredTrigger, InteractionDeferredTrigger as TmplAstInteractionDeferredTrigger, LetDeclaration$1 as TmplAstLetDeclaration, NeverDeferredTrigger as TmplAstNeverDeferredTrigger, RecursiveVisitor$1 as TmplAstRecursiveVisitor, Reference as TmplAstReference, SwitchBlock as TmplAstSwitchBlock, SwitchBlockCase as TmplAstSwitchBlockCase, Template as TmplAstTemplate, Text$3 as TmplAstText, TextAttribute as TmplAstTextAttribute, TimerDeferredTrigger as TmplAstTimerDeferredTrigger, UnknownBlock as TmplAstUnknownBlock, Variable as TmplAstVariable, ViewportDeferredTrigger as TmplAstViewportDeferredTrigger, Token, TokenType, TransplantedType, TreeError, Type, TypeModifier, TypeofExpr, TypeofExpression, Unary, UnaryOperator, UnaryOperatorExpr, VERSION, VariableBinding, Version, ViewEncapsulation, VoidExpr, VoidExpression, WrappedNodeExpr, WriteKeyExpr, WritePropExpr, WriteVarExpr, Xliff, Xliff2, Xmb, XmlParser, Xtb, compileClassDebugInfo, compileClassMetadata, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDeferResolverFunction, compileDirectiveFromMetadata, compileFactoryFunction, compileHmrInitializer, compileHmrUpdateCallback, compileInjectable, compileInjector, compileNgModule, compileOpaqueAsyncClassMetadata, compilePipeFromMetadata, computeMsgId, core, createCssSelectorFromNode, createInjectableType, createMayBeForwardRefExpression, devOnlyGuardedExpression, emitDistinctChangesOnlyDefaultValue, encapsulateStyle, findMatchingDirectivesAndPipes, getHtmlTagDefinition, getNsPrefix, getSafePropertyAccessString, identifierName, isNgContainer, isNgContent, isNgTemplate, jsDocComment, leadingComment, literal, literalMap, makeBindingParser, mergeNsAndName, output_ast as outputAst, parseHostBindings, parseTemplate, preserveWhitespacesDefault, publishFacade, r3JitTypeSourceSpan, sanitizeIdentifier, splitNsName, visitAll$1 as tmplAstVisitAll, verifyHostBindings, visitAll };
33641
33728
  //# sourceMappingURL=compiler.mjs.map