@angular/compiler 20.0.0-next.0 → 20.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/compiler.mjs +336 -231
- package/fesm2022/compiler.mjs.map +1 -1
- package/index.d.ts +28 -8
- package/package.json +2 -2
package/fesm2022/compiler.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0-next.
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v20.0.0-next.1
|
|
3
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -1001,11 +1001,11 @@ class Expression {
|
|
|
1001
1001
|
and(rhs, sourceSpan) {
|
|
1002
1002
|
return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
|
|
1003
1003
|
}
|
|
1004
|
-
bitwiseOr(rhs, sourceSpan
|
|
1005
|
-
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan
|
|
1004
|
+
bitwiseOr(rhs, sourceSpan) {
|
|
1005
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan);
|
|
1006
1006
|
}
|
|
1007
|
-
bitwiseAnd(rhs, sourceSpan
|
|
1008
|
-
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan
|
|
1007
|
+
bitwiseAnd(rhs, sourceSpan) {
|
|
1008
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan);
|
|
1009
1009
|
}
|
|
1010
1010
|
or(rhs, sourceSpan) {
|
|
1011
1011
|
return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
|
|
@@ -1678,16 +1678,34 @@ class UnaryOperatorExpr extends Expression {
|
|
|
1678
1678
|
return new UnaryOperatorExpr(this.operator, this.expr.clone(), this.type, this.sourceSpan, this.parens);
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
|
+
class ParenthesizedExpr extends Expression {
|
|
1682
|
+
expr;
|
|
1683
|
+
constructor(expr, type, sourceSpan) {
|
|
1684
|
+
super(type, sourceSpan);
|
|
1685
|
+
this.expr = expr;
|
|
1686
|
+
}
|
|
1687
|
+
visitExpression(visitor, context) {
|
|
1688
|
+
return visitor.visitParenthesizedExpr(this, context);
|
|
1689
|
+
}
|
|
1690
|
+
isEquivalent(e) {
|
|
1691
|
+
// TODO: should this ignore paren depth? i.e. is `(1)` equivalent to `1`?
|
|
1692
|
+
return e instanceof ParenthesizedExpr && e.expr.isEquivalent(this.expr);
|
|
1693
|
+
}
|
|
1694
|
+
isConstant() {
|
|
1695
|
+
return this.expr.isConstant();
|
|
1696
|
+
}
|
|
1697
|
+
clone() {
|
|
1698
|
+
return new ParenthesizedExpr(this.expr.clone());
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1681
1701
|
class BinaryOperatorExpr extends Expression {
|
|
1682
1702
|
operator;
|
|
1683
1703
|
rhs;
|
|
1684
|
-
parens;
|
|
1685
1704
|
lhs;
|
|
1686
|
-
constructor(operator, lhs, rhs, type, sourceSpan
|
|
1705
|
+
constructor(operator, lhs, rhs, type, sourceSpan) {
|
|
1687
1706
|
super(type || lhs.type, sourceSpan);
|
|
1688
1707
|
this.operator = operator;
|
|
1689
1708
|
this.rhs = rhs;
|
|
1690
|
-
this.parens = parens;
|
|
1691
1709
|
this.lhs = lhs;
|
|
1692
1710
|
}
|
|
1693
1711
|
isEquivalent(e) {
|
|
@@ -1703,7 +1721,7 @@ class BinaryOperatorExpr extends Expression {
|
|
|
1703
1721
|
return visitor.visitBinaryOperatorExpr(this, context);
|
|
1704
1722
|
}
|
|
1705
1723
|
clone() {
|
|
1706
|
-
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan
|
|
1724
|
+
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan);
|
|
1707
1725
|
}
|
|
1708
1726
|
}
|
|
1709
1727
|
class ReadPropExpr extends Expression {
|
|
@@ -2007,12 +2025,6 @@ class RecursiveAstVisitor$1 {
|
|
|
2007
2025
|
visitWrappedNodeExpr(ast, context) {
|
|
2008
2026
|
return ast;
|
|
2009
2027
|
}
|
|
2010
|
-
visitTypeofExpr(ast, context) {
|
|
2011
|
-
return this.visitExpression(ast, context);
|
|
2012
|
-
}
|
|
2013
|
-
visitVoidExpr(ast, context) {
|
|
2014
|
-
return this.visitExpression(ast, context);
|
|
2015
|
-
}
|
|
2016
2028
|
visitReadVarExpr(ast, context) {
|
|
2017
2029
|
return this.visitExpression(ast, context);
|
|
2018
2030
|
}
|
|
@@ -2090,6 +2102,14 @@ class RecursiveAstVisitor$1 {
|
|
|
2090
2102
|
ast.expr.visitExpression(this, context);
|
|
2091
2103
|
return this.visitExpression(ast, context);
|
|
2092
2104
|
}
|
|
2105
|
+
visitTypeofExpr(ast, context) {
|
|
2106
|
+
ast.expr.visitExpression(this, context);
|
|
2107
|
+
return this.visitExpression(ast, context);
|
|
2108
|
+
}
|
|
2109
|
+
visitVoidExpr(ast, context) {
|
|
2110
|
+
ast.expr.visitExpression(this, context);
|
|
2111
|
+
return this.visitExpression(ast, context);
|
|
2112
|
+
}
|
|
2093
2113
|
visitBinaryOperatorExpr(ast, context) {
|
|
2094
2114
|
ast.lhs.visitExpression(this, context);
|
|
2095
2115
|
ast.rhs.visitExpression(this, context);
|
|
@@ -2124,6 +2144,10 @@ class RecursiveAstVisitor$1 {
|
|
|
2124
2144
|
visitTemplateLiteralElementExpr(ast, context) {
|
|
2125
2145
|
return this.visitExpression(ast, context);
|
|
2126
2146
|
}
|
|
2147
|
+
visitParenthesizedExpr(ast, context) {
|
|
2148
|
+
ast.expr.visitExpression(this, context);
|
|
2149
|
+
return this.visitExpression(ast, context);
|
|
2150
|
+
}
|
|
2127
2151
|
visitAllExpressions(exprs, context) {
|
|
2128
2152
|
exprs.forEach((expr) => expr.visitExpression(this, context));
|
|
2129
2153
|
}
|
|
@@ -2301,6 +2325,7 @@ var output_ast = /*#__PURE__*/Object.freeze({
|
|
|
2301
2325
|
FunctionExpr: FunctionExpr,
|
|
2302
2326
|
ArrowFunctionExpr: ArrowFunctionExpr,
|
|
2303
2327
|
UnaryOperatorExpr: UnaryOperatorExpr,
|
|
2328
|
+
ParenthesizedExpr: ParenthesizedExpr,
|
|
2304
2329
|
BinaryOperatorExpr: BinaryOperatorExpr,
|
|
2305
2330
|
ReadPropExpr: ReadPropExpr,
|
|
2306
2331
|
ReadKeyExpr: ReadKeyExpr,
|
|
@@ -3548,6 +3573,7 @@ class EmitterVisitorContext {
|
|
|
3548
3573
|
}
|
|
3549
3574
|
class AbstractEmitterVisitor {
|
|
3550
3575
|
_escapeDollarInStrings;
|
|
3576
|
+
lastIfCondition = null;
|
|
3551
3577
|
constructor(_escapeDollarInStrings) {
|
|
3552
3578
|
this._escapeDollarInStrings = _escapeDollarInStrings;
|
|
3553
3579
|
}
|
|
@@ -3587,7 +3613,9 @@ class AbstractEmitterVisitor {
|
|
|
3587
3613
|
visitIfStmt(stmt, ctx) {
|
|
3588
3614
|
this.printLeadingComments(stmt, ctx);
|
|
3589
3615
|
ctx.print(stmt, `if (`);
|
|
3616
|
+
this.lastIfCondition = stmt.condition; // We can skip redundant parentheses for the condition.
|
|
3590
3617
|
stmt.condition.visitExpression(this, ctx);
|
|
3618
|
+
this.lastIfCondition = null;
|
|
3591
3619
|
ctx.print(stmt, `) {`);
|
|
3592
3620
|
const hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;
|
|
3593
3621
|
if (stmt.trueCase.length <= 1 && !hasElseCase) {
|
|
@@ -3760,11 +3788,12 @@ class AbstractEmitterVisitor {
|
|
|
3760
3788
|
default:
|
|
3761
3789
|
throw new Error(`Unknown operator ${ast.operator}`);
|
|
3762
3790
|
}
|
|
3763
|
-
|
|
3791
|
+
const parens = ast !== this.lastIfCondition;
|
|
3792
|
+
if (parens)
|
|
3764
3793
|
ctx.print(ast, `(`);
|
|
3765
3794
|
ctx.print(ast, opStr);
|
|
3766
3795
|
ast.expr.visitExpression(this, ctx);
|
|
3767
|
-
if (
|
|
3796
|
+
if (parens)
|
|
3768
3797
|
ctx.print(ast, `)`);
|
|
3769
3798
|
return null;
|
|
3770
3799
|
}
|
|
@@ -3831,12 +3860,13 @@ class AbstractEmitterVisitor {
|
|
|
3831
3860
|
default:
|
|
3832
3861
|
throw new Error(`Unknown operator ${ast.operator}`);
|
|
3833
3862
|
}
|
|
3834
|
-
|
|
3863
|
+
const parens = ast !== this.lastIfCondition;
|
|
3864
|
+
if (parens)
|
|
3835
3865
|
ctx.print(ast, `(`);
|
|
3836
3866
|
ast.lhs.visitExpression(this, ctx);
|
|
3837
3867
|
ctx.print(ast, ` ${opStr} `);
|
|
3838
3868
|
ast.rhs.visitExpression(this, ctx);
|
|
3839
|
-
if (
|
|
3869
|
+
if (parens)
|
|
3840
3870
|
ctx.print(ast, `)`);
|
|
3841
3871
|
return null;
|
|
3842
3872
|
}
|
|
@@ -3874,6 +3904,12 @@ class AbstractEmitterVisitor {
|
|
|
3874
3904
|
ctx.print(ast, ')');
|
|
3875
3905
|
return null;
|
|
3876
3906
|
}
|
|
3907
|
+
visitParenthesizedExpr(ast, ctx) {
|
|
3908
|
+
// We parenthesize everything regardless of an explicit ParenthesizedExpr, so we can just visit
|
|
3909
|
+
// the inner expression.
|
|
3910
|
+
// TODO: Do we *need* to parenthesize everything?
|
|
3911
|
+
ast.expr.visitExpression(this, ctx);
|
|
3912
|
+
}
|
|
3877
3913
|
visitAllExpressions(expressions, ctx, separator) {
|
|
3878
3914
|
this.visitAllObjects((expr) => expr.visitExpression(this, ctx), expressions, ctx, separator);
|
|
3879
3915
|
}
|
|
@@ -3970,7 +4006,7 @@ function guardedExpression(guard, expr) {
|
|
|
3970
4006
|
const guardNotDefined = new BinaryOperatorExpr(BinaryOperator.Identical, new TypeofExpr(guardExpr), literal('undefined'));
|
|
3971
4007
|
const guardUndefinedOrTrue = new BinaryOperatorExpr(BinaryOperator.Or, guardNotDefined, guardExpr,
|
|
3972
4008
|
/* type */ undefined,
|
|
3973
|
-
/* sourceSpan */ undefined
|
|
4009
|
+
/* sourceSpan */ undefined);
|
|
3974
4010
|
return new BinaryOperatorExpr(BinaryOperator.And, guardUndefinedOrTrue, expr);
|
|
3975
4011
|
}
|
|
3976
4012
|
function wrapReference(value) {
|
|
@@ -4563,6 +4599,18 @@ class SafeCall extends AST {
|
|
|
4563
4599
|
return visitor.visitSafeCall(this, context);
|
|
4564
4600
|
}
|
|
4565
4601
|
}
|
|
4602
|
+
class TaggedTemplateLiteral extends AST {
|
|
4603
|
+
tag;
|
|
4604
|
+
template;
|
|
4605
|
+
constructor(span, sourceSpan, tag, template) {
|
|
4606
|
+
super(span, sourceSpan);
|
|
4607
|
+
this.tag = tag;
|
|
4608
|
+
this.template = template;
|
|
4609
|
+
}
|
|
4610
|
+
visit(visitor, context) {
|
|
4611
|
+
return visitor.visitTaggedTemplateLiteral(this, context);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4566
4614
|
class TemplateLiteral extends AST {
|
|
4567
4615
|
elements;
|
|
4568
4616
|
expressions;
|
|
@@ -4747,6 +4795,10 @@ class RecursiveAstVisitor {
|
|
|
4747
4795
|
}
|
|
4748
4796
|
}
|
|
4749
4797
|
visitTemplateLiteralElement(ast, context) { }
|
|
4798
|
+
visitTaggedTemplateLiteral(ast, context) {
|
|
4799
|
+
this.visit(ast.tag, context);
|
|
4800
|
+
this.visit(ast.template, context);
|
|
4801
|
+
}
|
|
4750
4802
|
// This is not part of the AstVisitor interface, just a helper method
|
|
4751
4803
|
visitAll(asts, context) {
|
|
4752
4804
|
for (const ast of asts) {
|
|
@@ -10503,6 +10555,9 @@ function transformExpressionsInExpression(expr, transform, flags) {
|
|
|
10503
10555
|
expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform, flags);
|
|
10504
10556
|
}
|
|
10505
10557
|
}
|
|
10558
|
+
else if (expr instanceof ParenthesizedExpr) {
|
|
10559
|
+
expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);
|
|
10560
|
+
}
|
|
10506
10561
|
else if (expr instanceof ReadVarExpr ||
|
|
10507
10562
|
expr instanceof ExternalExpr ||
|
|
10508
10563
|
expr instanceof LiteralExpr) {
|
|
@@ -11577,6 +11632,33 @@ function assignI18nSlotDependencies(job) {
|
|
|
11577
11632
|
}
|
|
11578
11633
|
}
|
|
11579
11634
|
|
|
11635
|
+
/**
|
|
11636
|
+
* Locates all of the elements defined in a creation block and outputs an op
|
|
11637
|
+
* that will expose their definition location in the DOM.
|
|
11638
|
+
*/
|
|
11639
|
+
function attachSourceLocations(job) {
|
|
11640
|
+
if (!job.enableDebugLocations || job.relativeTemplatePath === null) {
|
|
11641
|
+
return;
|
|
11642
|
+
}
|
|
11643
|
+
for (const unit of job.units) {
|
|
11644
|
+
const locations = [];
|
|
11645
|
+
for (const op of unit.create) {
|
|
11646
|
+
if (op.kind === OpKind.ElementStart || op.kind === OpKind.Element) {
|
|
11647
|
+
const start = op.startSourceSpan.start;
|
|
11648
|
+
locations.push({
|
|
11649
|
+
targetSlot: op.handle,
|
|
11650
|
+
offset: start.offset,
|
|
11651
|
+
line: start.line,
|
|
11652
|
+
column: start.col,
|
|
11653
|
+
});
|
|
11654
|
+
}
|
|
11655
|
+
}
|
|
11656
|
+
if (locations.length > 0) {
|
|
11657
|
+
unit.create.push(createSourceLocationOp(job.relativeTemplatePath, locations));
|
|
11658
|
+
}
|
|
11659
|
+
}
|
|
11660
|
+
}
|
|
11661
|
+
|
|
11580
11662
|
/**
|
|
11581
11663
|
* Gets a map of all elements in the given view by their xref id.
|
|
11582
11664
|
*/
|
|
@@ -12267,29 +12349,6 @@ function convertI18nBindings(job) {
|
|
|
12267
12349
|
}
|
|
12268
12350
|
}
|
|
12269
12351
|
|
|
12270
|
-
/**
|
|
12271
|
-
* Resolve the dependency function of a deferred block.
|
|
12272
|
-
*/
|
|
12273
|
-
function resolveDeferDepsFns(job) {
|
|
12274
|
-
for (const unit of job.units) {
|
|
12275
|
-
for (const op of unit.create) {
|
|
12276
|
-
if (op.kind === OpKind.Defer) {
|
|
12277
|
-
if (op.resolverFn !== null) {
|
|
12278
|
-
continue;
|
|
12279
|
-
}
|
|
12280
|
-
if (op.ownResolverFn !== null) {
|
|
12281
|
-
if (op.handle.slot === null) {
|
|
12282
|
-
throw new Error('AssertionError: slot must be assigned before extracting defer deps functions');
|
|
12283
|
-
}
|
|
12284
|
-
const fullPathName = unit.fnName?.replace('_Template', '');
|
|
12285
|
-
op.resolverFn = job.pool.getSharedFunctionReference(op.ownResolverFn, `${fullPathName}_Defer_${op.handle.slot}_DepsFn`,
|
|
12286
|
-
/* Don't use unique names for TDB compatibility */ false);
|
|
12287
|
-
}
|
|
12288
|
-
}
|
|
12289
|
-
}
|
|
12290
|
-
}
|
|
12291
|
-
}
|
|
12292
|
-
|
|
12293
12352
|
/**
|
|
12294
12353
|
* Create one helper context op per i18n block (including generate descending blocks).
|
|
12295
12354
|
*
|
|
@@ -13037,6 +13096,27 @@ function generateAdvance(job) {
|
|
|
13037
13096
|
}
|
|
13038
13097
|
}
|
|
13039
13098
|
|
|
13099
|
+
/**
|
|
13100
|
+
* Replaces the `storeLet` ops with variables that can be
|
|
13101
|
+
* used to reference the value within the same view.
|
|
13102
|
+
*/
|
|
13103
|
+
function generateLocalLetReferences(job) {
|
|
13104
|
+
for (const unit of job.units) {
|
|
13105
|
+
for (const op of unit.update) {
|
|
13106
|
+
if (op.kind !== OpKind.StoreLet) {
|
|
13107
|
+
continue;
|
|
13108
|
+
}
|
|
13109
|
+
const variable = {
|
|
13110
|
+
kind: SemanticVariableKind.Identifier,
|
|
13111
|
+
name: null,
|
|
13112
|
+
identifier: op.declaredName,
|
|
13113
|
+
local: true,
|
|
13114
|
+
};
|
|
13115
|
+
OpList.replace(op, createVariableOp(job.allocateXrefId(), variable, new StoreLetExpr(op.target, op.value, op.sourceSpan), VariableFlags.None));
|
|
13116
|
+
}
|
|
13117
|
+
}
|
|
13118
|
+
}
|
|
13119
|
+
|
|
13040
13120
|
/**
|
|
13041
13121
|
* Locate projection slots, populate the each component's `ngContentSelectors` literal field,
|
|
13042
13122
|
* populate `project` arguments, and generate the required `projectionDef` instruction for the job's
|
|
@@ -18869,7 +18949,7 @@ class _ParseAST {
|
|
|
18869
18949
|
this.error('Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence');
|
|
18870
18950
|
}
|
|
18871
18951
|
this.advance();
|
|
18872
|
-
const right = this.
|
|
18952
|
+
const right = this.parseExponentiation();
|
|
18873
18953
|
result = new Binary(this.span(start), this.sourceSpan(start), '**', result, right);
|
|
18874
18954
|
}
|
|
18875
18955
|
return result;
|
|
@@ -18934,6 +19014,12 @@ class _ParseAST {
|
|
|
18934
19014
|
else if (this.consumeOptionalOperator('!')) {
|
|
18935
19015
|
result = new NonNullAssert(this.span(start), this.sourceSpan(start), result);
|
|
18936
19016
|
}
|
|
19017
|
+
else if (this.next.isTemplateLiteralEnd()) {
|
|
19018
|
+
result = this.parseNoInterpolationTaggedTemplateLiteral(result, start);
|
|
19019
|
+
}
|
|
19020
|
+
else if (this.next.isTemplateLiteralPart()) {
|
|
19021
|
+
result = this.parseTaggedTemplateLiteral(result, start);
|
|
19022
|
+
}
|
|
18937
19023
|
else {
|
|
18938
19024
|
return result;
|
|
18939
19025
|
}
|
|
@@ -18988,7 +19074,7 @@ class _ParseAST {
|
|
|
18988
19074
|
return new LiteralPrimitive(this.span(start), this.sourceSpan(start), value);
|
|
18989
19075
|
}
|
|
18990
19076
|
else if (this.next.isTemplateLiteralEnd()) {
|
|
18991
|
-
return this.parseNoInterpolationTemplateLiteral(
|
|
19077
|
+
return this.parseNoInterpolationTemplateLiteral();
|
|
18992
19078
|
}
|
|
18993
19079
|
else if (this.next.isTemplateLiteralPart()) {
|
|
18994
19080
|
return this.parseTemplateLiteral();
|
|
@@ -19318,17 +19404,25 @@ class _ParseAST {
|
|
|
19318
19404
|
const sourceSpan = new AbsoluteSourceSpan(spanStart, this.currentAbsoluteOffset);
|
|
19319
19405
|
return new VariableBinding(sourceSpan, key, value);
|
|
19320
19406
|
}
|
|
19321
|
-
|
|
19407
|
+
parseNoInterpolationTaggedTemplateLiteral(tag, start) {
|
|
19408
|
+
const template = this.parseNoInterpolationTemplateLiteral();
|
|
19409
|
+
return new TaggedTemplateLiteral(this.span(start), this.sourceSpan(start), tag, template);
|
|
19410
|
+
}
|
|
19411
|
+
parseNoInterpolationTemplateLiteral() {
|
|
19322
19412
|
const text = this.next.strValue;
|
|
19323
19413
|
this.advance();
|
|
19324
|
-
const span = this.span(
|
|
19325
|
-
const sourceSpan = this.sourceSpan(
|
|
19414
|
+
const span = this.span(this.inputIndex);
|
|
19415
|
+
const sourceSpan = this.sourceSpan(this.inputIndex);
|
|
19326
19416
|
return new TemplateLiteral(span, sourceSpan, [new TemplateLiteralElement(span, sourceSpan, text)], []);
|
|
19327
19417
|
}
|
|
19418
|
+
parseTaggedTemplateLiteral(tag, start) {
|
|
19419
|
+
const template = this.parseTemplateLiteral();
|
|
19420
|
+
return new TaggedTemplateLiteral(this.span(start), this.sourceSpan(start), tag, template);
|
|
19421
|
+
}
|
|
19328
19422
|
parseTemplateLiteral() {
|
|
19329
|
-
const start = this.inputIndex;
|
|
19330
19423
|
const elements = [];
|
|
19331
19424
|
const expressions = [];
|
|
19425
|
+
const start = this.inputIndex;
|
|
19332
19426
|
while (this.next !== EOF) {
|
|
19333
19427
|
const token = this.next;
|
|
19334
19428
|
if (token.isTemplateLiteralPart() || token.isTemplateLiteralEnd()) {
|
|
@@ -19589,6 +19683,9 @@ class SerializeExpressionVisitor {
|
|
|
19589
19683
|
visitTemplateLiteralElement(ast, context) {
|
|
19590
19684
|
return ast.text;
|
|
19591
19685
|
}
|
|
19686
|
+
visitTaggedTemplateLiteral(ast, context) {
|
|
19687
|
+
return ast.tag.visit(this, context) + ast.template.visit(this, context);
|
|
19688
|
+
}
|
|
19592
19689
|
}
|
|
19593
19690
|
/** Zips the two input arrays into a single array of pairs of elements at the same index. */
|
|
19594
19691
|
function zip(left, right) {
|
|
@@ -22138,30 +22235,6 @@ function disableBindings$1(job) {
|
|
|
22138
22235
|
}
|
|
22139
22236
|
}
|
|
22140
22237
|
|
|
22141
|
-
/**
|
|
22142
|
-
* Nullish coalescing expressions such as `a ?? b` have different semantics in Angular templates as
|
|
22143
|
-
* compared to JavaScript. In particular, they default to `null` instead of `undefined`. Therefore,
|
|
22144
|
-
* we replace them with ternary expressions, assigning temporaries as needed to avoid re-evaluating
|
|
22145
|
-
* the same sub-expression multiple times.
|
|
22146
|
-
*/
|
|
22147
|
-
function generateNullishCoalesceExpressions(job) {
|
|
22148
|
-
for (const unit of job.units) {
|
|
22149
|
-
for (const op of unit.ops()) {
|
|
22150
|
-
transformExpressionsInOp(op, (expr) => {
|
|
22151
|
-
if (!(expr instanceof BinaryOperatorExpr) ||
|
|
22152
|
-
expr.operator !== BinaryOperator.NullishCoalesce) {
|
|
22153
|
-
return expr;
|
|
22154
|
-
}
|
|
22155
|
-
const assignment = new AssignTemporaryExpr(expr.lhs.clone(), job.allocateXrefId());
|
|
22156
|
-
const read = new ReadTemporaryExpr(assignment.xref);
|
|
22157
|
-
// TODO: When not in compatibility mode for TemplateDefinitionBuilder, we can just emit
|
|
22158
|
-
// `t != null` instead of including an undefined check as well.
|
|
22159
|
-
return new ConditionalExpr(new BinaryOperatorExpr(BinaryOperator.And, new BinaryOperatorExpr(BinaryOperator.NotIdentical, assignment, NULL_EXPR), new BinaryOperatorExpr(BinaryOperator.NotIdentical, read, new LiteralExpr(undefined))), read.clone(), expr.rhs);
|
|
22160
|
-
}, VisitorContextFlag.None);
|
|
22161
|
-
}
|
|
22162
|
-
}
|
|
22163
|
-
}
|
|
22164
|
-
|
|
22165
22238
|
function kindTest(kind) {
|
|
22166
22239
|
return (op) => op.kind === kind;
|
|
22167
22240
|
}
|
|
@@ -23705,6 +23778,33 @@ function removeI18nContexts(job) {
|
|
|
23705
23778
|
}
|
|
23706
23779
|
}
|
|
23707
23780
|
|
|
23781
|
+
/**
|
|
23782
|
+
* It's not allowed to access a `@let` declaration before it has been defined. This is enforced
|
|
23783
|
+
* already via template type checking, however it can trip some of the assertions in the pipeline.
|
|
23784
|
+
* E.g. the naming phase can fail because we resolved the variable here, but the variable doesn't
|
|
23785
|
+
* exist anymore because the optimization phase removed it since it's invalid. To avoid surfacing
|
|
23786
|
+
* confusing errors to users in the case where template type checking isn't running (e.g. in JIT
|
|
23787
|
+
* mode) this phase detects illegal forward references and replaces them with `undefined`.
|
|
23788
|
+
* Eventually users will see the proper error from the template type checker.
|
|
23789
|
+
*/
|
|
23790
|
+
function removeIllegalLetReferences(job) {
|
|
23791
|
+
for (const unit of job.units) {
|
|
23792
|
+
for (const op of unit.update) {
|
|
23793
|
+
if (op.kind !== OpKind.Variable ||
|
|
23794
|
+
op.variable.kind !== SemanticVariableKind.Identifier ||
|
|
23795
|
+
!(op.initializer instanceof StoreLetExpr)) {
|
|
23796
|
+
continue;
|
|
23797
|
+
}
|
|
23798
|
+
const name = op.variable.identifier;
|
|
23799
|
+
let current = op;
|
|
23800
|
+
while (current && current.kind !== OpKind.ListEnd) {
|
|
23801
|
+
transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal(undefined) : expr, VisitorContextFlag.None);
|
|
23802
|
+
current = current.prev;
|
|
23803
|
+
}
|
|
23804
|
+
}
|
|
23805
|
+
}
|
|
23806
|
+
}
|
|
23807
|
+
|
|
23708
23808
|
/**
|
|
23709
23809
|
* i18nAttributes ops will be generated for each i18n attribute. However, not all i18n attribues
|
|
23710
23810
|
* will contain dynamic content, and so some of these i18nAttributes ops may be unnecessary.
|
|
@@ -23730,6 +23830,57 @@ function removeUnusedI18nAttributesOps(job) {
|
|
|
23730
23830
|
}
|
|
23731
23831
|
}
|
|
23732
23832
|
|
|
23833
|
+
// TODO: create AST for parentheses when parsing, then we can remove the unnecessary ones instead of
|
|
23834
|
+
// adding them out of thin air. This should simplify the parsing and give us valid spans for the
|
|
23835
|
+
// parentheses.
|
|
23836
|
+
/**
|
|
23837
|
+
* In some cases we need to add parentheses to expressions for them to be considered valid
|
|
23838
|
+
* JavaScript. This phase adds parentheses to cover such cases. Currently these cases are:
|
|
23839
|
+
*
|
|
23840
|
+
* 1. Unary operators in the base of an exponentiation expression. For example, `-2 ** 3` is not
|
|
23841
|
+
* valid JavaScript, but `(-2) ** 3` is.
|
|
23842
|
+
* 2. When mixing nullish coalescing (`??`) and logical and/or operators (`&&`, `||`), we need to
|
|
23843
|
+
* add parentheses. For example, `a ?? b && c` is not valid JavaScript, but `a ?? (b && c)` is.
|
|
23844
|
+
* 3. Safe property access that has been down-leveled into a ternary expression needs parentheses
|
|
23845
|
+
* when used with nullish coalescing.
|
|
23846
|
+
*/
|
|
23847
|
+
function requiredParentheses(job) {
|
|
23848
|
+
for (const unit of job.units) {
|
|
23849
|
+
for (const op of unit.ops()) {
|
|
23850
|
+
transformExpressionsInOp(op, (expr) => {
|
|
23851
|
+
if (expr instanceof BinaryOperatorExpr) {
|
|
23852
|
+
switch (expr.operator) {
|
|
23853
|
+
case BinaryOperator.Exponentiation:
|
|
23854
|
+
parenthesizeExponentiation(expr);
|
|
23855
|
+
break;
|
|
23856
|
+
case BinaryOperator.NullishCoalesce:
|
|
23857
|
+
parenthesizeNullishCoalescing(expr);
|
|
23858
|
+
break;
|
|
23859
|
+
}
|
|
23860
|
+
}
|
|
23861
|
+
return expr;
|
|
23862
|
+
}, VisitorContextFlag.None);
|
|
23863
|
+
}
|
|
23864
|
+
}
|
|
23865
|
+
}
|
|
23866
|
+
function parenthesizeExponentiation(expr) {
|
|
23867
|
+
if (expr.lhs instanceof UnaryOperatorExpr) {
|
|
23868
|
+
expr.lhs = new ParenthesizedExpr(expr.lhs);
|
|
23869
|
+
}
|
|
23870
|
+
}
|
|
23871
|
+
function parenthesizeNullishCoalescing(expr) {
|
|
23872
|
+
if (isLogicalAndOr(expr.lhs) || expr.lhs instanceof ConditionalExpr) {
|
|
23873
|
+
expr.lhs = new ParenthesizedExpr(expr.lhs);
|
|
23874
|
+
}
|
|
23875
|
+
if (isLogicalAndOr(expr.rhs) || expr.rhs instanceof ConditionalExpr) {
|
|
23876
|
+
expr.rhs = new ParenthesizedExpr(expr.rhs);
|
|
23877
|
+
}
|
|
23878
|
+
}
|
|
23879
|
+
function isLogicalAndOr(expr) {
|
|
23880
|
+
return (expr instanceof BinaryOperatorExpr &&
|
|
23881
|
+
(expr.operator === BinaryOperator.And || expr.operator === BinaryOperator.Or));
|
|
23882
|
+
}
|
|
23883
|
+
|
|
23733
23884
|
/**
|
|
23734
23885
|
* Resolves `ir.ContextExpr` expressions (which represent embedded view or component contexts) to
|
|
23735
23886
|
* either the `ctx` parameter to component functions (for the current view context) or to variables
|
|
@@ -23786,6 +23937,29 @@ function processLexicalScope$1(view, ops) {
|
|
|
23786
23937
|
}
|
|
23787
23938
|
}
|
|
23788
23939
|
|
|
23940
|
+
/**
|
|
23941
|
+
* Resolve the dependency function of a deferred block.
|
|
23942
|
+
*/
|
|
23943
|
+
function resolveDeferDepsFns(job) {
|
|
23944
|
+
for (const unit of job.units) {
|
|
23945
|
+
for (const op of unit.create) {
|
|
23946
|
+
if (op.kind === OpKind.Defer) {
|
|
23947
|
+
if (op.resolverFn !== null) {
|
|
23948
|
+
continue;
|
|
23949
|
+
}
|
|
23950
|
+
if (op.ownResolverFn !== null) {
|
|
23951
|
+
if (op.handle.slot === null) {
|
|
23952
|
+
throw new Error('AssertionError: slot must be assigned before extracting defer deps functions');
|
|
23953
|
+
}
|
|
23954
|
+
const fullPathName = unit.fnName?.replace('_Template', '');
|
|
23955
|
+
op.resolverFn = job.pool.getSharedFunctionReference(op.ownResolverFn, `${fullPathName}_Defer_${op.handle.slot}_DepsFn`,
|
|
23956
|
+
/* Don't use unique names for TDB compatibility */ false);
|
|
23957
|
+
}
|
|
23958
|
+
}
|
|
23959
|
+
}
|
|
23960
|
+
}
|
|
23961
|
+
}
|
|
23962
|
+
|
|
23789
23963
|
/**
|
|
23790
23964
|
* Any variable inside a listener with the name `$event` will be transformed into a output lexical
|
|
23791
23965
|
* read immediately, and does not participate in any of the normal logic for handling variables.
|
|
@@ -24362,39 +24536,6 @@ function getOnlySecurityContext(securityContext) {
|
|
|
24362
24536
|
return securityContext;
|
|
24363
24537
|
}
|
|
24364
24538
|
|
|
24365
|
-
/**
|
|
24366
|
-
* Transforms a `TwoWayBindingSet` expression into an expression that either
|
|
24367
|
-
* sets a value through the `twoWayBindingSet` instruction or falls back to setting
|
|
24368
|
-
* the value directly. E.g. the expression `TwoWayBindingSet(target, value)` becomes:
|
|
24369
|
-
* `ng.twoWayBindingSet(target, value) || (target = value)`.
|
|
24370
|
-
*/
|
|
24371
|
-
function transformTwoWayBindingSet(job) {
|
|
24372
|
-
for (const unit of job.units) {
|
|
24373
|
-
for (const op of unit.create) {
|
|
24374
|
-
if (op.kind === OpKind.TwoWayListener) {
|
|
24375
|
-
transformExpressionsInOp(op, (expr) => {
|
|
24376
|
-
if (!(expr instanceof TwoWayBindingSetExpr)) {
|
|
24377
|
-
return expr;
|
|
24378
|
-
}
|
|
24379
|
-
const { target, value } = expr;
|
|
24380
|
-
if (target instanceof ReadPropExpr || target instanceof ReadKeyExpr) {
|
|
24381
|
-
return twoWayBindingSet(target, value).or(target.set(value));
|
|
24382
|
-
}
|
|
24383
|
-
// ASSUMPTION: here we're assuming that `ReadVariableExpr` will be a reference
|
|
24384
|
-
// to a local template variable. This appears to be the case at the time of writing.
|
|
24385
|
-
// If the expression is targeting a variable read, we only emit the `twoWayBindingSet`
|
|
24386
|
-
// since the fallback would be attempting to write into a constant. Invalid usages will be
|
|
24387
|
-
// flagged during template type checking.
|
|
24388
|
-
if (target instanceof ReadVariableExpr) {
|
|
24389
|
-
return twoWayBindingSet(target, value);
|
|
24390
|
-
}
|
|
24391
|
-
throw new Error(`Unsupported expression in two-way action binding.`);
|
|
24392
|
-
}, VisitorContextFlag.InChildOperation);
|
|
24393
|
-
}
|
|
24394
|
-
}
|
|
24395
|
-
}
|
|
24396
|
-
}
|
|
24397
|
-
|
|
24398
24539
|
/**
|
|
24399
24540
|
* When inside of a listener, we may need access to one or more enclosing views. Therefore, each
|
|
24400
24541
|
* view should save the current view, and each listener must have the ability to restore the
|
|
@@ -24504,6 +24645,40 @@ function allocateSlots(job) {
|
|
|
24504
24645
|
}
|
|
24505
24646
|
}
|
|
24506
24647
|
|
|
24648
|
+
/*!
|
|
24649
|
+
* @license
|
|
24650
|
+
* Copyright Google LLC All Rights Reserved.
|
|
24651
|
+
*
|
|
24652
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
24653
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
24654
|
+
*/
|
|
24655
|
+
/**
|
|
24656
|
+
* Removes any `storeLet` calls that aren't referenced outside of the current view.
|
|
24657
|
+
*/
|
|
24658
|
+
function optimizeStoreLet(job) {
|
|
24659
|
+
const letUsedExternally = new Set();
|
|
24660
|
+
// Since `@let` declarations can be referenced in child views, both in
|
|
24661
|
+
// the creation block (via listeners) and in the update block, we have
|
|
24662
|
+
// to look through all the ops to find the references.
|
|
24663
|
+
for (const unit of job.units) {
|
|
24664
|
+
for (const op of unit.ops()) {
|
|
24665
|
+
visitExpressionsInOp(op, (expr) => {
|
|
24666
|
+
if (expr instanceof ContextLetReferenceExpr) {
|
|
24667
|
+
letUsedExternally.add(expr.target);
|
|
24668
|
+
}
|
|
24669
|
+
});
|
|
24670
|
+
}
|
|
24671
|
+
}
|
|
24672
|
+
// TODO(crisbeto): potentially remove the unused calls completely, pending discussion.
|
|
24673
|
+
for (const unit of job.units) {
|
|
24674
|
+
for (const op of unit.update) {
|
|
24675
|
+
transformExpressionsInOp(op, (expression) => expression instanceof StoreLetExpr && !letUsedExternally.has(expression.target)
|
|
24676
|
+
? expression.value
|
|
24677
|
+
: expression, VisitorContextFlag.None);
|
|
24678
|
+
}
|
|
24679
|
+
}
|
|
24680
|
+
}
|
|
24681
|
+
|
|
24507
24682
|
/**
|
|
24508
24683
|
* Transforms special-case bindings with 'style' or 'class' in their names. Must run before the
|
|
24509
24684
|
* main binding specialization pass.
|
|
@@ -24731,6 +24906,39 @@ function generateTrackVariables(job) {
|
|
|
24731
24906
|
}
|
|
24732
24907
|
}
|
|
24733
24908
|
|
|
24909
|
+
/**
|
|
24910
|
+
* Transforms a `TwoWayBindingSet` expression into an expression that either
|
|
24911
|
+
* sets a value through the `twoWayBindingSet` instruction or falls back to setting
|
|
24912
|
+
* the value directly. E.g. the expression `TwoWayBindingSet(target, value)` becomes:
|
|
24913
|
+
* `ng.twoWayBindingSet(target, value) || (target = value)`.
|
|
24914
|
+
*/
|
|
24915
|
+
function transformTwoWayBindingSet(job) {
|
|
24916
|
+
for (const unit of job.units) {
|
|
24917
|
+
for (const op of unit.create) {
|
|
24918
|
+
if (op.kind === OpKind.TwoWayListener) {
|
|
24919
|
+
transformExpressionsInOp(op, (expr) => {
|
|
24920
|
+
if (!(expr instanceof TwoWayBindingSetExpr)) {
|
|
24921
|
+
return expr;
|
|
24922
|
+
}
|
|
24923
|
+
const { target, value } = expr;
|
|
24924
|
+
if (target instanceof ReadPropExpr || target instanceof ReadKeyExpr) {
|
|
24925
|
+
return twoWayBindingSet(target, value).or(target.set(value));
|
|
24926
|
+
}
|
|
24927
|
+
// ASSUMPTION: here we're assuming that `ReadVariableExpr` will be a reference
|
|
24928
|
+
// to a local template variable. This appears to be the case at the time of writing.
|
|
24929
|
+
// If the expression is targeting a variable read, we only emit the `twoWayBindingSet`
|
|
24930
|
+
// since the fallback would be attempting to write into a constant. Invalid usages will be
|
|
24931
|
+
// flagged during template type checking.
|
|
24932
|
+
if (target instanceof ReadVariableExpr) {
|
|
24933
|
+
return twoWayBindingSet(target, value);
|
|
24934
|
+
}
|
|
24935
|
+
throw new Error(`Unsupported expression in two-way action binding.`);
|
|
24936
|
+
}, VisitorContextFlag.InChildOperation);
|
|
24937
|
+
}
|
|
24938
|
+
}
|
|
24939
|
+
}
|
|
24940
|
+
}
|
|
24941
|
+
|
|
24734
24942
|
/**
|
|
24735
24943
|
* Counts the number of variable slots used within each view, and stores that on the view itself, as
|
|
24736
24944
|
* well as propagates it to the `ir.TemplateOp` for embedded views.
|
|
@@ -25330,115 +25538,6 @@ function wrapI18nIcus(job) {
|
|
|
25330
25538
|
}
|
|
25331
25539
|
}
|
|
25332
25540
|
|
|
25333
|
-
/*!
|
|
25334
|
-
* @license
|
|
25335
|
-
* Copyright Google LLC All Rights Reserved.
|
|
25336
|
-
*
|
|
25337
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
25338
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
25339
|
-
*/
|
|
25340
|
-
/**
|
|
25341
|
-
* Removes any `storeLet` calls that aren't referenced outside of the current view.
|
|
25342
|
-
*/
|
|
25343
|
-
function optimizeStoreLet(job) {
|
|
25344
|
-
const letUsedExternally = new Set();
|
|
25345
|
-
// Since `@let` declarations can be referenced in child views, both in
|
|
25346
|
-
// the creation block (via listeners) and in the update block, we have
|
|
25347
|
-
// to look through all the ops to find the references.
|
|
25348
|
-
for (const unit of job.units) {
|
|
25349
|
-
for (const op of unit.ops()) {
|
|
25350
|
-
visitExpressionsInOp(op, (expr) => {
|
|
25351
|
-
if (expr instanceof ContextLetReferenceExpr) {
|
|
25352
|
-
letUsedExternally.add(expr.target);
|
|
25353
|
-
}
|
|
25354
|
-
});
|
|
25355
|
-
}
|
|
25356
|
-
}
|
|
25357
|
-
// TODO(crisbeto): potentially remove the unused calls completely, pending discussion.
|
|
25358
|
-
for (const unit of job.units) {
|
|
25359
|
-
for (const op of unit.update) {
|
|
25360
|
-
transformExpressionsInOp(op, (expression) => expression instanceof StoreLetExpr && !letUsedExternally.has(expression.target)
|
|
25361
|
-
? expression.value
|
|
25362
|
-
: expression, VisitorContextFlag.None);
|
|
25363
|
-
}
|
|
25364
|
-
}
|
|
25365
|
-
}
|
|
25366
|
-
|
|
25367
|
-
/**
|
|
25368
|
-
* It's not allowed to access a `@let` declaration before it has been defined. This is enforced
|
|
25369
|
-
* already via template type checking, however it can trip some of the assertions in the pipeline.
|
|
25370
|
-
* E.g. the naming phase can fail because we resolved the variable here, but the variable doesn't
|
|
25371
|
-
* exist anymore because the optimization phase removed it since it's invalid. To avoid surfacing
|
|
25372
|
-
* confusing errors to users in the case where template type checking isn't running (e.g. in JIT
|
|
25373
|
-
* mode) this phase detects illegal forward references and replaces them with `undefined`.
|
|
25374
|
-
* Eventually users will see the proper error from the template type checker.
|
|
25375
|
-
*/
|
|
25376
|
-
function removeIllegalLetReferences(job) {
|
|
25377
|
-
for (const unit of job.units) {
|
|
25378
|
-
for (const op of unit.update) {
|
|
25379
|
-
if (op.kind !== OpKind.Variable ||
|
|
25380
|
-
op.variable.kind !== SemanticVariableKind.Identifier ||
|
|
25381
|
-
!(op.initializer instanceof StoreLetExpr)) {
|
|
25382
|
-
continue;
|
|
25383
|
-
}
|
|
25384
|
-
const name = op.variable.identifier;
|
|
25385
|
-
let current = op;
|
|
25386
|
-
while (current && current.kind !== OpKind.ListEnd) {
|
|
25387
|
-
transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal(undefined) : expr, VisitorContextFlag.None);
|
|
25388
|
-
current = current.prev;
|
|
25389
|
-
}
|
|
25390
|
-
}
|
|
25391
|
-
}
|
|
25392
|
-
}
|
|
25393
|
-
|
|
25394
|
-
/**
|
|
25395
|
-
* Replaces the `storeLet` ops with variables that can be
|
|
25396
|
-
* used to reference the value within the same view.
|
|
25397
|
-
*/
|
|
25398
|
-
function generateLocalLetReferences(job) {
|
|
25399
|
-
for (const unit of job.units) {
|
|
25400
|
-
for (const op of unit.update) {
|
|
25401
|
-
if (op.kind !== OpKind.StoreLet) {
|
|
25402
|
-
continue;
|
|
25403
|
-
}
|
|
25404
|
-
const variable = {
|
|
25405
|
-
kind: SemanticVariableKind.Identifier,
|
|
25406
|
-
name: null,
|
|
25407
|
-
identifier: op.declaredName,
|
|
25408
|
-
local: true,
|
|
25409
|
-
};
|
|
25410
|
-
OpList.replace(op, createVariableOp(job.allocateXrefId(), variable, new StoreLetExpr(op.target, op.value, op.sourceSpan), VariableFlags.None));
|
|
25411
|
-
}
|
|
25412
|
-
}
|
|
25413
|
-
}
|
|
25414
|
-
|
|
25415
|
-
/**
|
|
25416
|
-
* Locates all of the elements defined in a creation block and outputs an op
|
|
25417
|
-
* that will expose their definition location in the DOM.
|
|
25418
|
-
*/
|
|
25419
|
-
function attachSourceLocations(job) {
|
|
25420
|
-
if (!job.enableDebugLocations || job.relativeTemplatePath === null) {
|
|
25421
|
-
return;
|
|
25422
|
-
}
|
|
25423
|
-
for (const unit of job.units) {
|
|
25424
|
-
const locations = [];
|
|
25425
|
-
for (const op of unit.create) {
|
|
25426
|
-
if (op.kind === OpKind.ElementStart || op.kind === OpKind.Element) {
|
|
25427
|
-
const start = op.startSourceSpan.start;
|
|
25428
|
-
locations.push({
|
|
25429
|
-
targetSlot: op.handle,
|
|
25430
|
-
offset: start.offset,
|
|
25431
|
-
line: start.line,
|
|
25432
|
-
column: start.col,
|
|
25433
|
-
});
|
|
25434
|
-
}
|
|
25435
|
-
}
|
|
25436
|
-
if (locations.length > 0) {
|
|
25437
|
-
unit.create.push(createSourceLocationOp(job.relativeTemplatePath, locations));
|
|
25438
|
-
}
|
|
25439
|
-
}
|
|
25440
|
-
}
|
|
25441
|
-
|
|
25442
25541
|
/**
|
|
25443
25542
|
*
|
|
25444
25543
|
* @license
|
|
@@ -25487,8 +25586,8 @@ const phases = [
|
|
|
25487
25586
|
{ kind: CompilationJobKind.Both, fn: resolveContexts },
|
|
25488
25587
|
{ kind: CompilationJobKind.Both, fn: resolveSanitizers },
|
|
25489
25588
|
{ kind: CompilationJobKind.Tmpl, fn: liftLocalRefs },
|
|
25490
|
-
{ kind: CompilationJobKind.Both, fn: generateNullishCoalesceExpressions },
|
|
25491
25589
|
{ kind: CompilationJobKind.Both, fn: expandSafeReads },
|
|
25590
|
+
{ kind: CompilationJobKind.Both, fn: requiredParentheses },
|
|
25492
25591
|
{ kind: CompilationJobKind.Both, fn: generateTemporaryVariables },
|
|
25493
25592
|
{ kind: CompilationJobKind.Both, fn: optimizeVariables },
|
|
25494
25593
|
{ kind: CompilationJobKind.Both, fn: optimizeStoreLet },
|
|
@@ -26282,14 +26381,20 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
26282
26381
|
return new VoidExpr(convertAst(ast.expression, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26283
26382
|
}
|
|
26284
26383
|
else if (ast instanceof TemplateLiteral) {
|
|
26285
|
-
return
|
|
26286
|
-
|
|
26287
|
-
|
|
26384
|
+
return convertTemplateLiteral(ast, job, baseSourceSpan);
|
|
26385
|
+
}
|
|
26386
|
+
else if (ast instanceof TaggedTemplateLiteral) {
|
|
26387
|
+
return new TaggedTemplateLiteralExpr(convertAst(ast.tag, job, baseSourceSpan), convertTemplateLiteral(ast.template, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26288
26388
|
}
|
|
26289
26389
|
else {
|
|
26290
26390
|
throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan?.start.file.url}"`);
|
|
26291
26391
|
}
|
|
26292
26392
|
}
|
|
26393
|
+
function convertTemplateLiteral(ast, job, baseSourceSpan) {
|
|
26394
|
+
return new TemplateLiteralExpr(ast.elements.map((el) => {
|
|
26395
|
+
return new TemplateLiteralElementExpr(el.text, convertSourceSpan(el.span, baseSourceSpan));
|
|
26396
|
+
}), ast.expressions.map((expr) => convertAst(expr, job, baseSourceSpan)), convertSourceSpan(ast.span, baseSourceSpan));
|
|
26397
|
+
}
|
|
26293
26398
|
function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
|
|
26294
26399
|
let expression;
|
|
26295
26400
|
if (value instanceof Interpolation$1) {
|
|
@@ -26687,7 +26792,7 @@ function getTemplateSourceLocationsEnabled() {
|
|
|
26687
26792
|
|
|
26688
26793
|
// if (rf & flags) { .. }
|
|
26689
26794
|
function renderFlagCheckIfStmt(flags, statements) {
|
|
26690
|
-
return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null
|
|
26795
|
+
return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null), statements);
|
|
26691
26796
|
}
|
|
26692
26797
|
/**
|
|
26693
26798
|
* Translates query flags into `TQueryFlags` type in
|
|
@@ -32845,7 +32950,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
|
32845
32950
|
function compileDeclareClassMetadata(metadata) {
|
|
32846
32951
|
const definitionMap = new DefinitionMap();
|
|
32847
32952
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
32848
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
32953
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
32849
32954
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32850
32955
|
definitionMap.set('type', metadata.type);
|
|
32851
32956
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -32863,7 +32968,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
|
32863
32968
|
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
|
|
32864
32969
|
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
|
|
32865
32970
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
32866
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
32971
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
32867
32972
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
32868
32973
|
definitionMap.set('type', metadata.type);
|
|
32869
32974
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
@@ -32958,7 +33063,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
32958
33063
|
const definitionMap = new DefinitionMap();
|
|
32959
33064
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
32960
33065
|
definitionMap.set('minVersion', literal(minVersion));
|
|
32961
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33066
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
32962
33067
|
// e.g. `type: MyDirective`
|
|
32963
33068
|
definitionMap.set('type', meta.type.value);
|
|
32964
33069
|
if (meta.isStandalone !== undefined) {
|
|
@@ -33377,7 +33482,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
33377
33482
|
function compileDeclareFactoryFunction(meta) {
|
|
33378
33483
|
const definitionMap = new DefinitionMap();
|
|
33379
33484
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
33380
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33485
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
33381
33486
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33382
33487
|
definitionMap.set('type', meta.type.value);
|
|
33383
33488
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -33412,7 +33517,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
33412
33517
|
function createInjectableDefinitionMap(meta) {
|
|
33413
33518
|
const definitionMap = new DefinitionMap();
|
|
33414
33519
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
33415
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33520
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
33416
33521
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33417
33522
|
definitionMap.set('type', meta.type.value);
|
|
33418
33523
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -33463,7 +33568,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
33463
33568
|
function createInjectorDefinitionMap(meta) {
|
|
33464
33569
|
const definitionMap = new DefinitionMap();
|
|
33465
33570
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
33466
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33571
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
33467
33572
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33468
33573
|
definitionMap.set('type', meta.type.value);
|
|
33469
33574
|
definitionMap.set('providers', meta.providers);
|
|
@@ -33496,7 +33601,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
33496
33601
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
33497
33602
|
}
|
|
33498
33603
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
33499
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33604
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
33500
33605
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33501
33606
|
definitionMap.set('type', meta.type.value);
|
|
33502
33607
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -33547,7 +33652,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
33547
33652
|
function createPipeDefinitionMap(meta) {
|
|
33548
33653
|
const definitionMap = new DefinitionMap();
|
|
33549
33654
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
33550
|
-
definitionMap.set('version', literal('20.0.0-next.
|
|
33655
|
+
definitionMap.set('version', literal('20.0.0-next.1'));
|
|
33551
33656
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33552
33657
|
// e.g. `type: MyPipe`
|
|
33553
33658
|
definitionMap.set('type', meta.type.value);
|
|
@@ -33705,7 +33810,7 @@ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
|
|
|
33705
33810
|
* @description
|
|
33706
33811
|
* Entry point for all public APIs of the compiler package.
|
|
33707
33812
|
*/
|
|
33708
|
-
const VERSION = new Version('20.0.0-next.
|
|
33813
|
+
const VERSION = new Version('20.0.0-next.1');
|
|
33709
33814
|
|
|
33710
33815
|
//////////////////////////////////////
|
|
33711
33816
|
// This file only reexports content of the `src` folder. Keep it that way.
|
|
@@ -33724,5 +33829,5 @@ publishFacade(_global);
|
|
|
33724
33829
|
|
|
33725
33830
|
// This file is not used to build this module. It is only used during editing
|
|
33726
33831
|
|
|
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 };
|
|
33832
|
+
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, ParenthesizedExpr, 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, TaggedTemplateLiteral, 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 };
|
|
33728
33833
|
//# sourceMappingURL=compiler.mjs.map
|