@angular/compiler 20.0.0 → 20.1.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.
- package/fesm2022/compiler.mjs +333 -417
- package/fesm2022/compiler.mjs.map +1 -1
- package/index.d.ts +141 -99
- package/package.json +1 -1
package/fesm2022/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0
|
|
2
|
+
* @license Angular v20.1.0-next.0
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -698,7 +698,7 @@ function fingerprint(str) {
|
|
|
698
698
|
let lo = hash32(view, utf8.length, 102072);
|
|
699
699
|
if (hi == 0 && (lo == 0 || lo == 1)) {
|
|
700
700
|
hi = hi ^ 0x130f9bef;
|
|
701
|
-
lo = lo ^ -
|
|
701
|
+
lo = lo ^ -0x6b5f56d8;
|
|
702
702
|
}
|
|
703
703
|
return (BigInt.asUintN(32, BigInt(hi)) << BigInt(32)) | BigInt.asUintN(32, BigInt(lo));
|
|
704
704
|
}
|
|
@@ -942,24 +942,25 @@ var BinaryOperator;
|
|
|
942
942
|
(function (BinaryOperator) {
|
|
943
943
|
BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals";
|
|
944
944
|
BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals";
|
|
945
|
-
BinaryOperator[BinaryOperator["
|
|
946
|
-
BinaryOperator[BinaryOperator["
|
|
947
|
-
BinaryOperator[BinaryOperator["
|
|
948
|
-
BinaryOperator[BinaryOperator["
|
|
949
|
-
BinaryOperator[BinaryOperator["
|
|
950
|
-
BinaryOperator[BinaryOperator["
|
|
951
|
-
BinaryOperator[BinaryOperator["
|
|
952
|
-
BinaryOperator[BinaryOperator["
|
|
953
|
-
BinaryOperator[BinaryOperator["
|
|
954
|
-
BinaryOperator[BinaryOperator["
|
|
955
|
-
BinaryOperator[BinaryOperator["
|
|
956
|
-
BinaryOperator[BinaryOperator["
|
|
957
|
-
BinaryOperator[BinaryOperator["
|
|
958
|
-
BinaryOperator[BinaryOperator["
|
|
959
|
-
BinaryOperator[BinaryOperator["
|
|
960
|
-
BinaryOperator[BinaryOperator["
|
|
961
|
-
BinaryOperator[BinaryOperator["
|
|
962
|
-
BinaryOperator[BinaryOperator["
|
|
945
|
+
BinaryOperator[BinaryOperator["Assign"] = 2] = "Assign";
|
|
946
|
+
BinaryOperator[BinaryOperator["Identical"] = 3] = "Identical";
|
|
947
|
+
BinaryOperator[BinaryOperator["NotIdentical"] = 4] = "NotIdentical";
|
|
948
|
+
BinaryOperator[BinaryOperator["Minus"] = 5] = "Minus";
|
|
949
|
+
BinaryOperator[BinaryOperator["Plus"] = 6] = "Plus";
|
|
950
|
+
BinaryOperator[BinaryOperator["Divide"] = 7] = "Divide";
|
|
951
|
+
BinaryOperator[BinaryOperator["Multiply"] = 8] = "Multiply";
|
|
952
|
+
BinaryOperator[BinaryOperator["Modulo"] = 9] = "Modulo";
|
|
953
|
+
BinaryOperator[BinaryOperator["And"] = 10] = "And";
|
|
954
|
+
BinaryOperator[BinaryOperator["Or"] = 11] = "Or";
|
|
955
|
+
BinaryOperator[BinaryOperator["BitwiseOr"] = 12] = "BitwiseOr";
|
|
956
|
+
BinaryOperator[BinaryOperator["BitwiseAnd"] = 13] = "BitwiseAnd";
|
|
957
|
+
BinaryOperator[BinaryOperator["Lower"] = 14] = "Lower";
|
|
958
|
+
BinaryOperator[BinaryOperator["LowerEquals"] = 15] = "LowerEquals";
|
|
959
|
+
BinaryOperator[BinaryOperator["Bigger"] = 16] = "Bigger";
|
|
960
|
+
BinaryOperator[BinaryOperator["BiggerEquals"] = 17] = "BiggerEquals";
|
|
961
|
+
BinaryOperator[BinaryOperator["NullishCoalesce"] = 18] = "NullishCoalesce";
|
|
962
|
+
BinaryOperator[BinaryOperator["Exponentiation"] = 19] = "Exponentiation";
|
|
963
|
+
BinaryOperator[BinaryOperator["In"] = 20] = "In";
|
|
963
964
|
})(BinaryOperator || (BinaryOperator = {}));
|
|
964
965
|
function nullSafeIsEquivalent(base, other) {
|
|
965
966
|
if (base == null || other == null) {
|
|
@@ -1089,7 +1090,7 @@ class ReadVarExpr extends Expression {
|
|
|
1089
1090
|
return new ReadVarExpr(this.name, this.type, this.sourceSpan);
|
|
1090
1091
|
}
|
|
1091
1092
|
set(value) {
|
|
1092
|
-
return new
|
|
1093
|
+
return new BinaryOperatorExpr(BinaryOperator.Assign, this, value, null, this.sourceSpan);
|
|
1093
1094
|
}
|
|
1094
1095
|
}
|
|
1095
1096
|
class TypeofExpr extends Expression {
|
|
@@ -1149,85 +1150,6 @@ class WrappedNodeExpr extends Expression {
|
|
|
1149
1150
|
return new WrappedNodeExpr(this.node, this.type, this.sourceSpan);
|
|
1150
1151
|
}
|
|
1151
1152
|
}
|
|
1152
|
-
class WriteVarExpr extends Expression {
|
|
1153
|
-
name;
|
|
1154
|
-
value;
|
|
1155
|
-
constructor(name, value, type, sourceSpan) {
|
|
1156
|
-
super(type || value.type, sourceSpan);
|
|
1157
|
-
this.name = name;
|
|
1158
|
-
this.value = value;
|
|
1159
|
-
}
|
|
1160
|
-
isEquivalent(e) {
|
|
1161
|
-
return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);
|
|
1162
|
-
}
|
|
1163
|
-
isConstant() {
|
|
1164
|
-
return false;
|
|
1165
|
-
}
|
|
1166
|
-
visitExpression(visitor, context) {
|
|
1167
|
-
return visitor.visitWriteVarExpr(this, context);
|
|
1168
|
-
}
|
|
1169
|
-
clone() {
|
|
1170
|
-
return new WriteVarExpr(this.name, this.value.clone(), this.type, this.sourceSpan);
|
|
1171
|
-
}
|
|
1172
|
-
toDeclStmt(type, modifiers) {
|
|
1173
|
-
return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
|
|
1174
|
-
}
|
|
1175
|
-
toConstDecl() {
|
|
1176
|
-
return this.toDeclStmt(INFERRED_TYPE, StmtModifier.Final);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
class WriteKeyExpr extends Expression {
|
|
1180
|
-
receiver;
|
|
1181
|
-
index;
|
|
1182
|
-
value;
|
|
1183
|
-
constructor(receiver, index, value, type, sourceSpan) {
|
|
1184
|
-
super(type || value.type, sourceSpan);
|
|
1185
|
-
this.receiver = receiver;
|
|
1186
|
-
this.index = index;
|
|
1187
|
-
this.value = value;
|
|
1188
|
-
}
|
|
1189
|
-
isEquivalent(e) {
|
|
1190
|
-
return (e instanceof WriteKeyExpr &&
|
|
1191
|
-
this.receiver.isEquivalent(e.receiver) &&
|
|
1192
|
-
this.index.isEquivalent(e.index) &&
|
|
1193
|
-
this.value.isEquivalent(e.value));
|
|
1194
|
-
}
|
|
1195
|
-
isConstant() {
|
|
1196
|
-
return false;
|
|
1197
|
-
}
|
|
1198
|
-
visitExpression(visitor, context) {
|
|
1199
|
-
return visitor.visitWriteKeyExpr(this, context);
|
|
1200
|
-
}
|
|
1201
|
-
clone() {
|
|
1202
|
-
return new WriteKeyExpr(this.receiver.clone(), this.index.clone(), this.value.clone(), this.type, this.sourceSpan);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
class WritePropExpr extends Expression {
|
|
1206
|
-
receiver;
|
|
1207
|
-
name;
|
|
1208
|
-
value;
|
|
1209
|
-
constructor(receiver, name, value, type, sourceSpan) {
|
|
1210
|
-
super(type || value.type, sourceSpan);
|
|
1211
|
-
this.receiver = receiver;
|
|
1212
|
-
this.name = name;
|
|
1213
|
-
this.value = value;
|
|
1214
|
-
}
|
|
1215
|
-
isEquivalent(e) {
|
|
1216
|
-
return (e instanceof WritePropExpr &&
|
|
1217
|
-
this.receiver.isEquivalent(e.receiver) &&
|
|
1218
|
-
this.name === e.name &&
|
|
1219
|
-
this.value.isEquivalent(e.value));
|
|
1220
|
-
}
|
|
1221
|
-
isConstant() {
|
|
1222
|
-
return false;
|
|
1223
|
-
}
|
|
1224
|
-
visitExpression(visitor, context) {
|
|
1225
|
-
return visitor.visitWritePropExpr(this, context);
|
|
1226
|
-
}
|
|
1227
|
-
clone() {
|
|
1228
|
-
return new WritePropExpr(this.receiver.clone(), this.name, this.value.clone(), this.type, this.sourceSpan);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
1153
|
class InvokeFunctionExpr extends Expression {
|
|
1232
1154
|
fn;
|
|
1233
1155
|
args;
|
|
@@ -1781,7 +1703,7 @@ class ReadPropExpr extends Expression {
|
|
|
1781
1703
|
return visitor.visitReadPropExpr(this, context);
|
|
1782
1704
|
}
|
|
1783
1705
|
set(value) {
|
|
1784
|
-
return new
|
|
1706
|
+
return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.prop(this.name), value, null, this.sourceSpan);
|
|
1785
1707
|
}
|
|
1786
1708
|
clone() {
|
|
1787
1709
|
return new ReadPropExpr(this.receiver.clone(), this.name, this.type, this.sourceSpan);
|
|
@@ -1807,7 +1729,7 @@ class ReadKeyExpr extends Expression {
|
|
|
1807
1729
|
return visitor.visitReadKeyExpr(this, context);
|
|
1808
1730
|
}
|
|
1809
1731
|
set(value) {
|
|
1810
|
-
return new
|
|
1732
|
+
return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.key(this.index), value, null, this.sourceSpan);
|
|
1811
1733
|
}
|
|
1812
1734
|
clone() {
|
|
1813
1735
|
return new ReadKeyExpr(this.receiver.clone(), this.index.clone(), this.type, this.sourceSpan);
|
|
@@ -2063,21 +1985,6 @@ let RecursiveAstVisitor$1 = class RecursiveAstVisitor {
|
|
|
2063
1985
|
visitReadVarExpr(ast, context) {
|
|
2064
1986
|
return this.visitExpression(ast, context);
|
|
2065
1987
|
}
|
|
2066
|
-
visitWriteVarExpr(ast, context) {
|
|
2067
|
-
ast.value.visitExpression(this, context);
|
|
2068
|
-
return this.visitExpression(ast, context);
|
|
2069
|
-
}
|
|
2070
|
-
visitWriteKeyExpr(ast, context) {
|
|
2071
|
-
ast.receiver.visitExpression(this, context);
|
|
2072
|
-
ast.index.visitExpression(this, context);
|
|
2073
|
-
ast.value.visitExpression(this, context);
|
|
2074
|
-
return this.visitExpression(ast, context);
|
|
2075
|
-
}
|
|
2076
|
-
visitWritePropExpr(ast, context) {
|
|
2077
|
-
ast.receiver.visitExpression(this, context);
|
|
2078
|
-
ast.value.visitExpression(this, context);
|
|
2079
|
-
return this.visitExpression(ast, context);
|
|
2080
|
-
}
|
|
2081
1988
|
visitDynamicImportExpr(ast, context) {
|
|
2082
1989
|
return this.visitExpression(ast, context);
|
|
2083
1990
|
}
|
|
@@ -2375,9 +2282,6 @@ var output_ast = /*#__PURE__*/Object.freeze({
|
|
|
2375
2282
|
UnaryOperatorExpr: UnaryOperatorExpr,
|
|
2376
2283
|
VoidExpr: VoidExpr,
|
|
2377
2284
|
WrappedNodeExpr: WrappedNodeExpr,
|
|
2378
|
-
WriteKeyExpr: WriteKeyExpr,
|
|
2379
|
-
WritePropExpr: WritePropExpr,
|
|
2380
|
-
WriteVarExpr: WriteVarExpr,
|
|
2381
2285
|
areAllEquivalent: areAllEquivalent,
|
|
2382
2286
|
arrowFn: arrowFn,
|
|
2383
2287
|
expressionType: expressionType,
|
|
@@ -2505,7 +2409,7 @@ class ConstantPool {
|
|
|
2505
2409
|
if ((!newValue && !fixup.shared) || (newValue && forceShared)) {
|
|
2506
2410
|
// Replace the expression with a variable
|
|
2507
2411
|
const name = this.freshName();
|
|
2508
|
-
let
|
|
2412
|
+
let value;
|
|
2509
2413
|
let usage;
|
|
2510
2414
|
if (this.isClosureCompilerEnabled && isLongStringLiteral(literal)) {
|
|
2511
2415
|
// For string literals, Closure will **always** inline the string at
|
|
@@ -2521,20 +2425,20 @@ class ConstantPool {
|
|
|
2521
2425
|
// const myStr = function() { return "very very very long string"; };
|
|
2522
2426
|
// const usage1 = myStr();
|
|
2523
2427
|
// const usage2 = myStr();
|
|
2524
|
-
|
|
2428
|
+
value = new FunctionExpr([], // Params.
|
|
2525
2429
|
[
|
|
2526
2430
|
// Statements.
|
|
2527
2431
|
new ReturnStatement(literal),
|
|
2528
|
-
])
|
|
2432
|
+
]);
|
|
2529
2433
|
usage = variable(name).callFn([]);
|
|
2530
2434
|
}
|
|
2531
2435
|
else {
|
|
2532
2436
|
// Just declare and use the variable directly, without a function call
|
|
2533
2437
|
// indirection. This saves a few bytes and avoids an unnecessary call.
|
|
2534
|
-
|
|
2438
|
+
value = literal;
|
|
2535
2439
|
usage = variable(name);
|
|
2536
2440
|
}
|
|
2537
|
-
this.statements.push(
|
|
2441
|
+
this.statements.push(new DeclareVarStmt(name, value, INFERRED_TYPE, StmtModifier.Final));
|
|
2538
2442
|
fixup.fixup(usage);
|
|
2539
2443
|
}
|
|
2540
2444
|
return fixup;
|
|
@@ -2605,9 +2509,7 @@ class ConstantPool {
|
|
|
2605
2509
|
.map((e) => new FnParam(e.name, DYNAMIC_TYPE));
|
|
2606
2510
|
const pureFunctionDeclaration = arrowFn(parameters, resultMap(resultExpressions), INFERRED_TYPE);
|
|
2607
2511
|
const name = this.freshName();
|
|
2608
|
-
this.statements.push(
|
|
2609
|
-
.set(pureFunctionDeclaration)
|
|
2610
|
-
.toDeclStmt(INFERRED_TYPE, StmtModifier.Final));
|
|
2512
|
+
this.statements.push(new DeclareVarStmt(name, pureFunctionDeclaration, INFERRED_TYPE, StmtModifier.Final));
|
|
2611
2513
|
literalFactory = variable(name);
|
|
2612
2514
|
this.literalFactories.set(key, literalFactory);
|
|
2613
2515
|
}
|
|
@@ -3511,46 +3413,6 @@ class AbstractEmitterVisitor {
|
|
|
3511
3413
|
ctx.println(stmt, `}`);
|
|
3512
3414
|
return null;
|
|
3513
3415
|
}
|
|
3514
|
-
visitWriteVarExpr(expr, ctx) {
|
|
3515
|
-
const lineWasEmpty = ctx.lineIsEmpty();
|
|
3516
|
-
if (!lineWasEmpty) {
|
|
3517
|
-
ctx.print(expr, '(');
|
|
3518
|
-
}
|
|
3519
|
-
ctx.print(expr, `${expr.name} = `);
|
|
3520
|
-
expr.value.visitExpression(this, ctx);
|
|
3521
|
-
if (!lineWasEmpty) {
|
|
3522
|
-
ctx.print(expr, ')');
|
|
3523
|
-
}
|
|
3524
|
-
return null;
|
|
3525
|
-
}
|
|
3526
|
-
visitWriteKeyExpr(expr, ctx) {
|
|
3527
|
-
const lineWasEmpty = ctx.lineIsEmpty();
|
|
3528
|
-
if (!lineWasEmpty) {
|
|
3529
|
-
ctx.print(expr, '(');
|
|
3530
|
-
}
|
|
3531
|
-
expr.receiver.visitExpression(this, ctx);
|
|
3532
|
-
ctx.print(expr, `[`);
|
|
3533
|
-
expr.index.visitExpression(this, ctx);
|
|
3534
|
-
ctx.print(expr, `] = `);
|
|
3535
|
-
expr.value.visitExpression(this, ctx);
|
|
3536
|
-
if (!lineWasEmpty) {
|
|
3537
|
-
ctx.print(expr, ')');
|
|
3538
|
-
}
|
|
3539
|
-
return null;
|
|
3540
|
-
}
|
|
3541
|
-
visitWritePropExpr(expr, ctx) {
|
|
3542
|
-
const lineWasEmpty = ctx.lineIsEmpty();
|
|
3543
|
-
if (!lineWasEmpty) {
|
|
3544
|
-
ctx.print(expr, '(');
|
|
3545
|
-
}
|
|
3546
|
-
expr.receiver.visitExpression(this, ctx);
|
|
3547
|
-
ctx.print(expr, `.${expr.name} = `);
|
|
3548
|
-
expr.value.visitExpression(this, ctx);
|
|
3549
|
-
if (!lineWasEmpty) {
|
|
3550
|
-
ctx.print(expr, ')');
|
|
3551
|
-
}
|
|
3552
|
-
return null;
|
|
3553
|
-
}
|
|
3554
3416
|
visitInvokeFunctionExpr(expr, ctx) {
|
|
3555
3417
|
const shouldParenthesize = expr.fn instanceof ArrowFunctionExpr;
|
|
3556
3418
|
if (shouldParenthesize) {
|
|
@@ -3672,6 +3534,9 @@ class AbstractEmitterVisitor {
|
|
|
3672
3534
|
visitBinaryOperatorExpr(ast, ctx) {
|
|
3673
3535
|
let opStr;
|
|
3674
3536
|
switch (ast.operator) {
|
|
3537
|
+
case BinaryOperator.Assign:
|
|
3538
|
+
opStr = '=';
|
|
3539
|
+
break;
|
|
3675
3540
|
case BinaryOperator.Equals:
|
|
3676
3541
|
opStr = '==';
|
|
3677
3542
|
break;
|
|
@@ -3951,7 +3816,7 @@ function compileFactoryFunction(meta) {
|
|
|
3951
3816
|
let retExpr = null;
|
|
3952
3817
|
function makeConditionalFactory(nonCtorExpr) {
|
|
3953
3818
|
const r = variable('__ngConditionalFactory__');
|
|
3954
|
-
body.push(r.
|
|
3819
|
+
body.push(new DeclareVarStmt(r.name, NULL_EXPR, INFERRED_TYPE));
|
|
3955
3820
|
const ctorStmt = ctorExpr !== null
|
|
3956
3821
|
? r.set(ctorExpr).toStmt()
|
|
3957
3822
|
: importExpr(Identifiers.invalidFactory).callFn([]).toStmt();
|
|
@@ -4211,20 +4076,6 @@ class PropertyRead extends ASTWithName {
|
|
|
4211
4076
|
return visitor.visitPropertyRead(this, context);
|
|
4212
4077
|
}
|
|
4213
4078
|
}
|
|
4214
|
-
class PropertyWrite extends ASTWithName {
|
|
4215
|
-
receiver;
|
|
4216
|
-
name;
|
|
4217
|
-
value;
|
|
4218
|
-
constructor(span, sourceSpan, nameSpan, receiver, name, value) {
|
|
4219
|
-
super(span, sourceSpan, nameSpan);
|
|
4220
|
-
this.receiver = receiver;
|
|
4221
|
-
this.name = name;
|
|
4222
|
-
this.value = value;
|
|
4223
|
-
}
|
|
4224
|
-
visit(visitor, context = null) {
|
|
4225
|
-
return visitor.visitPropertyWrite(this, context);
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
4079
|
class SafePropertyRead extends ASTWithName {
|
|
4229
4080
|
receiver;
|
|
4230
4081
|
name;
|
|
@@ -4261,29 +4112,31 @@ class SafeKeyedRead extends AST {
|
|
|
4261
4112
|
return visitor.visitSafeKeyedRead(this, context);
|
|
4262
4113
|
}
|
|
4263
4114
|
}
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
}
|
|
4115
|
+
/** Possible types for a pipe. */
|
|
4116
|
+
var BindingPipeType;
|
|
4117
|
+
(function (BindingPipeType) {
|
|
4118
|
+
/**
|
|
4119
|
+
* Pipe is being referenced by its name, for example:
|
|
4120
|
+
* `@Pipe({name: 'foo'}) class FooPipe` and `{{123 | foo}}`.
|
|
4121
|
+
*/
|
|
4122
|
+
BindingPipeType[BindingPipeType["ReferencedByName"] = 0] = "ReferencedByName";
|
|
4123
|
+
/**
|
|
4124
|
+
* Pipe is being referenced by its class name, for example:
|
|
4125
|
+
* `@Pipe() class FooPipe` and `{{123 | FooPipe}}`.
|
|
4126
|
+
*/
|
|
4127
|
+
BindingPipeType[BindingPipeType["ReferencedDirectly"] = 1] = "ReferencedDirectly";
|
|
4128
|
+
})(BindingPipeType || (BindingPipeType = {}));
|
|
4278
4129
|
class BindingPipe extends ASTWithName {
|
|
4279
4130
|
exp;
|
|
4280
4131
|
name;
|
|
4281
4132
|
args;
|
|
4282
|
-
|
|
4133
|
+
type;
|
|
4134
|
+
constructor(span, sourceSpan, exp, name, args, type, nameSpan) {
|
|
4283
4135
|
super(span, sourceSpan, nameSpan);
|
|
4284
4136
|
this.exp = exp;
|
|
4285
4137
|
this.name = name;
|
|
4286
4138
|
this.args = args;
|
|
4139
|
+
this.type = type;
|
|
4287
4140
|
}
|
|
4288
4141
|
visit(visitor, context = null) {
|
|
4289
4142
|
return visitor.visitPipe(this, context);
|
|
@@ -4604,11 +4457,6 @@ class RecursiveAstVisitor {
|
|
|
4604
4457
|
this.visit(ast.receiver, context);
|
|
4605
4458
|
this.visit(ast.key, context);
|
|
4606
4459
|
}
|
|
4607
|
-
visitKeyedWrite(ast, context) {
|
|
4608
|
-
this.visit(ast.receiver, context);
|
|
4609
|
-
this.visit(ast.key, context);
|
|
4610
|
-
this.visit(ast.value, context);
|
|
4611
|
-
}
|
|
4612
4460
|
visitLiteralArray(ast, context) {
|
|
4613
4461
|
this.visitAll(ast.expressions, context);
|
|
4614
4462
|
}
|
|
@@ -4631,10 +4479,6 @@ class RecursiveAstVisitor {
|
|
|
4631
4479
|
visitPropertyRead(ast, context) {
|
|
4632
4480
|
this.visit(ast.receiver, context);
|
|
4633
4481
|
}
|
|
4634
|
-
visitPropertyWrite(ast, context) {
|
|
4635
|
-
this.visit(ast.receiver, context);
|
|
4636
|
-
this.visit(ast.value, context);
|
|
4637
|
-
}
|
|
4638
4482
|
visitSafePropertyRead(ast, context) {
|
|
4639
4483
|
this.visit(ast.receiver, context);
|
|
4640
4484
|
}
|
|
@@ -4960,11 +4804,12 @@ let Element$1 = class Element {
|
|
|
4960
4804
|
directives;
|
|
4961
4805
|
children;
|
|
4962
4806
|
references;
|
|
4807
|
+
isSelfClosing;
|
|
4963
4808
|
sourceSpan;
|
|
4964
4809
|
startSourceSpan;
|
|
4965
4810
|
endSourceSpan;
|
|
4966
4811
|
i18n;
|
|
4967
|
-
constructor(name, attributes, inputs, outputs, directives, children, references, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
4812
|
+
constructor(name, attributes, inputs, outputs, directives, children, references, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
4968
4813
|
this.name = name;
|
|
4969
4814
|
this.attributes = attributes;
|
|
4970
4815
|
this.inputs = inputs;
|
|
@@ -4972,6 +4817,7 @@ let Element$1 = class Element {
|
|
|
4972
4817
|
this.directives = directives;
|
|
4973
4818
|
this.children = children;
|
|
4974
4819
|
this.references = references;
|
|
4820
|
+
this.isSelfClosing = isSelfClosing;
|
|
4975
4821
|
this.sourceSpan = sourceSpan;
|
|
4976
4822
|
this.startSourceSpan = startSourceSpan;
|
|
4977
4823
|
this.endSourceSpan = endSourceSpan;
|
|
@@ -5278,11 +5124,12 @@ let Component$1 = class Component {
|
|
|
5278
5124
|
directives;
|
|
5279
5125
|
children;
|
|
5280
5126
|
references;
|
|
5127
|
+
isSelfClosing;
|
|
5281
5128
|
sourceSpan;
|
|
5282
5129
|
startSourceSpan;
|
|
5283
5130
|
endSourceSpan;
|
|
5284
5131
|
i18n;
|
|
5285
|
-
constructor(componentName, tagName, fullName, attributes, inputs, outputs, directives, children, references, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5132
|
+
constructor(componentName, tagName, fullName, attributes, inputs, outputs, directives, children, references, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5286
5133
|
this.componentName = componentName;
|
|
5287
5134
|
this.tagName = tagName;
|
|
5288
5135
|
this.fullName = fullName;
|
|
@@ -5292,6 +5139,7 @@ let Component$1 = class Component {
|
|
|
5292
5139
|
this.directives = directives;
|
|
5293
5140
|
this.children = children;
|
|
5294
5141
|
this.references = references;
|
|
5142
|
+
this.isSelfClosing = isSelfClosing;
|
|
5295
5143
|
this.sourceSpan = sourceSpan;
|
|
5296
5144
|
this.startSourceSpan = startSourceSpan;
|
|
5297
5145
|
this.endSourceSpan = endSourceSpan;
|
|
@@ -5336,6 +5184,7 @@ class Template {
|
|
|
5336
5184
|
children;
|
|
5337
5185
|
references;
|
|
5338
5186
|
variables;
|
|
5187
|
+
isSelfClosing;
|
|
5339
5188
|
sourceSpan;
|
|
5340
5189
|
startSourceSpan;
|
|
5341
5190
|
endSourceSpan;
|
|
@@ -5345,7 +5194,7 @@ class Template {
|
|
|
5345
5194
|
// `null` is a special case for when there is a structural directive on an `ng-template` so
|
|
5346
5195
|
// the renderer can differentiate between the synthetic template and the one written in the
|
|
5347
5196
|
// file.
|
|
5348
|
-
tagName, attributes, inputs, outputs, directives, templateAttrs, children, references, variables, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5197
|
+
tagName, attributes, inputs, outputs, directives, templateAttrs, children, references, variables, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5349
5198
|
this.tagName = tagName;
|
|
5350
5199
|
this.attributes = attributes;
|
|
5351
5200
|
this.inputs = inputs;
|
|
@@ -5355,6 +5204,7 @@ class Template {
|
|
|
5355
5204
|
this.children = children;
|
|
5356
5205
|
this.references = references;
|
|
5357
5206
|
this.variables = variables;
|
|
5207
|
+
this.isSelfClosing = isSelfClosing;
|
|
5358
5208
|
this.sourceSpan = sourceSpan;
|
|
5359
5209
|
this.startSourceSpan = startSourceSpan;
|
|
5360
5210
|
this.endSourceSpan = endSourceSpan;
|
|
@@ -5368,15 +5218,17 @@ class Content {
|
|
|
5368
5218
|
selector;
|
|
5369
5219
|
attributes;
|
|
5370
5220
|
children;
|
|
5221
|
+
isSelfClosing;
|
|
5371
5222
|
sourceSpan;
|
|
5372
5223
|
startSourceSpan;
|
|
5373
5224
|
endSourceSpan;
|
|
5374
5225
|
i18n;
|
|
5375
5226
|
name = 'ng-content';
|
|
5376
|
-
constructor(selector, attributes, children, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5227
|
+
constructor(selector, attributes, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
|
|
5377
5228
|
this.selector = selector;
|
|
5378
5229
|
this.attributes = attributes;
|
|
5379
5230
|
this.children = children;
|
|
5231
|
+
this.isSelfClosing = isSelfClosing;
|
|
5380
5232
|
this.sourceSpan = sourceSpan;
|
|
5381
5233
|
this.startSourceSpan = startSourceSpan;
|
|
5382
5234
|
this.endSourceSpan = endSourceSpan;
|
|
@@ -5542,7 +5394,7 @@ function visitAll$1(visitor, nodes) {
|
|
|
5542
5394
|
const result = [];
|
|
5543
5395
|
if (visitor.visit) {
|
|
5544
5396
|
for (const node of nodes) {
|
|
5545
|
-
visitor.visit(node)
|
|
5397
|
+
visitor.visit(node);
|
|
5546
5398
|
}
|
|
5547
5399
|
}
|
|
5548
5400
|
else {
|
|
@@ -7438,7 +7290,11 @@ function tupleOfTypes(types) {
|
|
|
7438
7290
|
function compilePipeFromMetadata(metadata) {
|
|
7439
7291
|
const definitionMapValues = [];
|
|
7440
7292
|
// e.g. `name: 'myPipe'`
|
|
7441
|
-
definitionMapValues.push({
|
|
7293
|
+
definitionMapValues.push({
|
|
7294
|
+
key: 'name',
|
|
7295
|
+
value: literal(metadata.pipeName ?? metadata.name),
|
|
7296
|
+
quoted: false,
|
|
7297
|
+
});
|
|
7442
7298
|
// e.g. `type: MyPipe`
|
|
7443
7299
|
definitionMapValues.push({ key: 'type', value: metadata.type.value, quoted: false });
|
|
7444
7300
|
// e.g. `pure: true`
|
|
@@ -10454,15 +10310,6 @@ function transformExpressionsInExpression(expr, transform, flags) {
|
|
|
10454
10310
|
expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
|
|
10455
10311
|
expr.index = transformExpressionsInExpression(expr.index, transform, flags);
|
|
10456
10312
|
}
|
|
10457
|
-
else if (expr instanceof WritePropExpr) {
|
|
10458
|
-
expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
|
|
10459
|
-
expr.value = transformExpressionsInExpression(expr.value, transform, flags);
|
|
10460
|
-
}
|
|
10461
|
-
else if (expr instanceof WriteKeyExpr) {
|
|
10462
|
-
expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
|
|
10463
|
-
expr.index = transformExpressionsInExpression(expr.index, transform, flags);
|
|
10464
|
-
expr.value = transformExpressionsInExpression(expr.value, transform, flags);
|
|
10465
|
-
}
|
|
10466
10313
|
else if (expr instanceof InvokeFunctionExpr) {
|
|
10467
10314
|
expr.fn = transformExpressionsInExpression(expr.fn, transform, flags);
|
|
10468
10315
|
for (let i = 0; i < expr.args.length; i++) {
|
|
@@ -10492,9 +10339,6 @@ function transformExpressionsInExpression(expr, transform, flags) {
|
|
|
10492
10339
|
else if (expr instanceof VoidExpr) {
|
|
10493
10340
|
expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);
|
|
10494
10341
|
}
|
|
10495
|
-
else if (expr instanceof WriteVarExpr) {
|
|
10496
|
-
expr.value = transformExpressionsInExpression(expr.value, transform, flags);
|
|
10497
|
-
}
|
|
10498
10342
|
else if (expr instanceof LocalizedString) {
|
|
10499
10343
|
for (let i = 0; i < expr.expressions.length; i++) {
|
|
10500
10344
|
expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform, flags);
|
|
@@ -12077,6 +11921,7 @@ const BINARY_OPERATORS = new Map([
|
|
|
12077
11921
|
['|', BinaryOperator.BitwiseOr],
|
|
12078
11922
|
['&', BinaryOperator.BitwiseAnd],
|
|
12079
11923
|
['/', BinaryOperator.Divide],
|
|
11924
|
+
['=', BinaryOperator.Assign],
|
|
12080
11925
|
['==', BinaryOperator.Equals],
|
|
12081
11926
|
['===', BinaryOperator.Identical],
|
|
12082
11927
|
['<', BinaryOperator.Lower],
|
|
@@ -13551,14 +13396,16 @@ class Element extends NodeWithI18n {
|
|
|
13551
13396
|
attrs;
|
|
13552
13397
|
directives;
|
|
13553
13398
|
children;
|
|
13399
|
+
isSelfClosing;
|
|
13554
13400
|
startSourceSpan;
|
|
13555
13401
|
endSourceSpan;
|
|
13556
|
-
constructor(name, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
|
|
13402
|
+
constructor(name, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
|
|
13557
13403
|
super(sourceSpan, i18n);
|
|
13558
13404
|
this.name = name;
|
|
13559
13405
|
this.attrs = attrs;
|
|
13560
13406
|
this.directives = directives;
|
|
13561
13407
|
this.children = children;
|
|
13408
|
+
this.isSelfClosing = isSelfClosing;
|
|
13562
13409
|
this.startSourceSpan = startSourceSpan;
|
|
13563
13410
|
this.endSourceSpan = endSourceSpan;
|
|
13564
13411
|
}
|
|
@@ -13604,9 +13451,10 @@ class Component extends NodeWithI18n {
|
|
|
13604
13451
|
attrs;
|
|
13605
13452
|
directives;
|
|
13606
13453
|
children;
|
|
13454
|
+
isSelfClosing;
|
|
13607
13455
|
startSourceSpan;
|
|
13608
13456
|
endSourceSpan;
|
|
13609
|
-
constructor(componentName, tagName, fullName, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
|
|
13457
|
+
constructor(componentName, tagName, fullName, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
|
|
13610
13458
|
super(sourceSpan, i18n);
|
|
13611
13459
|
this.componentName = componentName;
|
|
13612
13460
|
this.tagName = tagName;
|
|
@@ -13614,6 +13462,7 @@ class Component extends NodeWithI18n {
|
|
|
13614
13462
|
this.attrs = attrs;
|
|
13615
13463
|
this.directives = directives;
|
|
13616
13464
|
this.children = children;
|
|
13465
|
+
this.isSelfClosing = isSelfClosing;
|
|
13617
13466
|
this.startSourceSpan = startSourceSpan;
|
|
13618
13467
|
this.endSourceSpan = endSourceSpan;
|
|
13619
13468
|
}
|
|
@@ -17525,7 +17374,7 @@ class _TreeBuilder {
|
|
|
17525
17374
|
const span = new ParseSourceSpan(startTagToken.sourceSpan.start, end, startTagToken.sourceSpan.fullStart);
|
|
17526
17375
|
// Create a separate `startSpan` because `span` will be modified when there is an `end` span.
|
|
17527
17376
|
const startSpan = new ParseSourceSpan(startTagToken.sourceSpan.start, end, startTagToken.sourceSpan.fullStart);
|
|
17528
|
-
const el = new Element(fullName, attrs, directives, [], span, startSpan, undefined);
|
|
17377
|
+
const el = new Element(fullName, attrs, directives, [], selfClosing, span, startSpan, undefined);
|
|
17529
17378
|
const parent = this._getContainer();
|
|
17530
17379
|
const isClosedByChild = parent !== null && !!this._getTagDefinition(parent)?.isClosedByChild(el.name);
|
|
17531
17380
|
this._pushContainer(el, isClosedByChild);
|
|
@@ -17554,7 +17403,7 @@ class _TreeBuilder {
|
|
|
17554
17403
|
const end = this._peek.sourceSpan.fullStart;
|
|
17555
17404
|
const span = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart);
|
|
17556
17405
|
const startSpan = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart);
|
|
17557
|
-
const node = new Component(componentName, tagName, fullName, attrs, directives, [], span, startSpan, undefined);
|
|
17406
|
+
const node = new Component(componentName, tagName, fullName, attrs, directives, [], selfClosing, span, startSpan, undefined);
|
|
17558
17407
|
const parent = this._getContainer();
|
|
17559
17408
|
const isClosedByChild = parent !== null &&
|
|
17560
17409
|
node.tagName !== null &&
|
|
@@ -17968,11 +17817,11 @@ class WhitespaceVisitor {
|
|
|
17968
17817
|
if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
|
|
17969
17818
|
// don't descent into elements where we need to preserve whitespaces
|
|
17970
17819
|
// but still visit all attributes to eliminate one used as a market to preserve WS
|
|
17971
|
-
const newElement = new Element(element.name, visitAllWithSiblings(this, element.attrs), visitAllWithSiblings(this, element.directives), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
17820
|
+
const newElement = new Element(element.name, visitAllWithSiblings(this, element.attrs), visitAllWithSiblings(this, element.directives), element.children, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
17972
17821
|
this.originalNodeMap?.set(newElement, element);
|
|
17973
17822
|
return newElement;
|
|
17974
17823
|
}
|
|
17975
|
-
const newElement = new Element(element.name, element.attrs, element.directives, visitAllWithSiblings(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
17824
|
+
const newElement = new Element(element.name, element.attrs, element.directives, visitAllWithSiblings(this, element.children), element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
17976
17825
|
this.originalNodeMap?.set(newElement, element);
|
|
17977
17826
|
return newElement;
|
|
17978
17827
|
}
|
|
@@ -18051,11 +17900,11 @@ class WhitespaceVisitor {
|
|
|
18051
17900
|
hasPreserveWhitespacesAttr(node.attrs)) {
|
|
18052
17901
|
// don't descent into elements where we need to preserve whitespaces
|
|
18053
17902
|
// but still visit all attributes to eliminate one used as a market to preserve WS
|
|
18054
|
-
const newElement = new Component(node.componentName, node.tagName, node.fullName, visitAllWithSiblings(this, node.attrs), visitAllWithSiblings(this, node.directives), node.children, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.i18n);
|
|
17903
|
+
const newElement = new Component(node.componentName, node.tagName, node.fullName, visitAllWithSiblings(this, node.attrs), visitAllWithSiblings(this, node.directives), node.children, node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.i18n);
|
|
18055
17904
|
this.originalNodeMap?.set(newElement, node);
|
|
18056
17905
|
return newElement;
|
|
18057
17906
|
}
|
|
18058
|
-
const newElement = new Component(node.componentName, node.tagName, node.fullName, node.attrs, node.directives, visitAllWithSiblings(this, node.children), node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.i18n);
|
|
17907
|
+
const newElement = new Component(node.componentName, node.tagName, node.fullName, node.attrs, node.directives, visitAllWithSiblings(this, node.children), node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.i18n);
|
|
18059
17908
|
this.originalNodeMap?.set(newElement, node);
|
|
18060
17909
|
return newElement;
|
|
18061
17910
|
}
|
|
@@ -18655,20 +18504,23 @@ class TemplateBindingParseResult {
|
|
|
18655
18504
|
}
|
|
18656
18505
|
class Parser {
|
|
18657
18506
|
_lexer;
|
|
18658
|
-
|
|
18659
|
-
constructor(_lexer) {
|
|
18507
|
+
_supportsDirectPipeReferences;
|
|
18508
|
+
constructor(_lexer, _supportsDirectPipeReferences = false) {
|
|
18660
18509
|
this._lexer = _lexer;
|
|
18510
|
+
this._supportsDirectPipeReferences = _supportsDirectPipeReferences;
|
|
18661
18511
|
}
|
|
18662
18512
|
parseAction(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18663
|
-
|
|
18513
|
+
const errors = [];
|
|
18514
|
+
this._checkNoInterpolation(errors, input, location, interpolationConfig);
|
|
18664
18515
|
const sourceToLex = this._stripComments(input);
|
|
18665
18516
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
18666
|
-
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 1 /* ParseFlags.Action */,
|
|
18667
|
-
return new ASTWithSource(ast, input, location, absoluteOffset,
|
|
18517
|
+
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 1 /* ParseFlags.Action */, errors, 0, this._supportsDirectPipeReferences).parseChain();
|
|
18518
|
+
return new ASTWithSource(ast, input, location, absoluteOffset, errors);
|
|
18668
18519
|
}
|
|
18669
18520
|
parseBinding(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18670
|
-
const
|
|
18671
|
-
|
|
18521
|
+
const errors = [];
|
|
18522
|
+
const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors);
|
|
18523
|
+
return new ASTWithSource(ast, input, location, absoluteOffset, errors);
|
|
18672
18524
|
}
|
|
18673
18525
|
checkSimpleExpression(ast) {
|
|
18674
18526
|
const checker = new SimpleExpressionChecker();
|
|
@@ -18677,21 +18529,19 @@ class Parser {
|
|
|
18677
18529
|
}
|
|
18678
18530
|
// Host bindings parsed here
|
|
18679
18531
|
parseSimpleBinding(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18680
|
-
const
|
|
18681
|
-
const
|
|
18682
|
-
|
|
18683
|
-
|
|
18532
|
+
const errors = [];
|
|
18533
|
+
const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors);
|
|
18534
|
+
const simplExpressionErrors = this.checkSimpleExpression(ast);
|
|
18535
|
+
if (simplExpressionErrors.length > 0) {
|
|
18536
|
+
errors.push(new ParserError(`Host binding expression cannot contain ${simplExpressionErrors.join(' ')}`, input, location));
|
|
18684
18537
|
}
|
|
18685
|
-
return new ASTWithSource(ast, input, location, absoluteOffset,
|
|
18686
|
-
}
|
|
18687
|
-
_reportError(message, input, errLocation, ctxLocation) {
|
|
18688
|
-
this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
|
|
18538
|
+
return new ASTWithSource(ast, input, location, absoluteOffset, errors);
|
|
18689
18539
|
}
|
|
18690
|
-
_parseBindingAst(input, location, absoluteOffset, interpolationConfig) {
|
|
18691
|
-
this._checkNoInterpolation(input, location, interpolationConfig);
|
|
18540
|
+
_parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors) {
|
|
18541
|
+
this._checkNoInterpolation(errors, input, location, interpolationConfig);
|
|
18692
18542
|
const sourceToLex = this._stripComments(input);
|
|
18693
18543
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
18694
|
-
return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */,
|
|
18544
|
+
return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, 0, this._supportsDirectPipeReferences).parseChain();
|
|
18695
18545
|
}
|
|
18696
18546
|
/**
|
|
18697
18547
|
* Parse microsyntax template expression and return a list of bindings or
|
|
@@ -18721,14 +18571,16 @@ class Parser {
|
|
|
18721
18571
|
*/
|
|
18722
18572
|
parseTemplateBindings(templateKey, templateValue, templateUrl, absoluteKeyOffset, absoluteValueOffset) {
|
|
18723
18573
|
const tokens = this._lexer.tokenize(templateValue);
|
|
18724
|
-
const
|
|
18574
|
+
const errors = [];
|
|
18575
|
+
const parser = new _ParseAST(templateValue, templateUrl, absoluteValueOffset, tokens, 0 /* ParseFlags.None */, errors, 0 /* relative offset */, this._supportsDirectPipeReferences);
|
|
18725
18576
|
return parser.parseTemplateBindings({
|
|
18726
18577
|
source: templateKey,
|
|
18727
18578
|
span: new AbsoluteSourceSpan(absoluteKeyOffset, absoluteKeyOffset + templateKey.length),
|
|
18728
18579
|
});
|
|
18729
18580
|
}
|
|
18730
18581
|
parseInterpolation(input, location, absoluteOffset, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18731
|
-
const
|
|
18582
|
+
const errors = [];
|
|
18583
|
+
const { strings, expressions, offsets } = this.splitInterpolation(input, location, errors, interpolatedTokens, interpolationConfig);
|
|
18732
18584
|
if (expressions.length === 0)
|
|
18733
18585
|
return null;
|
|
18734
18586
|
const expressionNodes = [];
|
|
@@ -18736,10 +18588,10 @@ class Parser {
|
|
|
18736
18588
|
const expressionText = expressions[i].text;
|
|
18737
18589
|
const sourceToLex = this._stripComments(expressionText);
|
|
18738
18590
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
18739
|
-
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */,
|
|
18591
|
+
const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, offsets[i], this._supportsDirectPipeReferences).parseChain();
|
|
18740
18592
|
expressionNodes.push(ast);
|
|
18741
18593
|
}
|
|
18742
|
-
return this.createInterpolationAst(strings.map((s) => s.text), expressionNodes, input, location, absoluteOffset);
|
|
18594
|
+
return this.createInterpolationAst(strings.map((s) => s.text), expressionNodes, input, location, absoluteOffset, errors);
|
|
18743
18595
|
}
|
|
18744
18596
|
/**
|
|
18745
18597
|
* Similar to `parseInterpolation`, but treats the provided string as a single expression
|
|
@@ -18749,14 +18601,15 @@ class Parser {
|
|
|
18749
18601
|
parseInterpolationExpression(expression, location, absoluteOffset) {
|
|
18750
18602
|
const sourceToLex = this._stripComments(expression);
|
|
18751
18603
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
18752
|
-
const
|
|
18604
|
+
const errors = [];
|
|
18605
|
+
const ast = new _ParseAST(expression, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, 0, this._supportsDirectPipeReferences).parseChain();
|
|
18753
18606
|
const strings = ['', '']; // The prefix and suffix strings are both empty
|
|
18754
|
-
return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset);
|
|
18607
|
+
return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset, errors);
|
|
18755
18608
|
}
|
|
18756
|
-
createInterpolationAst(strings, expressions, input, location, absoluteOffset) {
|
|
18609
|
+
createInterpolationAst(strings, expressions, input, location, absoluteOffset, errors) {
|
|
18757
18610
|
const span = new ParseSpan(0, input.length);
|
|
18758
18611
|
const interpolation = new Interpolation$1(span, span.toAbsolute(absoluteOffset), strings, expressions);
|
|
18759
|
-
return new ASTWithSource(interpolation, input, location, absoluteOffset,
|
|
18612
|
+
return new ASTWithSource(interpolation, input, location, absoluteOffset, errors);
|
|
18760
18613
|
}
|
|
18761
18614
|
/**
|
|
18762
18615
|
* Splits a string of text into "raw" text segments and expressions present in interpolations in
|
|
@@ -18765,7 +18618,7 @@ class Parser {
|
|
|
18765
18618
|
* `SplitInterpolation` with splits that look like
|
|
18766
18619
|
* <raw text> <expression> <raw text> ... <raw text> <expression> <raw text>
|
|
18767
18620
|
*/
|
|
18768
|
-
splitInterpolation(input, location, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18621
|
+
splitInterpolation(input, location, errors, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
18769
18622
|
const strings = [];
|
|
18770
18623
|
const expressions = [];
|
|
18771
18624
|
const offsets = [];
|
|
@@ -18803,7 +18656,7 @@ class Parser {
|
|
|
18803
18656
|
const fullEnd = exprEnd + interpEnd.length;
|
|
18804
18657
|
const text = input.substring(exprStart, exprEnd);
|
|
18805
18658
|
if (text.trim().length === 0) {
|
|
18806
|
-
|
|
18659
|
+
errors.push(new ParserError('Blank expressions are not allowed in interpolated strings', input, `at column ${i} in`, location));
|
|
18807
18660
|
}
|
|
18808
18661
|
expressions.push({ text, start: fullStart, end: fullEnd });
|
|
18809
18662
|
const startInOriginalTemplate = inputToTemplateIndexMap?.get(fullStart) ?? fullStart;
|
|
@@ -18828,7 +18681,7 @@ class Parser {
|
|
|
18828
18681
|
}
|
|
18829
18682
|
wrapLiteralPrimitive(input, location, absoluteOffset) {
|
|
18830
18683
|
const span = new ParseSpan(0, input == null ? 0 : input.length);
|
|
18831
|
-
return new ASTWithSource(new LiteralPrimitive(span, span.toAbsolute(absoluteOffset), input), input, location, absoluteOffset,
|
|
18684
|
+
return new ASTWithSource(new LiteralPrimitive(span, span.toAbsolute(absoluteOffset), input), input, location, absoluteOffset, []);
|
|
18832
18685
|
}
|
|
18833
18686
|
_stripComments(input) {
|
|
18834
18687
|
const i = this._commentStart(input);
|
|
@@ -18850,7 +18703,7 @@ class Parser {
|
|
|
18850
18703
|
}
|
|
18851
18704
|
return null;
|
|
18852
18705
|
}
|
|
18853
|
-
_checkNoInterpolation(input, location, { start, end }) {
|
|
18706
|
+
_checkNoInterpolation(errors, input, location, { start, end }) {
|
|
18854
18707
|
let startIndex = -1;
|
|
18855
18708
|
let endIndex = -1;
|
|
18856
18709
|
for (const charIndex of this._forEachUnquotedChar(input, 0)) {
|
|
@@ -18867,7 +18720,7 @@ class Parser {
|
|
|
18867
18720
|
}
|
|
18868
18721
|
}
|
|
18869
18722
|
if (startIndex > -1 && endIndex > -1) {
|
|
18870
|
-
|
|
18723
|
+
errors.push(new ParserError(`Got interpolation (${start}${end}) where expression was expected`, input, `at column ${startIndex} in`, location));
|
|
18871
18724
|
}
|
|
18872
18725
|
}
|
|
18873
18726
|
/**
|
|
@@ -18932,6 +18785,7 @@ class _ParseAST {
|
|
|
18932
18785
|
parseFlags;
|
|
18933
18786
|
errors;
|
|
18934
18787
|
offset;
|
|
18788
|
+
supportsDirectPipeReferences;
|
|
18935
18789
|
rparensExpected = 0;
|
|
18936
18790
|
rbracketsExpected = 0;
|
|
18937
18791
|
rbracesExpected = 0;
|
|
@@ -18942,7 +18796,7 @@ class _ParseAST {
|
|
|
18942
18796
|
// and may change for subsequent expressions visited by the parser.
|
|
18943
18797
|
sourceSpanCache = new Map();
|
|
18944
18798
|
index = 0;
|
|
18945
|
-
constructor(input, location, absoluteOffset, tokens, parseFlags, errors, offset) {
|
|
18799
|
+
constructor(input, location, absoluteOffset, tokens, parseFlags, errors, offset, supportsDirectPipeReferences) {
|
|
18946
18800
|
this.input = input;
|
|
18947
18801
|
this.location = location;
|
|
18948
18802
|
this.absoluteOffset = absoluteOffset;
|
|
@@ -18950,6 +18804,7 @@ class _ParseAST {
|
|
|
18950
18804
|
this.parseFlags = parseFlags;
|
|
18951
18805
|
this.errors = errors;
|
|
18952
18806
|
this.offset = offset;
|
|
18807
|
+
this.supportsDirectPipeReferences = supportsDirectPipeReferences;
|
|
18953
18808
|
}
|
|
18954
18809
|
peek(offset) {
|
|
18955
18810
|
const i = this.index + offset;
|
|
@@ -19178,7 +19033,18 @@ class _ParseAST {
|
|
|
19178
19033
|
// If there are additional expressions beyond the name, then the artificial end for the
|
|
19179
19034
|
// name is no longer relevant.
|
|
19180
19035
|
}
|
|
19181
|
-
|
|
19036
|
+
let type;
|
|
19037
|
+
if (this.supportsDirectPipeReferences) {
|
|
19038
|
+
const charCode = nameId.charCodeAt(0);
|
|
19039
|
+
type =
|
|
19040
|
+
charCode === $_ || (charCode >= $A && charCode <= $Z)
|
|
19041
|
+
? BindingPipeType.ReferencedDirectly
|
|
19042
|
+
: BindingPipeType.ReferencedByName;
|
|
19043
|
+
}
|
|
19044
|
+
else {
|
|
19045
|
+
type = BindingPipeType.ReferencedByName;
|
|
19046
|
+
}
|
|
19047
|
+
result = new BindingPipe(this.span(start), this.sourceSpan(start, fullSpanEnd), result, nameId, args, type, nameSpan);
|
|
19182
19048
|
} while (this.consumeOptionalOperator('|'));
|
|
19183
19049
|
}
|
|
19184
19050
|
return result;
|
|
@@ -19411,8 +19277,13 @@ class _ParseAST {
|
|
|
19411
19277
|
if (this.consumeOptionalCharacter($LPAREN)) {
|
|
19412
19278
|
this.rparensExpected++;
|
|
19413
19279
|
const result = this.parsePipe();
|
|
19280
|
+
if (!this.consumeOptionalCharacter($RPAREN)) {
|
|
19281
|
+
this.error('Missing closing parentheses');
|
|
19282
|
+
// Calling into `error` above will attempt to recover up until the next closing paren.
|
|
19283
|
+
// If that's the case, consume it so we can partially recover the expression.
|
|
19284
|
+
this.consumeOptionalCharacter($RPAREN);
|
|
19285
|
+
}
|
|
19414
19286
|
this.rparensExpected--;
|
|
19415
|
-
this.expectCharacter($RPAREN);
|
|
19416
19287
|
return new ParenthesizedExpression(this.span(start), this.sourceSpan(start), result);
|
|
19417
19288
|
}
|
|
19418
19289
|
else if (this.next.isKeywordNull()) {
|
|
@@ -19537,14 +19408,13 @@ class _ParseAST {
|
|
|
19537
19408
|
return id;
|
|
19538
19409
|
});
|
|
19539
19410
|
const nameSpan = this.sourceSpan(nameStart);
|
|
19540
|
-
let receiver;
|
|
19541
19411
|
if (isSafe) {
|
|
19542
19412
|
if (this.consumeOptionalOperator('=')) {
|
|
19543
19413
|
this.error("The '?.' operator cannot be used in the assignment");
|
|
19544
|
-
|
|
19414
|
+
return new EmptyExpr$1(this.span(start), this.sourceSpan(start));
|
|
19545
19415
|
}
|
|
19546
19416
|
else {
|
|
19547
|
-
|
|
19417
|
+
return new SafePropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
|
|
19548
19418
|
}
|
|
19549
19419
|
}
|
|
19550
19420
|
else {
|
|
@@ -19553,14 +19423,14 @@ class _ParseAST {
|
|
|
19553
19423
|
this.error('Bindings cannot contain assignments');
|
|
19554
19424
|
return new EmptyExpr$1(this.span(start), this.sourceSpan(start));
|
|
19555
19425
|
}
|
|
19426
|
+
const receiver = new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
|
|
19556
19427
|
const value = this.parseConditional();
|
|
19557
|
-
|
|
19428
|
+
return new Binary(this.span(start), this.sourceSpan(start), '=', receiver, value);
|
|
19558
19429
|
}
|
|
19559
19430
|
else {
|
|
19560
|
-
|
|
19431
|
+
return new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
|
|
19561
19432
|
}
|
|
19562
19433
|
}
|
|
19563
|
-
return receiver;
|
|
19564
19434
|
}
|
|
19565
19435
|
parseCall(receiver, start, isSafe) {
|
|
19566
19436
|
const argumentStart = this.inputIndex;
|
|
@@ -19675,8 +19545,9 @@ class _ParseAST {
|
|
|
19675
19545
|
this.error("The '?.' operator cannot be used in the assignment");
|
|
19676
19546
|
}
|
|
19677
19547
|
else {
|
|
19548
|
+
const binaryReceiver = new KeyedRead(this.span(start), this.sourceSpan(start), receiver, key);
|
|
19678
19549
|
const value = this.parseConditional();
|
|
19679
|
-
return new
|
|
19550
|
+
return new Binary(this.span(start), this.sourceSpan(start), '=', binaryReceiver, value);
|
|
19680
19551
|
}
|
|
19681
19552
|
}
|
|
19682
19553
|
else {
|
|
@@ -19979,9 +19850,6 @@ class SerializeExpressionVisitor {
|
|
|
19979
19850
|
visitKeyedRead(ast, context) {
|
|
19980
19851
|
return `${ast.receiver.visit(this, context)}[${ast.key.visit(this, context)}]`;
|
|
19981
19852
|
}
|
|
19982
|
-
visitKeyedWrite(ast, context) {
|
|
19983
|
-
return `${ast.receiver.visit(this, context)}[${ast.key.visit(this, context)}] = ${ast.value.visit(this, context)}`;
|
|
19984
|
-
}
|
|
19985
19853
|
visitLiteralArray(ast, context) {
|
|
19986
19854
|
return `[${ast.expressions.map((e) => e.visit(this, context)).join(', ')}]`;
|
|
19987
19855
|
}
|
|
@@ -20022,14 +19890,6 @@ class SerializeExpressionVisitor {
|
|
|
20022
19890
|
return `${ast.receiver.visit(this, context)}.${ast.name}`;
|
|
20023
19891
|
}
|
|
20024
19892
|
}
|
|
20025
|
-
visitPropertyWrite(ast, context) {
|
|
20026
|
-
if (ast.receiver instanceof ImplicitReceiver) {
|
|
20027
|
-
return `${ast.name} = ${ast.value.visit(this, context)}`;
|
|
20028
|
-
}
|
|
20029
|
-
else {
|
|
20030
|
-
return `${ast.receiver.visit(this, context)}.${ast.name} = ${ast.value.visit(this, context)}`;
|
|
20031
|
-
}
|
|
20032
|
-
}
|
|
20033
19893
|
visitSafePropertyRead(ast, context) {
|
|
20034
19894
|
return `${ast.receiver.visit(this, context)}?.${ast.name}`;
|
|
20035
19895
|
}
|
|
@@ -21646,7 +21506,7 @@ function createGoogleGetMsgStatements(variable$1, message, closureVar, placehold
|
|
|
21646
21506
|
// */
|
|
21647
21507
|
// const MSG_... = goog.getMsg(..);
|
|
21648
21508
|
// I18N_X = MSG_...;
|
|
21649
|
-
const googGetMsgStmt = closureVar.
|
|
21509
|
+
const googGetMsgStmt = new DeclareVarStmt(closureVar.name, variable(GOOG_GET_MSG).callFn(args), INFERRED_TYPE, StmtModifier.Final);
|
|
21650
21510
|
googGetMsgStmt.addLeadingComment(i18nMetaToJSDoc(message));
|
|
21651
21511
|
const i18nAssignmentStmt = new ExpressionStatement(variable$1.set(closureVar));
|
|
21652
21512
|
return [googGetMsgStmt, i18nAssignmentStmt];
|
|
@@ -23776,10 +23636,9 @@ function reifyCreateOperations(unit, ops) {
|
|
|
23776
23636
|
args = [];
|
|
23777
23637
|
}
|
|
23778
23638
|
else {
|
|
23779
|
-
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
args = [op.trigger.targetSlot.slot];
|
|
23639
|
+
// The slots not being defined at this point is invalid, however we
|
|
23640
|
+
// catch it during type checking. Pass in null in such cases.
|
|
23641
|
+
args = [op.trigger.targetSlot?.slot ?? null];
|
|
23783
23642
|
if (op.trigger.targetSlotViewSteps !== 0) {
|
|
23784
23643
|
args.push(op.trigger.targetSlotViewSteps);
|
|
23785
23644
|
}
|
|
@@ -26695,17 +26554,6 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
26695
26554
|
return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26696
26555
|
}
|
|
26697
26556
|
}
|
|
26698
|
-
else if (ast instanceof PropertyWrite) {
|
|
26699
|
-
if (ast.receiver instanceof ImplicitReceiver) {
|
|
26700
|
-
return new WritePropExpr(
|
|
26701
|
-
// TODO: Is it correct to always use the root context in place of the implicit receiver?
|
|
26702
|
-
new ContextExpr(job.root.xref), ast.name, convertAst(ast.value, job, baseSourceSpan), null, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26703
|
-
}
|
|
26704
|
-
return new WritePropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, convertAst(ast.value, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26705
|
-
}
|
|
26706
|
-
else if (ast instanceof KeyedWrite) {
|
|
26707
|
-
return new WriteKeyExpr(convertAst(ast.receiver, job, baseSourceSpan), convertAst(ast.key, job, baseSourceSpan), convertAst(ast.value, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26708
|
-
}
|
|
26709
26557
|
else if (ast instanceof Call) {
|
|
26710
26558
|
if (ast.receiver instanceof ImplicitReceiver) {
|
|
26711
26559
|
throw new Error(`Unexpected ImplicitReceiver`);
|
|
@@ -27196,6 +27044,12 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
|
|
|
27196
27044
|
* internal tooling as well.
|
|
27197
27045
|
*/
|
|
27198
27046
|
let ENABLE_TEMPLATE_SOURCE_LOCATIONS = false;
|
|
27047
|
+
/**
|
|
27048
|
+
* Utility function to enable source locations. Intended to be used **only** inside unit tests.
|
|
27049
|
+
*/
|
|
27050
|
+
function setEnableTemplateSourceLocations(value) {
|
|
27051
|
+
ENABLE_TEMPLATE_SOURCE_LOCATIONS = value;
|
|
27052
|
+
}
|
|
27199
27053
|
/** Gets whether template source locations are enabled. */
|
|
27200
27054
|
function getTemplateSourceLocationsEnabled() {
|
|
27201
27055
|
return ENABLE_TEMPLATE_SOURCE_LOCATIONS;
|
|
@@ -28514,7 +28368,7 @@ class OnTriggerParser {
|
|
|
28514
28368
|
this.trackTrigger('timer', createTimerTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan));
|
|
28515
28369
|
break;
|
|
28516
28370
|
case OnTriggerType.INTERACTION:
|
|
28517
|
-
this.trackTrigger('interaction', createInteractionTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.
|
|
28371
|
+
this.trackTrigger('interaction', createInteractionTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.validator));
|
|
28518
28372
|
break;
|
|
28519
28373
|
case OnTriggerType.IMMEDIATE:
|
|
28520
28374
|
this.trackTrigger('immediate', createImmediateTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan));
|
|
@@ -28523,7 +28377,7 @@ class OnTriggerParser {
|
|
|
28523
28377
|
this.trackTrigger('hover', createHoverTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.placeholder, this.validator));
|
|
28524
28378
|
break;
|
|
28525
28379
|
case OnTriggerType.VIEWPORT:
|
|
28526
|
-
this.trackTrigger('viewport', createViewportTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.
|
|
28380
|
+
this.trackTrigger('viewport', createViewportTrigger(parameters, nameSpan, sourceSpan, this.prefetchSpan, this.onSourceSpan, this.hydrateSpan, this.validator));
|
|
28527
28381
|
break;
|
|
28528
28382
|
default:
|
|
28529
28383
|
throw new Error(`Unrecognized trigger type "${identifier}"`);
|
|
@@ -28636,36 +28490,26 @@ function createImmediateTrigger(parameters, nameSpan, sourceSpan, prefetchSpan,
|
|
|
28636
28490
|
return new ImmediateDeferredTrigger(nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
|
|
28637
28491
|
}
|
|
28638
28492
|
function createHoverTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, placeholder, validator) {
|
|
28639
|
-
validator(OnTriggerType.HOVER, parameters
|
|
28493
|
+
validator(OnTriggerType.HOVER, parameters);
|
|
28640
28494
|
return new HoverDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
|
|
28641
28495
|
}
|
|
28642
|
-
function createInteractionTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan,
|
|
28643
|
-
validator(OnTriggerType.INTERACTION, parameters
|
|
28496
|
+
function createInteractionTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, validator) {
|
|
28497
|
+
validator(OnTriggerType.INTERACTION, parameters);
|
|
28644
28498
|
return new InteractionDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
|
|
28645
28499
|
}
|
|
28646
|
-
function createViewportTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan,
|
|
28647
|
-
validator(OnTriggerType.VIEWPORT, parameters
|
|
28500
|
+
function createViewportTrigger(parameters, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan, validator) {
|
|
28501
|
+
validator(OnTriggerType.VIEWPORT, parameters);
|
|
28648
28502
|
return new ViewportDeferredTrigger(parameters[0] ?? null, nameSpan, sourceSpan, prefetchSpan, onSourceSpan, hydrateSpan);
|
|
28649
28503
|
}
|
|
28650
28504
|
/**
|
|
28651
28505
|
* Checks whether the structure of a non-hydrate reference-based trigger is valid.
|
|
28652
28506
|
* @param type Type of the trigger being validated.
|
|
28653
28507
|
* @param parameters Parameters of the trigger.
|
|
28654
|
-
* @param placeholder Placeholder of the defer block.
|
|
28655
28508
|
*/
|
|
28656
|
-
function validatePlainReferenceBasedTrigger(type, parameters
|
|
28509
|
+
function validatePlainReferenceBasedTrigger(type, parameters) {
|
|
28657
28510
|
if (parameters.length > 1) {
|
|
28658
28511
|
throw new Error(`"${type}" trigger can only have zero or one parameters`);
|
|
28659
28512
|
}
|
|
28660
|
-
if (parameters.length === 0) {
|
|
28661
|
-
if (placeholder === null) {
|
|
28662
|
-
throw new Error(`"${type}" trigger with no parameters can only be placed on an @defer that has a @placeholder block`);
|
|
28663
|
-
}
|
|
28664
|
-
if (placeholder.children.length !== 1 || !(placeholder.children[0] instanceof Element$1)) {
|
|
28665
|
-
throw new Error(`"${type}" trigger with no parameters can only be placed on an @defer that has a ` +
|
|
28666
|
-
`@placeholder block with exactly one root element node`);
|
|
28667
|
-
}
|
|
28668
|
-
}
|
|
28669
28513
|
}
|
|
28670
28514
|
/**
|
|
28671
28515
|
* Checks whether the structure of a hydrate trigger is valid.
|
|
@@ -28992,7 +28836,7 @@ class HtmlAstToIvyAst {
|
|
|
28992
28836
|
if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
|
|
28993
28837
|
const selector = preparsedElement.selectAttr;
|
|
28994
28838
|
const attrs = element.attrs.map((attr) => this.visitAttribute(attr));
|
|
28995
|
-
parsedElement = new Content(selector, attrs, children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
28839
|
+
parsedElement = new Content(selector, attrs, children, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
28996
28840
|
this.ngContentSelectors.push(selector);
|
|
28997
28841
|
}
|
|
28998
28842
|
else if (isTemplateElement) {
|
|
@@ -29000,11 +28844,11 @@ class HtmlAstToIvyAst {
|
|
|
29000
28844
|
const attrs = this.categorizePropertyAttributes(element.name, parsedProperties, i18nAttrsMeta);
|
|
29001
28845
|
parsedElement = new Template(element.name, attributes, attrs.bound, boundEvents, directives, [
|
|
29002
28846
|
/* no template attributes */
|
|
29003
|
-
], children, references, variables, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
28847
|
+
], children, references, variables, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
29004
28848
|
}
|
|
29005
28849
|
else {
|
|
29006
28850
|
const attrs = this.categorizePropertyAttributes(element.name, parsedProperties, i18nAttrsMeta);
|
|
29007
|
-
parsedElement = new Element$1(element.name, attributes, attrs.bound, boundEvents, directives, children, references, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
28851
|
+
parsedElement = new Element$1(element.name, attributes, attrs.bound, boundEvents, directives, children, references, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
|
|
29008
28852
|
}
|
|
29009
28853
|
if (elementHasInlineTemplate) {
|
|
29010
28854
|
// If this node is an inline-template (e.g. has *ngFor) then we need to create a template
|
|
@@ -29099,7 +28943,7 @@ class HtmlAstToIvyAst {
|
|
|
29099
28943
|
children = visitAll(this, component.children, component.children);
|
|
29100
28944
|
}
|
|
29101
28945
|
const attrs = this.categorizePropertyAttributes(component.tagName, parsedProperties, i18nAttrsMeta);
|
|
29102
|
-
let node = new Component$1(component.componentName, component.tagName, component.fullName, attributes, attrs.bound, boundEvents, directives, children, references, component.sourceSpan, component.startSourceSpan, component.endSourceSpan, component.i18n);
|
|
28946
|
+
let node = new Component$1(component.componentName, component.tagName, component.fullName, attributes, attrs.bound, boundEvents, directives, children, references, component.isSelfClosing, component.sourceSpan, component.startSourceSpan, component.endSourceSpan, component.i18n);
|
|
29103
28947
|
if (elementHasInlineTemplate) {
|
|
29104
28948
|
node = this.wrapInTemplate(node, templateParsedProperties, templateVariables, i18nAttrsMeta, false, isI18nRootElement);
|
|
29105
28949
|
}
|
|
@@ -29439,7 +29283,7 @@ class HtmlAstToIvyAst {
|
|
|
29439
29283
|
// Do not copy over the directives.
|
|
29440
29284
|
], templateAttrs, [node], [
|
|
29441
29285
|
// Do not copy over the references.
|
|
29442
|
-
], templateVariables, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, i18n);
|
|
29286
|
+
], templateVariables, false, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, i18n);
|
|
29443
29287
|
}
|
|
29444
29288
|
_visitTextWithInterpolation(value, sourceSpan, interpolatedTokens, i18n) {
|
|
29445
29289
|
const valueNoNgsp = replaceNgsp(value);
|
|
@@ -29510,7 +29354,7 @@ class NonBindableVisitor {
|
|
|
29510
29354
|
/* inputs */ [],
|
|
29511
29355
|
/* outputs */ [],
|
|
29512
29356
|
/* directives */ [], children,
|
|
29513
|
-
/* references */ [], ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
29357
|
+
/* references */ [], ast.isSelfClosing, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
29514
29358
|
}
|
|
29515
29359
|
visitComment(comment) {
|
|
29516
29360
|
return null;
|
|
@@ -29551,7 +29395,7 @@ class NonBindableVisitor {
|
|
|
29551
29395
|
/* inputs */ [],
|
|
29552
29396
|
/* outputs */ [],
|
|
29553
29397
|
/* directives */ [], children,
|
|
29554
|
-
/* references */ [], ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
29398
|
+
/* references */ [], ast.isSelfClosing, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
29555
29399
|
}
|
|
29556
29400
|
visitDirective(directive, context) {
|
|
29557
29401
|
return null;
|
|
@@ -29583,7 +29427,8 @@ const LEADING_TRIVIA_CHARS = [' ', '\n', '\r', '\t'];
|
|
|
29583
29427
|
*/
|
|
29584
29428
|
function parseTemplate(template, templateUrl, options = {}) {
|
|
29585
29429
|
const { interpolationConfig, preserveWhitespaces, enableI18nLegacyMessageIdFormat } = options;
|
|
29586
|
-
const
|
|
29430
|
+
const selectorlessEnabled = options.enableSelectorless ?? false;
|
|
29431
|
+
const bindingParser = makeBindingParser(interpolationConfig, selectorlessEnabled);
|
|
29587
29432
|
const htmlParser = new HtmlParser();
|
|
29588
29433
|
const parseResult = htmlParser.parse(template, templateUrl, {
|
|
29589
29434
|
leadingTriviaChars: LEADING_TRIVIA_CHARS,
|
|
@@ -29591,7 +29436,7 @@ function parseTemplate(template, templateUrl, options = {}) {
|
|
|
29591
29436
|
tokenizeExpansionForms: true,
|
|
29592
29437
|
tokenizeBlocks: options.enableBlockSyntax ?? true,
|
|
29593
29438
|
tokenizeLet: options.enableLetSyntax ?? true,
|
|
29594
|
-
selectorlessEnabled
|
|
29439
|
+
selectorlessEnabled,
|
|
29595
29440
|
});
|
|
29596
29441
|
if (!options.alwaysAttemptHtmlToR3AstConversion &&
|
|
29597
29442
|
parseResult.errors &&
|
|
@@ -29690,8 +29535,8 @@ const elementRegistry = new DomElementSchemaRegistry();
|
|
|
29690
29535
|
/**
|
|
29691
29536
|
* Construct a `BindingParser` with a default configuration.
|
|
29692
29537
|
*/
|
|
29693
|
-
function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
|
|
29694
|
-
return new BindingParser(new Parser(new Lexer()), interpolationConfig, elementRegistry, []);
|
|
29538
|
+
function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG, selectorlessEnabled = false) {
|
|
29539
|
+
return new BindingParser(new Parser(new Lexer(), selectorlessEnabled), interpolationConfig, elementRegistry, []);
|
|
29695
29540
|
}
|
|
29696
29541
|
|
|
29697
29542
|
const COMPONENT_VARIABLE = '%COMP%';
|
|
@@ -30220,6 +30065,132 @@ function compileDeferResolverFunction(meta) {
|
|
|
30220
30065
|
return arrowFn([], literalArr(depExpressions));
|
|
30221
30066
|
}
|
|
30222
30067
|
|
|
30068
|
+
/*!
|
|
30069
|
+
* @license
|
|
30070
|
+
* Copyright Google LLC All Rights Reserved.
|
|
30071
|
+
*
|
|
30072
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
30073
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
30074
|
+
*/
|
|
30075
|
+
/**
|
|
30076
|
+
* Visitor that traverses all template and expression AST nodes in a template.
|
|
30077
|
+
* Useful for cases where every single node needs to be visited.
|
|
30078
|
+
*/
|
|
30079
|
+
class CombinedRecursiveAstVisitor extends RecursiveAstVisitor {
|
|
30080
|
+
visit(node) {
|
|
30081
|
+
if (node instanceof ASTWithSource) {
|
|
30082
|
+
this.visit(node.ast);
|
|
30083
|
+
}
|
|
30084
|
+
else {
|
|
30085
|
+
node.visit(this);
|
|
30086
|
+
}
|
|
30087
|
+
}
|
|
30088
|
+
visitElement(element) {
|
|
30089
|
+
this.visitAllTemplateNodes(element.attributes);
|
|
30090
|
+
this.visitAllTemplateNodes(element.inputs);
|
|
30091
|
+
this.visitAllTemplateNodes(element.outputs);
|
|
30092
|
+
this.visitAllTemplateNodes(element.directives);
|
|
30093
|
+
this.visitAllTemplateNodes(element.references);
|
|
30094
|
+
this.visitAllTemplateNodes(element.children);
|
|
30095
|
+
}
|
|
30096
|
+
visitTemplate(template) {
|
|
30097
|
+
this.visitAllTemplateNodes(template.attributes);
|
|
30098
|
+
this.visitAllTemplateNodes(template.inputs);
|
|
30099
|
+
this.visitAllTemplateNodes(template.outputs);
|
|
30100
|
+
this.visitAllTemplateNodes(template.directives);
|
|
30101
|
+
this.visitAllTemplateNodes(template.templateAttrs);
|
|
30102
|
+
this.visitAllTemplateNodes(template.variables);
|
|
30103
|
+
this.visitAllTemplateNodes(template.references);
|
|
30104
|
+
this.visitAllTemplateNodes(template.children);
|
|
30105
|
+
}
|
|
30106
|
+
visitContent(content) {
|
|
30107
|
+
this.visitAllTemplateNodes(content.children);
|
|
30108
|
+
}
|
|
30109
|
+
visitBoundAttribute(attribute) {
|
|
30110
|
+
this.visit(attribute.value);
|
|
30111
|
+
}
|
|
30112
|
+
visitBoundEvent(attribute) {
|
|
30113
|
+
this.visit(attribute.handler);
|
|
30114
|
+
}
|
|
30115
|
+
visitBoundText(text) {
|
|
30116
|
+
this.visit(text.value);
|
|
30117
|
+
}
|
|
30118
|
+
visitIcu(icu) {
|
|
30119
|
+
Object.keys(icu.vars).forEach((key) => this.visit(icu.vars[key]));
|
|
30120
|
+
Object.keys(icu.placeholders).forEach((key) => this.visit(icu.placeholders[key]));
|
|
30121
|
+
}
|
|
30122
|
+
visitDeferredBlock(deferred) {
|
|
30123
|
+
deferred.visitAll(this);
|
|
30124
|
+
}
|
|
30125
|
+
visitDeferredTrigger(trigger) {
|
|
30126
|
+
if (trigger instanceof BoundDeferredTrigger) {
|
|
30127
|
+
this.visit(trigger.value);
|
|
30128
|
+
}
|
|
30129
|
+
}
|
|
30130
|
+
visitDeferredBlockPlaceholder(block) {
|
|
30131
|
+
this.visitAllTemplateNodes(block.children);
|
|
30132
|
+
}
|
|
30133
|
+
visitDeferredBlockError(block) {
|
|
30134
|
+
this.visitAllTemplateNodes(block.children);
|
|
30135
|
+
}
|
|
30136
|
+
visitDeferredBlockLoading(block) {
|
|
30137
|
+
this.visitAllTemplateNodes(block.children);
|
|
30138
|
+
}
|
|
30139
|
+
visitSwitchBlock(block) {
|
|
30140
|
+
this.visit(block.expression);
|
|
30141
|
+
this.visitAllTemplateNodes(block.cases);
|
|
30142
|
+
}
|
|
30143
|
+
visitSwitchBlockCase(block) {
|
|
30144
|
+
block.expression && this.visit(block.expression);
|
|
30145
|
+
this.visitAllTemplateNodes(block.children);
|
|
30146
|
+
}
|
|
30147
|
+
visitForLoopBlock(block) {
|
|
30148
|
+
block.item.visit(this);
|
|
30149
|
+
this.visitAllTemplateNodes(block.contextVariables);
|
|
30150
|
+
this.visit(block.expression);
|
|
30151
|
+
this.visitAllTemplateNodes(block.children);
|
|
30152
|
+
block.empty?.visit(this);
|
|
30153
|
+
}
|
|
30154
|
+
visitForLoopBlockEmpty(block) {
|
|
30155
|
+
this.visitAllTemplateNodes(block.children);
|
|
30156
|
+
}
|
|
30157
|
+
visitIfBlock(block) {
|
|
30158
|
+
this.visitAllTemplateNodes(block.branches);
|
|
30159
|
+
}
|
|
30160
|
+
visitIfBlockBranch(block) {
|
|
30161
|
+
block.expression && this.visit(block.expression);
|
|
30162
|
+
block.expressionAlias?.visit(this);
|
|
30163
|
+
this.visitAllTemplateNodes(block.children);
|
|
30164
|
+
}
|
|
30165
|
+
visitLetDeclaration(decl) {
|
|
30166
|
+
this.visit(decl.value);
|
|
30167
|
+
}
|
|
30168
|
+
visitComponent(component) {
|
|
30169
|
+
this.visitAllTemplateNodes(component.attributes);
|
|
30170
|
+
this.visitAllTemplateNodes(component.inputs);
|
|
30171
|
+
this.visitAllTemplateNodes(component.outputs);
|
|
30172
|
+
this.visitAllTemplateNodes(component.directives);
|
|
30173
|
+
this.visitAllTemplateNodes(component.references);
|
|
30174
|
+
this.visitAllTemplateNodes(component.children);
|
|
30175
|
+
}
|
|
30176
|
+
visitDirective(directive) {
|
|
30177
|
+
this.visitAllTemplateNodes(directive.attributes);
|
|
30178
|
+
this.visitAllTemplateNodes(directive.inputs);
|
|
30179
|
+
this.visitAllTemplateNodes(directive.outputs);
|
|
30180
|
+
this.visitAllTemplateNodes(directive.references);
|
|
30181
|
+
}
|
|
30182
|
+
visitVariable(variable) { }
|
|
30183
|
+
visitReference(reference) { }
|
|
30184
|
+
visitTextAttribute(attribute) { }
|
|
30185
|
+
visitText(text) { }
|
|
30186
|
+
visitUnknownBlock(block) { }
|
|
30187
|
+
visitAllTemplateNodes(nodes) {
|
|
30188
|
+
for (const node of nodes) {
|
|
30189
|
+
this.visit(node);
|
|
30190
|
+
}
|
|
30191
|
+
}
|
|
30192
|
+
}
|
|
30193
|
+
|
|
30223
30194
|
/**
|
|
30224
30195
|
* Computes a difference between full list (first argument) and
|
|
30225
30196
|
* list of items that should be excluded from the full list (second
|
|
@@ -30323,9 +30294,7 @@ class R3TargetBinder {
|
|
|
30323
30294
|
// - bindings: Map of inputs, outputs, and attributes to the directive/element that claims
|
|
30324
30295
|
// them. TODO(alxhub): handle multiple directives claiming an input/output/etc.
|
|
30325
30296
|
// - references: Map of #references to their targets.
|
|
30326
|
-
|
|
30327
|
-
DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
|
|
30328
|
-
}
|
|
30297
|
+
DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
|
|
30329
30298
|
// Finally, run the TemplateBinder to bind references, variables, and other entities within the
|
|
30330
30299
|
// template. This extracts all the metadata that doesn't depend on directive matching.
|
|
30331
30300
|
TemplateBinder.applyWithScope(target.template, scope, expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
|
|
@@ -30659,6 +30628,13 @@ class DirectiveBinder {
|
|
|
30659
30628
|
this.directiveMatcher.match(cssSelector, (_, results) => directives.push(...results));
|
|
30660
30629
|
this.trackSelectorBasedBindingsAndDirectives(node, directives);
|
|
30661
30630
|
}
|
|
30631
|
+
else {
|
|
30632
|
+
node.references.forEach((ref) => {
|
|
30633
|
+
if (ref.value.trim() === '') {
|
|
30634
|
+
this.references.set(ref, node);
|
|
30635
|
+
}
|
|
30636
|
+
});
|
|
30637
|
+
}
|
|
30662
30638
|
node.directives.forEach((directive) => directive.visit(this));
|
|
30663
30639
|
node.children.forEach((child) => child.visit(this));
|
|
30664
30640
|
}
|
|
@@ -30761,7 +30737,7 @@ class DirectiveBinder {
|
|
|
30761
30737
|
* Expressions are visited by the superclass `RecursiveAstVisitor`, with custom logic provided
|
|
30762
30738
|
* by overridden methods from that visitor.
|
|
30763
30739
|
*/
|
|
30764
|
-
class TemplateBinder extends
|
|
30740
|
+
class TemplateBinder extends CombinedRecursiveAstVisitor {
|
|
30765
30741
|
bindings;
|
|
30766
30742
|
symbols;
|
|
30767
30743
|
usedPipes;
|
|
@@ -30771,7 +30747,7 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30771
30747
|
scope;
|
|
30772
30748
|
rootNode;
|
|
30773
30749
|
level;
|
|
30774
|
-
visitNode;
|
|
30750
|
+
visitNode = (node) => node.visit(this);
|
|
30775
30751
|
constructor(bindings, symbols, usedPipes, eagerPipes, deferBlocks, nestingLevel, scope, rootNode, level) {
|
|
30776
30752
|
super();
|
|
30777
30753
|
this.bindings = bindings;
|
|
@@ -30783,19 +30759,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30783
30759
|
this.scope = scope;
|
|
30784
30760
|
this.rootNode = rootNode;
|
|
30785
30761
|
this.level = level;
|
|
30786
|
-
// Save a bit of processing time by constructing this closure in advance.
|
|
30787
|
-
this.visitNode = (node) => node.visit(this);
|
|
30788
|
-
}
|
|
30789
|
-
// This method is defined to reconcile the type of TemplateBinder since both
|
|
30790
|
-
// RecursiveAstVisitor and Visitor define the visit() method in their
|
|
30791
|
-
// interfaces.
|
|
30792
|
-
visit(node, context) {
|
|
30793
|
-
if (node instanceof AST) {
|
|
30794
|
-
node.visit(this, context);
|
|
30795
|
-
}
|
|
30796
|
-
else {
|
|
30797
|
-
node.visit(this);
|
|
30798
|
-
}
|
|
30799
30762
|
}
|
|
30800
30763
|
/**
|
|
30801
30764
|
* Process a template and extract metadata about expressions and symbols within.
|
|
@@ -30864,14 +30827,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30864
30827
|
nodeOrNodes.forEach(this.visitNode);
|
|
30865
30828
|
}
|
|
30866
30829
|
}
|
|
30867
|
-
visitElement(element) {
|
|
30868
|
-
// Visit the inputs, outputs, and children of the element.
|
|
30869
|
-
element.inputs.forEach(this.visitNode);
|
|
30870
|
-
element.outputs.forEach(this.visitNode);
|
|
30871
|
-
element.directives.forEach(this.visitNode);
|
|
30872
|
-
element.children.forEach(this.visitNode);
|
|
30873
|
-
element.references.forEach(this.visitNode);
|
|
30874
|
-
}
|
|
30875
30830
|
visitTemplate(template) {
|
|
30876
30831
|
// First, visit inputs, outputs and template attributes of the template node.
|
|
30877
30832
|
template.inputs.forEach(this.visitNode);
|
|
@@ -30894,34 +30849,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30894
30849
|
this.symbols.set(reference, this.rootNode);
|
|
30895
30850
|
}
|
|
30896
30851
|
}
|
|
30897
|
-
visitComponent(component) {
|
|
30898
|
-
component.inputs.forEach(this.visitNode);
|
|
30899
|
-
component.outputs.forEach(this.visitNode);
|
|
30900
|
-
component.directives.forEach(this.visitNode);
|
|
30901
|
-
component.children.forEach(this.visitNode);
|
|
30902
|
-
component.references.forEach(this.visitNode);
|
|
30903
|
-
}
|
|
30904
|
-
visitDirective(directive) {
|
|
30905
|
-
directive.inputs.forEach(this.visitNode);
|
|
30906
|
-
directive.outputs.forEach(this.visitNode);
|
|
30907
|
-
directive.references.forEach(this.visitNode);
|
|
30908
|
-
}
|
|
30909
|
-
// Unused template visitors
|
|
30910
|
-
visitText(text) { }
|
|
30911
|
-
visitTextAttribute(attribute) { }
|
|
30912
|
-
visitUnknownBlock(block) { }
|
|
30913
|
-
visitDeferredTrigger() { }
|
|
30914
|
-
visitIcu(icu) {
|
|
30915
|
-
Object.keys(icu.vars).forEach((key) => icu.vars[key].visit(this));
|
|
30916
|
-
Object.keys(icu.placeholders).forEach((key) => icu.placeholders[key].visit(this));
|
|
30917
|
-
}
|
|
30918
|
-
// The remaining visitors are concerned with processing AST expressions within template bindings
|
|
30919
|
-
visitBoundAttribute(attribute) {
|
|
30920
|
-
attribute.value.visit(this);
|
|
30921
|
-
}
|
|
30922
|
-
visitBoundEvent(event) {
|
|
30923
|
-
event.handler.visit(this);
|
|
30924
|
-
}
|
|
30925
30852
|
visitDeferredBlock(deferred) {
|
|
30926
30853
|
this.ingestScopedNode(deferred);
|
|
30927
30854
|
deferred.triggers.when?.value.visit(this);
|
|
@@ -30941,10 +30868,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30941
30868
|
visitDeferredBlockLoading(block) {
|
|
30942
30869
|
this.ingestScopedNode(block);
|
|
30943
30870
|
}
|
|
30944
|
-
visitSwitchBlock(block) {
|
|
30945
|
-
block.expression.visit(this);
|
|
30946
|
-
block.cases.forEach(this.visitNode);
|
|
30947
|
-
}
|
|
30948
30871
|
visitSwitchBlockCase(block) {
|
|
30949
30872
|
block.expression?.visit(this);
|
|
30950
30873
|
this.ingestScopedNode(block);
|
|
@@ -30957,9 +30880,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30957
30880
|
visitForLoopBlockEmpty(block) {
|
|
30958
30881
|
this.ingestScopedNode(block);
|
|
30959
30882
|
}
|
|
30960
|
-
visitIfBlock(block) {
|
|
30961
|
-
block.branches.forEach((node) => node.visit(this));
|
|
30962
|
-
}
|
|
30963
30883
|
visitIfBlockBranch(block) {
|
|
30964
30884
|
block.expression?.visit(this);
|
|
30965
30885
|
this.ingestScopedNode(block);
|
|
@@ -30967,11 +30887,8 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30967
30887
|
visitContent(content) {
|
|
30968
30888
|
this.ingestScopedNode(content);
|
|
30969
30889
|
}
|
|
30970
|
-
visitBoundText(text) {
|
|
30971
|
-
text.value.visit(this);
|
|
30972
|
-
}
|
|
30973
30890
|
visitLetDeclaration(decl) {
|
|
30974
|
-
|
|
30891
|
+
super.visitLetDeclaration(decl);
|
|
30975
30892
|
if (this.rootNode !== null) {
|
|
30976
30893
|
this.symbols.set(decl, this.rootNode);
|
|
30977
30894
|
}
|
|
@@ -30993,10 +30910,6 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
30993
30910
|
this.maybeMap(ast, ast.name);
|
|
30994
30911
|
return super.visitSafePropertyRead(ast, context);
|
|
30995
30912
|
}
|
|
30996
|
-
visitPropertyWrite(ast, context) {
|
|
30997
|
-
this.maybeMap(ast, ast.name);
|
|
30998
|
-
return super.visitPropertyWrite(ast, context);
|
|
30999
|
-
}
|
|
31000
30913
|
ingestScopedNode(node) {
|
|
31001
30914
|
const childScope = this.scope.getChildScope(node);
|
|
31002
30915
|
const binder = new TemplateBinder(this.bindings, this.symbols, this.usedPipes, this.eagerPipes, this.deferBlocks, this.nestingLevel, childScope, node, this.level + 1);
|
|
@@ -31102,7 +31015,7 @@ class R3BoundTarget {
|
|
|
31102
31015
|
}
|
|
31103
31016
|
const name = trigger.reference;
|
|
31104
31017
|
if (name === null) {
|
|
31105
|
-
let
|
|
31018
|
+
let target = null;
|
|
31106
31019
|
if (block.placeholder !== null) {
|
|
31107
31020
|
for (const child of block.placeholder.children) {
|
|
31108
31021
|
// Skip over comment nodes. Currently by default the template parser doesn't capture
|
|
@@ -31112,15 +31025,15 @@ class R3BoundTarget {
|
|
|
31112
31025
|
}
|
|
31113
31026
|
// We can only infer the trigger if there's one root element node. Any other
|
|
31114
31027
|
// nodes at the root make it so that we can't infer the trigger anymore.
|
|
31115
|
-
if (
|
|
31028
|
+
if (target !== null) {
|
|
31116
31029
|
return null;
|
|
31117
31030
|
}
|
|
31118
31031
|
if (child instanceof Element$1) {
|
|
31119
|
-
|
|
31032
|
+
target = child;
|
|
31120
31033
|
}
|
|
31121
31034
|
}
|
|
31122
31035
|
}
|
|
31123
|
-
return
|
|
31036
|
+
return target;
|
|
31124
31037
|
}
|
|
31125
31038
|
const outsideRef = this.findEntityInScope(block, name);
|
|
31126
31039
|
// First try to resolve the target in the scope of the main deferred block. Note that we
|
|
@@ -31238,8 +31151,10 @@ class CompilerFacadeImpl {
|
|
|
31238
31151
|
}
|
|
31239
31152
|
compilePipe(angularCoreEnv, sourceMapUrl, facade) {
|
|
31240
31153
|
const metadata = {
|
|
31154
|
+
name: facade.name,
|
|
31241
31155
|
type: wrapReference(facade.type),
|
|
31242
31156
|
typeArgumentCount: 0,
|
|
31157
|
+
deps: null,
|
|
31243
31158
|
pipeName: facade.pipeName,
|
|
31244
31159
|
pure: facade.pure,
|
|
31245
31160
|
isStandalone: facade.isStandalone,
|
|
@@ -31284,6 +31199,7 @@ class CompilerFacadeImpl {
|
|
|
31284
31199
|
}
|
|
31285
31200
|
compileInjector(angularCoreEnv, sourceMapUrl, facade) {
|
|
31286
31201
|
const meta = {
|
|
31202
|
+
name: facade.name,
|
|
31287
31203
|
type: wrapReference(facade.type),
|
|
31288
31204
|
providers: facade.providers && facade.providers.length > 0
|
|
31289
31205
|
? new WrappedNodeExpr(facade.providers)
|
|
@@ -31981,7 +31897,7 @@ class _Visitor {
|
|
|
31981
31897
|
this._init(_VisitorMode.Merge, interpolationConfig);
|
|
31982
31898
|
this._translations = translations;
|
|
31983
31899
|
// Construct a single fake root element
|
|
31984
|
-
const wrapper = new Element('wrapper', [], [], nodes, undefined, undefined, undefined);
|
|
31900
|
+
const wrapper = new Element('wrapper', [], [], nodes, false, undefined, undefined, undefined);
|
|
31985
31901
|
const translatedNode = wrapper.visit(this, null);
|
|
31986
31902
|
if (this._inI18nBlock) {
|
|
31987
31903
|
this._reportError(nodes[nodes.length - 1], 'Unclosed block');
|
|
@@ -32159,10 +32075,10 @@ class _Visitor {
|
|
|
32159
32075
|
this._inImplicitNode = wasInImplicitNode;
|
|
32160
32076
|
if (this._mode === _VisitorMode.Merge) {
|
|
32161
32077
|
if (node instanceof Element) {
|
|
32162
|
-
return new Element(node.name, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
|
|
32078
|
+
return new Element(node.name, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
|
|
32163
32079
|
}
|
|
32164
32080
|
else {
|
|
32165
|
-
return new Component(node.componentName, node.tagName, node.fullName, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
|
|
32081
|
+
return new Component(node.componentName, node.tagName, node.fullName, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
|
|
32166
32082
|
}
|
|
32167
32083
|
}
|
|
32168
32084
|
return null;
|
|
@@ -33653,7 +33569,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
|
33653
33569
|
function compileDeclareClassMetadata(metadata) {
|
|
33654
33570
|
const definitionMap = new DefinitionMap();
|
|
33655
33571
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
33656
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
33572
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
33657
33573
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33658
33574
|
definitionMap.set('type', metadata.type);
|
|
33659
33575
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -33671,7 +33587,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
|
33671
33587
|
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
|
|
33672
33588
|
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
|
|
33673
33589
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
33674
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
33590
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
33675
33591
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33676
33592
|
definitionMap.set('type', metadata.type);
|
|
33677
33593
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
@@ -33766,7 +33682,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
33766
33682
|
const definitionMap = new DefinitionMap();
|
|
33767
33683
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
33768
33684
|
definitionMap.set('minVersion', literal(minVersion));
|
|
33769
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
33685
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
33770
33686
|
// e.g. `type: MyDirective`
|
|
33771
33687
|
definitionMap.set('type', meta.type.value);
|
|
33772
33688
|
if (meta.isStandalone !== undefined) {
|
|
@@ -34182,7 +34098,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
34182
34098
|
function compileDeclareFactoryFunction(meta) {
|
|
34183
34099
|
const definitionMap = new DefinitionMap();
|
|
34184
34100
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
34185
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
34101
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
34186
34102
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34187
34103
|
definitionMap.set('type', meta.type.value);
|
|
34188
34104
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -34217,7 +34133,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
34217
34133
|
function createInjectableDefinitionMap(meta) {
|
|
34218
34134
|
const definitionMap = new DefinitionMap();
|
|
34219
34135
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
34220
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
34136
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
34221
34137
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34222
34138
|
definitionMap.set('type', meta.type.value);
|
|
34223
34139
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -34268,7 +34184,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
34268
34184
|
function createInjectorDefinitionMap(meta) {
|
|
34269
34185
|
const definitionMap = new DefinitionMap();
|
|
34270
34186
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
34271
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
34187
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
34272
34188
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34273
34189
|
definitionMap.set('type', meta.type.value);
|
|
34274
34190
|
definitionMap.set('providers', meta.providers);
|
|
@@ -34301,7 +34217,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
34301
34217
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
34302
34218
|
}
|
|
34303
34219
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
34304
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
34220
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
34305
34221
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34306
34222
|
definitionMap.set('type', meta.type.value);
|
|
34307
34223
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -34352,7 +34268,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
34352
34268
|
function createPipeDefinitionMap(meta) {
|
|
34353
34269
|
const definitionMap = new DefinitionMap();
|
|
34354
34270
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
34355
|
-
definitionMap.set('version', literal('20.0.0'));
|
|
34271
|
+
definitionMap.set('version', literal('20.1.0-next.0'));
|
|
34356
34272
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34357
34273
|
// e.g. `type: MyPipe`
|
|
34358
34274
|
definitionMap.set('type', meta.type.value);
|
|
@@ -34360,7 +34276,7 @@ function createPipeDefinitionMap(meta) {
|
|
|
34360
34276
|
definitionMap.set('isStandalone', literal(meta.isStandalone));
|
|
34361
34277
|
}
|
|
34362
34278
|
// e.g. `name: "myPipe"`
|
|
34363
|
-
definitionMap.set('name', literal(meta.pipeName));
|
|
34279
|
+
definitionMap.set('name', literal(meta.pipeName ?? meta.name));
|
|
34364
34280
|
if (meta.pure === false) {
|
|
34365
34281
|
// e.g. `pure: false`
|
|
34366
34282
|
definitionMap.set('pure', literal(meta.pure));
|
|
@@ -34508,7 +34424,7 @@ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
|
|
|
34508
34424
|
* @description
|
|
34509
34425
|
* Entry point for all public APIs of the compiler package.
|
|
34510
34426
|
*/
|
|
34511
|
-
const VERSION = new Version('20.0.0');
|
|
34427
|
+
const VERSION = new Version('20.1.0-next.0');
|
|
34512
34428
|
|
|
34513
34429
|
//////////////////////////////////////
|
|
34514
34430
|
// THIS FILE HAS GLOBAL SIDE EFFECT //
|
|
@@ -34534,5 +34450,5 @@ const VERSION = new Version('20.0.0');
|
|
|
34534
34450
|
// the late binding of the Compiler to the @angular/core for jit compilation.
|
|
34535
34451
|
publishFacade(_global);
|
|
34536
34452
|
|
|
34537
|
-
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, CompilerFacadeImpl, Component, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, Directive, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead,
|
|
34453
|
+
export { AST, ASTWithName, ASTWithSource, AbsoluteSourceSpan, ArrayType, ArrowFunctionExpr, Attribute, Binary, BinaryOperator, BinaryOperatorExpr, BindingPipe, BindingPipeType, BindingType, Block, BlockParameter, BoundElementProperty, BuiltinType, BuiltinTypeName, CUSTOM_ELEMENTS_SCHEMA, Call, Chain, ChangeDetectionStrategy, CombinedRecursiveAstVisitor, CommaExpr, Comment, CompilerConfig, CompilerFacadeImpl, Component, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, Directive, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead, LeadingComment, LetDeclaration, Lexer, LiteralArray, LiteralArrayExpr, LiteralExpr, LiteralMap, LiteralMapExpr, LiteralPrimitive, LocalizedString, MapType, MessageBundle, NONE_TYPE, NO_ERRORS_SCHEMA, NodeWithI18n, NonNullAssert, NotExpr, ParenthesizedExpr, ParenthesizedExpression, ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseSpan, ParseTreeResult, ParsedEvent, ParsedEventType, ParsedProperty, ParsedPropertyType, ParsedVariable, Parser, ParserError, PrefixNot, PropertyRead, Identifiers as R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, R3TargetBinder, R3TemplateDependencyKind, ReadKeyExpr, ReadPropExpr, ReadVarExpr, RecursiveAstVisitor, RecursiveVisitor, ResourceLoader, ReturnStatement, SECURITY_SCHEMA, STRING_TYPE, SafeCall, SafeKeyedRead, SafePropertyRead, SelectorContext, SelectorListContext, SelectorMatcher, SelectorlessMatcher, 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, Component$1 as TmplAstComponent, Content as TmplAstContent, DeferredBlock as TmplAstDeferredBlock, DeferredBlockError as TmplAstDeferredBlockError, DeferredBlockLoading as TmplAstDeferredBlockLoading, DeferredBlockPlaceholder as TmplAstDeferredBlockPlaceholder, DeferredTrigger as TmplAstDeferredTrigger, Directive$1 as TmplAstDirective, Element$1 as TmplAstElement, ForLoopBlock as TmplAstForLoopBlock, ForLoopBlockEmpty as TmplAstForLoopBlockEmpty, HostElement as TmplAstHostElement, 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$1 as ViewEncapsulation, VoidExpr, VoidExpression, WrappedNodeExpr, 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, escapeRegExp, findMatchingDirectivesAndPipes, getHtmlTagDefinition, getNsPrefix, getSafePropertyAccessString, identifierName, isNgContainer, isNgContent, isNgTemplate, jsDocComment, leadingComment, literal, literalMap, makeBindingParser, mergeNsAndName, output_ast as outputAst, parseHostBindings, parseTemplate, preserveWhitespacesDefault, publishFacade, r3JitTypeSourceSpan, sanitizeIdentifier, setEnableTemplateSourceLocations, splitNsName, visitAll$1 as tmplAstVisitAll, verifyHostBindings, visitAll };
|
|
34538
34454
|
//# sourceMappingURL=compiler.mjs.map
|