@angular/core 20.0.1 → 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.
Files changed (69) hide show
  1. package/{api.d-B0vztftH.d.ts → api.d-Dwpmmn5j.d.ts} +2 -2
  2. package/{chrome_dev_tools_performance.d-DvzAxqBc.d.ts → chrome_dev_tools_performance.d-Dk_7kdX9.d.ts} +5 -1
  3. package/{discovery.d-CB2iJta5.d.ts → discovery.d-BAZTj_rM.d.ts} +2 -2
  4. package/event_dispatcher.d-BReQpZfC.d.ts +1 -1
  5. package/fesm2022/attribute-BWp59EjE.mjs +1 -1
  6. package/fesm2022/attribute-BWp59EjE.mjs.map +1 -1
  7. package/fesm2022/core.mjs +12 -11
  8. package/fesm2022/core.mjs.map +1 -1
  9. package/fesm2022/{debug_node-B9JawCEy.mjs → debug_node-CjNGi9N3.mjs} +1463 -1437
  10. package/fesm2022/debug_node-CjNGi9N3.mjs.map +1 -0
  11. package/fesm2022/primitives/di.mjs +1 -1
  12. package/fesm2022/primitives/di.mjs.map +1 -1
  13. package/fesm2022/primitives/event-dispatch.mjs +93 -2
  14. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  15. package/fesm2022/primitives/signals.mjs +3 -3
  16. package/fesm2022/primitives/signals.mjs.map +1 -1
  17. package/fesm2022/{resource-W6LObBPP.mjs → resource-1o9xbJml.mjs} +5 -5
  18. package/fesm2022/{resource-W6LObBPP.mjs.map → resource-1o9xbJml.mjs.map} +1 -1
  19. package/fesm2022/{root_effect_scheduler-C4AUixQF.mjs → root_effect_scheduler-Ds-Wmkv_.mjs} +16 -9
  20. package/fesm2022/root_effect_scheduler-Ds-Wmkv_.mjs.map +1 -0
  21. package/fesm2022/rxjs-interop.mjs +4 -4
  22. package/fesm2022/rxjs-interop.mjs.map +1 -1
  23. package/fesm2022/signal-BZ1SD--i.mjs +1 -1
  24. package/fesm2022/signal-BZ1SD--i.mjs.map +1 -1
  25. package/fesm2022/testing.mjs +22 -32
  26. package/fesm2022/testing.mjs.map +1 -1
  27. package/fesm2022/{untracked-RA6XPQ1Z.mjs → untracked-C72kieeB.mjs} +3 -3
  28. package/fesm2022/{untracked-RA6XPQ1Z.mjs.map → untracked-C72kieeB.mjs.map} +1 -1
  29. package/fesm2022/weak_ref-BaIq-pgY.mjs +1 -1
  30. package/fesm2022/weak_ref-BaIq-pgY.mjs.map +1 -1
  31. package/graph.d-BcIOep_B.d.ts +1 -1
  32. package/index.d.ts +10 -7
  33. package/package.json +2 -2
  34. package/primitives/di/index.d.ts +1 -1
  35. package/primitives/event-dispatch/index.d.ts +1 -1
  36. package/primitives/signals/index.d.ts +1 -1
  37. package/rxjs-interop/index.d.ts +3 -3
  38. package/schematics/bundles/{apply_import_manager-DT15wSJs.cjs → apply_import_manager-CSEu0fby.cjs} +3 -3
  39. package/schematics/bundles/{checker-Bu1Wu4f7.cjs → checker-CuQvkMhs.cjs} +680 -528
  40. package/schematics/bundles/cleanup-unused-imports.cjs +5 -5
  41. package/schematics/bundles/{compiler_host-C_4Iw5UD.cjs → compiler_host-Biezhzch.cjs} +2 -2
  42. package/schematics/bundles/control-flow-migration.cjs +3 -3
  43. package/schematics/bundles/document-core.cjs +5 -5
  44. package/schematics/bundles/imports-CIX-JgAN.cjs +1 -1
  45. package/schematics/bundles/{index-CCX_cTPD.cjs → index-C5wL4qaq.cjs} +1001 -585
  46. package/schematics/bundles/{index-CAM7Xiu7.cjs → index-vkqofxID.cjs} +17 -16
  47. package/schematics/bundles/inject-flags.cjs +5 -5
  48. package/schematics/bundles/inject-migration.cjs +3 -3
  49. package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
  50. package/schematics/bundles/{migrate_ts_type_references-DSqmdRpG.cjs → migrate_ts_type_references-BYgEQg0O.cjs} +26 -77
  51. package/schematics/bundles/ng_decorators-B5HCqr20.cjs +1 -1
  52. package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
  53. package/schematics/bundles/output-migration.cjs +6 -6
  54. package/schematics/bundles/{project_paths-BjQra9mv.cjs → project_paths-KPCsvRfl.cjs} +3 -3
  55. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
  56. package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
  57. package/schematics/bundles/route-lazy-loading.cjs +3 -3
  58. package/schematics/bundles/self-closing-tags-migration.cjs +7 -19
  59. package/schematics/bundles/signal-input-migration.cjs +28 -12
  60. package/schematics/bundles/signal-queries-migration.cjs +7 -7
  61. package/schematics/bundles/signals.cjs +7 -7
  62. package/schematics/bundles/standalone-migration.cjs +4 -4
  63. package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
  64. package/schematics/bundles/test-bed-get.cjs +4 -4
  65. package/signal.d-fOdF0h0o.d.ts +1 -1
  66. package/testing/index.d.ts +3 -3
  67. package/weak_ref.d-eGOEP9S1.d.ts +1 -1
  68. package/fesm2022/debug_node-B9JawCEy.mjs.map +0 -1
  69. package/fesm2022/root_effect_scheduler-C4AUixQF.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v20.0.1
3
+ * @license Angular v20.1.0-next.0
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -936,24 +936,25 @@ var BinaryOperator;
936
936
  (function (BinaryOperator) {
937
937
  BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals";
938
938
  BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals";
939
- BinaryOperator[BinaryOperator["Identical"] = 2] = "Identical";
940
- BinaryOperator[BinaryOperator["NotIdentical"] = 3] = "NotIdentical";
941
- BinaryOperator[BinaryOperator["Minus"] = 4] = "Minus";
942
- BinaryOperator[BinaryOperator["Plus"] = 5] = "Plus";
943
- BinaryOperator[BinaryOperator["Divide"] = 6] = "Divide";
944
- BinaryOperator[BinaryOperator["Multiply"] = 7] = "Multiply";
945
- BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo";
946
- BinaryOperator[BinaryOperator["And"] = 9] = "And";
947
- BinaryOperator[BinaryOperator["Or"] = 10] = "Or";
948
- BinaryOperator[BinaryOperator["BitwiseOr"] = 11] = "BitwiseOr";
949
- BinaryOperator[BinaryOperator["BitwiseAnd"] = 12] = "BitwiseAnd";
950
- BinaryOperator[BinaryOperator["Lower"] = 13] = "Lower";
951
- BinaryOperator[BinaryOperator["LowerEquals"] = 14] = "LowerEquals";
952
- BinaryOperator[BinaryOperator["Bigger"] = 15] = "Bigger";
953
- BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
954
- BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
955
- BinaryOperator[BinaryOperator["Exponentiation"] = 18] = "Exponentiation";
956
- BinaryOperator[BinaryOperator["In"] = 19] = "In";
939
+ BinaryOperator[BinaryOperator["Assign"] = 2] = "Assign";
940
+ BinaryOperator[BinaryOperator["Identical"] = 3] = "Identical";
941
+ BinaryOperator[BinaryOperator["NotIdentical"] = 4] = "NotIdentical";
942
+ BinaryOperator[BinaryOperator["Minus"] = 5] = "Minus";
943
+ BinaryOperator[BinaryOperator["Plus"] = 6] = "Plus";
944
+ BinaryOperator[BinaryOperator["Divide"] = 7] = "Divide";
945
+ BinaryOperator[BinaryOperator["Multiply"] = 8] = "Multiply";
946
+ BinaryOperator[BinaryOperator["Modulo"] = 9] = "Modulo";
947
+ BinaryOperator[BinaryOperator["And"] = 10] = "And";
948
+ BinaryOperator[BinaryOperator["Or"] = 11] = "Or";
949
+ BinaryOperator[BinaryOperator["BitwiseOr"] = 12] = "BitwiseOr";
950
+ BinaryOperator[BinaryOperator["BitwiseAnd"] = 13] = "BitwiseAnd";
951
+ BinaryOperator[BinaryOperator["Lower"] = 14] = "Lower";
952
+ BinaryOperator[BinaryOperator["LowerEquals"] = 15] = "LowerEquals";
953
+ BinaryOperator[BinaryOperator["Bigger"] = 16] = "Bigger";
954
+ BinaryOperator[BinaryOperator["BiggerEquals"] = 17] = "BiggerEquals";
955
+ BinaryOperator[BinaryOperator["NullishCoalesce"] = 18] = "NullishCoalesce";
956
+ BinaryOperator[BinaryOperator["Exponentiation"] = 19] = "Exponentiation";
957
+ BinaryOperator[BinaryOperator["In"] = 20] = "In";
957
958
  })(BinaryOperator || (BinaryOperator = {}));
958
959
  function nullSafeIsEquivalent(base, other) {
959
960
  if (base == null || other == null) {
@@ -1083,7 +1084,7 @@ class ReadVarExpr extends Expression {
1083
1084
  return new ReadVarExpr(this.name, this.type, this.sourceSpan);
1084
1085
  }
1085
1086
  set(value) {
1086
- return new WriteVarExpr(this.name, value, null, this.sourceSpan);
1087
+ return new BinaryOperatorExpr(BinaryOperator.Assign, this, value, null, this.sourceSpan);
1087
1088
  }
1088
1089
  }
1089
1090
  class TypeofExpr extends Expression {
@@ -1143,85 +1144,6 @@ class WrappedNodeExpr extends Expression {
1143
1144
  return new WrappedNodeExpr(this.node, this.type, this.sourceSpan);
1144
1145
  }
1145
1146
  }
1146
- class WriteVarExpr extends Expression {
1147
- name;
1148
- value;
1149
- constructor(name, value, type, sourceSpan) {
1150
- super(type || value.type, sourceSpan);
1151
- this.name = name;
1152
- this.value = value;
1153
- }
1154
- isEquivalent(e) {
1155
- return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);
1156
- }
1157
- isConstant() {
1158
- return false;
1159
- }
1160
- visitExpression(visitor, context) {
1161
- return visitor.visitWriteVarExpr(this, context);
1162
- }
1163
- clone() {
1164
- return new WriteVarExpr(this.name, this.value.clone(), this.type, this.sourceSpan);
1165
- }
1166
- toDeclStmt(type, modifiers) {
1167
- return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
1168
- }
1169
- toConstDecl() {
1170
- return this.toDeclStmt(INFERRED_TYPE, exports.StmtModifier.Final);
1171
- }
1172
- }
1173
- class WriteKeyExpr extends Expression {
1174
- receiver;
1175
- index;
1176
- value;
1177
- constructor(receiver, index, value, type, sourceSpan) {
1178
- super(type || value.type, sourceSpan);
1179
- this.receiver = receiver;
1180
- this.index = index;
1181
- this.value = value;
1182
- }
1183
- isEquivalent(e) {
1184
- return (e instanceof WriteKeyExpr &&
1185
- this.receiver.isEquivalent(e.receiver) &&
1186
- this.index.isEquivalent(e.index) &&
1187
- this.value.isEquivalent(e.value));
1188
- }
1189
- isConstant() {
1190
- return false;
1191
- }
1192
- visitExpression(visitor, context) {
1193
- return visitor.visitWriteKeyExpr(this, context);
1194
- }
1195
- clone() {
1196
- return new WriteKeyExpr(this.receiver.clone(), this.index.clone(), this.value.clone(), this.type, this.sourceSpan);
1197
- }
1198
- }
1199
- class WritePropExpr extends Expression {
1200
- receiver;
1201
- name;
1202
- value;
1203
- constructor(receiver, name, value, type, sourceSpan) {
1204
- super(type || value.type, sourceSpan);
1205
- this.receiver = receiver;
1206
- this.name = name;
1207
- this.value = value;
1208
- }
1209
- isEquivalent(e) {
1210
- return (e instanceof WritePropExpr &&
1211
- this.receiver.isEquivalent(e.receiver) &&
1212
- this.name === e.name &&
1213
- this.value.isEquivalent(e.value));
1214
- }
1215
- isConstant() {
1216
- return false;
1217
- }
1218
- visitExpression(visitor, context) {
1219
- return visitor.visitWritePropExpr(this, context);
1220
- }
1221
- clone() {
1222
- return new WritePropExpr(this.receiver.clone(), this.name, this.value.clone(), this.type, this.sourceSpan);
1223
- }
1224
- }
1225
1147
  class InvokeFunctionExpr extends Expression {
1226
1148
  fn;
1227
1149
  args;
@@ -1775,7 +1697,7 @@ class ReadPropExpr extends Expression {
1775
1697
  return visitor.visitReadPropExpr(this, context);
1776
1698
  }
1777
1699
  set(value) {
1778
- return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
1700
+ return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.prop(this.name), value, null, this.sourceSpan);
1779
1701
  }
1780
1702
  clone() {
1781
1703
  return new ReadPropExpr(this.receiver.clone(), this.name, this.type, this.sourceSpan);
@@ -1801,7 +1723,7 @@ class ReadKeyExpr extends Expression {
1801
1723
  return visitor.visitReadKeyExpr(this, context);
1802
1724
  }
1803
1725
  set(value) {
1804
- return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
1726
+ return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.key(this.index), value, null, this.sourceSpan);
1805
1727
  }
1806
1728
  clone() {
1807
1729
  return new ReadKeyExpr(this.receiver.clone(), this.index.clone(), this.type, this.sourceSpan);
@@ -2038,21 +1960,6 @@ let RecursiveAstVisitor$1 = class RecursiveAstVisitor {
2038
1960
  visitReadVarExpr(ast, context) {
2039
1961
  return this.visitExpression(ast, context);
2040
1962
  }
2041
- visitWriteVarExpr(ast, context) {
2042
- ast.value.visitExpression(this, context);
2043
- return this.visitExpression(ast, context);
2044
- }
2045
- visitWriteKeyExpr(ast, context) {
2046
- ast.receiver.visitExpression(this, context);
2047
- ast.index.visitExpression(this, context);
2048
- ast.value.visitExpression(this, context);
2049
- return this.visitExpression(ast, context);
2050
- }
2051
- visitWritePropExpr(ast, context) {
2052
- ast.receiver.visitExpression(this, context);
2053
- ast.value.visitExpression(this, context);
2054
- return this.visitExpression(ast, context);
2055
- }
2056
1963
  visitDynamicImportExpr(ast, context) {
2057
1964
  return this.visitExpression(ast, context);
2058
1965
  }
@@ -2382,7 +2289,7 @@ class ConstantPool {
2382
2289
  if ((!newValue && !fixup.shared) || (newValue && forceShared)) {
2383
2290
  // Replace the expression with a variable
2384
2291
  const name = this.freshName();
2385
- let definition;
2292
+ let value;
2386
2293
  let usage;
2387
2294
  if (this.isClosureCompilerEnabled && isLongStringLiteral(literal)) {
2388
2295
  // For string literals, Closure will **always** inline the string at
@@ -2398,20 +2305,20 @@ class ConstantPool {
2398
2305
  // const myStr = function() { return "very very very long string"; };
2399
2306
  // const usage1 = myStr();
2400
2307
  // const usage2 = myStr();
2401
- definition = variable(name).set(new FunctionExpr([], // Params.
2308
+ value = new FunctionExpr([], // Params.
2402
2309
  [
2403
2310
  // Statements.
2404
2311
  new ReturnStatement(literal),
2405
- ]));
2312
+ ]);
2406
2313
  usage = variable(name).callFn([]);
2407
2314
  }
2408
2315
  else {
2409
2316
  // Just declare and use the variable directly, without a function call
2410
2317
  // indirection. This saves a few bytes and avoids an unnecessary call.
2411
- definition = variable(name).set(literal);
2318
+ value = literal;
2412
2319
  usage = variable(name);
2413
2320
  }
2414
- this.statements.push(definition.toDeclStmt(INFERRED_TYPE, exports.StmtModifier.Final));
2321
+ this.statements.push(new DeclareVarStmt(name, value, INFERRED_TYPE, exports.StmtModifier.Final));
2415
2322
  fixup.fixup(usage);
2416
2323
  }
2417
2324
  return fixup;
@@ -2482,9 +2389,7 @@ class ConstantPool {
2482
2389
  .map((e) => new FnParam(e.name, DYNAMIC_TYPE));
2483
2390
  const pureFunctionDeclaration = arrowFn(parameters, resultMap(resultExpressions), INFERRED_TYPE);
2484
2391
  const name = this.freshName();
2485
- this.statements.push(variable(name)
2486
- .set(pureFunctionDeclaration)
2487
- .toDeclStmt(INFERRED_TYPE, exports.StmtModifier.Final));
2392
+ this.statements.push(new DeclareVarStmt(name, pureFunctionDeclaration, INFERRED_TYPE, exports.StmtModifier.Final));
2488
2393
  literalFactory = variable(name);
2489
2394
  this.literalFactories.set(key, literalFactory);
2490
2395
  }
@@ -3381,46 +3286,6 @@ class AbstractEmitterVisitor {
3381
3286
  ctx.println(stmt, `}`);
3382
3287
  return null;
3383
3288
  }
3384
- visitWriteVarExpr(expr, ctx) {
3385
- const lineWasEmpty = ctx.lineIsEmpty();
3386
- if (!lineWasEmpty) {
3387
- ctx.print(expr, '(');
3388
- }
3389
- ctx.print(expr, `${expr.name} = `);
3390
- expr.value.visitExpression(this, ctx);
3391
- if (!lineWasEmpty) {
3392
- ctx.print(expr, ')');
3393
- }
3394
- return null;
3395
- }
3396
- visitWriteKeyExpr(expr, ctx) {
3397
- const lineWasEmpty = ctx.lineIsEmpty();
3398
- if (!lineWasEmpty) {
3399
- ctx.print(expr, '(');
3400
- }
3401
- expr.receiver.visitExpression(this, ctx);
3402
- ctx.print(expr, `[`);
3403
- expr.index.visitExpression(this, ctx);
3404
- ctx.print(expr, `] = `);
3405
- expr.value.visitExpression(this, ctx);
3406
- if (!lineWasEmpty) {
3407
- ctx.print(expr, ')');
3408
- }
3409
- return null;
3410
- }
3411
- visitWritePropExpr(expr, ctx) {
3412
- const lineWasEmpty = ctx.lineIsEmpty();
3413
- if (!lineWasEmpty) {
3414
- ctx.print(expr, '(');
3415
- }
3416
- expr.receiver.visitExpression(this, ctx);
3417
- ctx.print(expr, `.${expr.name} = `);
3418
- expr.value.visitExpression(this, ctx);
3419
- if (!lineWasEmpty) {
3420
- ctx.print(expr, ')');
3421
- }
3422
- return null;
3423
- }
3424
3289
  visitInvokeFunctionExpr(expr, ctx) {
3425
3290
  const shouldParenthesize = expr.fn instanceof ArrowFunctionExpr;
3426
3291
  if (shouldParenthesize) {
@@ -3542,6 +3407,9 @@ class AbstractEmitterVisitor {
3542
3407
  visitBinaryOperatorExpr(ast, ctx) {
3543
3408
  let opStr;
3544
3409
  switch (ast.operator) {
3410
+ case BinaryOperator.Assign:
3411
+ opStr = '=';
3412
+ break;
3545
3413
  case BinaryOperator.Equals:
3546
3414
  opStr = '==';
3547
3415
  break;
@@ -3821,7 +3689,7 @@ function compileFactoryFunction(meta) {
3821
3689
  let retExpr = null;
3822
3690
  function makeConditionalFactory(nonCtorExpr) {
3823
3691
  const r = variable('__ngConditionalFactory__');
3824
- body.push(r.set(NULL_EXPR).toDeclStmt());
3692
+ body.push(new DeclareVarStmt(r.name, NULL_EXPR, INFERRED_TYPE));
3825
3693
  const ctorStmt = ctorExpr !== null
3826
3694
  ? r.set(ctorExpr).toStmt()
3827
3695
  : importExpr(Identifiers.invalidFactory).callFn([]).toStmt();
@@ -4081,20 +3949,6 @@ class PropertyRead extends ASTWithName {
4081
3949
  return visitor.visitPropertyRead(this, context);
4082
3950
  }
4083
3951
  }
4084
- class PropertyWrite extends ASTWithName {
4085
- receiver;
4086
- name;
4087
- value;
4088
- constructor(span, sourceSpan, nameSpan, receiver, name, value) {
4089
- super(span, sourceSpan, nameSpan);
4090
- this.receiver = receiver;
4091
- this.name = name;
4092
- this.value = value;
4093
- }
4094
- visit(visitor, context = null) {
4095
- return visitor.visitPropertyWrite(this, context);
4096
- }
4097
- }
4098
3952
  class SafePropertyRead extends ASTWithName {
4099
3953
  receiver;
4100
3954
  name;
@@ -4131,29 +3985,31 @@ class SafeKeyedRead extends AST {
4131
3985
  return visitor.visitSafeKeyedRead(this, context);
4132
3986
  }
4133
3987
  }
4134
- class KeyedWrite extends AST {
4135
- receiver;
4136
- key;
4137
- value;
4138
- constructor(span, sourceSpan, receiver, key, value) {
4139
- super(span, sourceSpan);
4140
- this.receiver = receiver;
4141
- this.key = key;
4142
- this.value = value;
4143
- }
4144
- visit(visitor, context = null) {
4145
- return visitor.visitKeyedWrite(this, context);
4146
- }
4147
- }
3988
+ /** Possible types for a pipe. */
3989
+ exports.BindingPipeType = void 0;
3990
+ (function (BindingPipeType) {
3991
+ /**
3992
+ * Pipe is being referenced by its name, for example:
3993
+ * `@Pipe({name: 'foo'}) class FooPipe` and `{{123 | foo}}`.
3994
+ */
3995
+ BindingPipeType[BindingPipeType["ReferencedByName"] = 0] = "ReferencedByName";
3996
+ /**
3997
+ * Pipe is being referenced by its class name, for example:
3998
+ * `@Pipe() class FooPipe` and `{{123 | FooPipe}}`.
3999
+ */
4000
+ BindingPipeType[BindingPipeType["ReferencedDirectly"] = 1] = "ReferencedDirectly";
4001
+ })(exports.BindingPipeType || (exports.BindingPipeType = {}));
4148
4002
  class BindingPipe extends ASTWithName {
4149
4003
  exp;
4150
4004
  name;
4151
4005
  args;
4152
- constructor(span, sourceSpan, exp, name, args, nameSpan) {
4006
+ type;
4007
+ constructor(span, sourceSpan, exp, name, args, type, nameSpan) {
4153
4008
  super(span, sourceSpan, nameSpan);
4154
4009
  this.exp = exp;
4155
4010
  this.name = name;
4156
4011
  this.args = args;
4012
+ this.type = type;
4157
4013
  }
4158
4014
  visit(visitor, context = null) {
4159
4015
  return visitor.visitPipe(this, context);
@@ -4474,11 +4330,6 @@ class RecursiveAstVisitor {
4474
4330
  this.visit(ast.receiver, context);
4475
4331
  this.visit(ast.key, context);
4476
4332
  }
4477
- visitKeyedWrite(ast, context) {
4478
- this.visit(ast.receiver, context);
4479
- this.visit(ast.key, context);
4480
- this.visit(ast.value, context);
4481
- }
4482
4333
  visitLiteralArray(ast, context) {
4483
4334
  this.visitAll(ast.expressions, context);
4484
4335
  }
@@ -4501,10 +4352,6 @@ class RecursiveAstVisitor {
4501
4352
  visitPropertyRead(ast, context) {
4502
4353
  this.visit(ast.receiver, context);
4503
4354
  }
4504
- visitPropertyWrite(ast, context) {
4505
- this.visit(ast.receiver, context);
4506
- this.visit(ast.value, context);
4507
- }
4508
4355
  visitSafePropertyRead(ast, context) {
4509
4356
  this.visit(ast.receiver, context);
4510
4357
  }
@@ -4830,11 +4677,12 @@ let Element$1 = class Element {
4830
4677
  directives;
4831
4678
  children;
4832
4679
  references;
4680
+ isSelfClosing;
4833
4681
  sourceSpan;
4834
4682
  startSourceSpan;
4835
4683
  endSourceSpan;
4836
4684
  i18n;
4837
- constructor(name, attributes, inputs, outputs, directives, children, references, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
4685
+ constructor(name, attributes, inputs, outputs, directives, children, references, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
4838
4686
  this.name = name;
4839
4687
  this.attributes = attributes;
4840
4688
  this.inputs = inputs;
@@ -4842,6 +4690,7 @@ let Element$1 = class Element {
4842
4690
  this.directives = directives;
4843
4691
  this.children = children;
4844
4692
  this.references = references;
4693
+ this.isSelfClosing = isSelfClosing;
4845
4694
  this.sourceSpan = sourceSpan;
4846
4695
  this.startSourceSpan = startSourceSpan;
4847
4696
  this.endSourceSpan = endSourceSpan;
@@ -5148,11 +4997,12 @@ let Component$1 = class Component {
5148
4997
  directives;
5149
4998
  children;
5150
4999
  references;
5000
+ isSelfClosing;
5151
5001
  sourceSpan;
5152
5002
  startSourceSpan;
5153
5003
  endSourceSpan;
5154
5004
  i18n;
5155
- constructor(componentName, tagName, fullName, attributes, inputs, outputs, directives, children, references, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5005
+ constructor(componentName, tagName, fullName, attributes, inputs, outputs, directives, children, references, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5156
5006
  this.componentName = componentName;
5157
5007
  this.tagName = tagName;
5158
5008
  this.fullName = fullName;
@@ -5162,6 +5012,7 @@ let Component$1 = class Component {
5162
5012
  this.directives = directives;
5163
5013
  this.children = children;
5164
5014
  this.references = references;
5015
+ this.isSelfClosing = isSelfClosing;
5165
5016
  this.sourceSpan = sourceSpan;
5166
5017
  this.startSourceSpan = startSourceSpan;
5167
5018
  this.endSourceSpan = endSourceSpan;
@@ -5206,6 +5057,7 @@ class Template {
5206
5057
  children;
5207
5058
  references;
5208
5059
  variables;
5060
+ isSelfClosing;
5209
5061
  sourceSpan;
5210
5062
  startSourceSpan;
5211
5063
  endSourceSpan;
@@ -5215,7 +5067,7 @@ class Template {
5215
5067
  // `null` is a special case for when there is a structural directive on an `ng-template` so
5216
5068
  // the renderer can differentiate between the synthetic template and the one written in the
5217
5069
  // file.
5218
- tagName, attributes, inputs, outputs, directives, templateAttrs, children, references, variables, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5070
+ tagName, attributes, inputs, outputs, directives, templateAttrs, children, references, variables, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5219
5071
  this.tagName = tagName;
5220
5072
  this.attributes = attributes;
5221
5073
  this.inputs = inputs;
@@ -5225,6 +5077,7 @@ class Template {
5225
5077
  this.children = children;
5226
5078
  this.references = references;
5227
5079
  this.variables = variables;
5080
+ this.isSelfClosing = isSelfClosing;
5228
5081
  this.sourceSpan = sourceSpan;
5229
5082
  this.startSourceSpan = startSourceSpan;
5230
5083
  this.endSourceSpan = endSourceSpan;
@@ -5238,15 +5091,17 @@ class Content {
5238
5091
  selector;
5239
5092
  attributes;
5240
5093
  children;
5094
+ isSelfClosing;
5241
5095
  sourceSpan;
5242
5096
  startSourceSpan;
5243
5097
  endSourceSpan;
5244
5098
  i18n;
5245
5099
  name = 'ng-content';
5246
- constructor(selector, attributes, children, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5100
+ constructor(selector, attributes, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan, i18n) {
5247
5101
  this.selector = selector;
5248
5102
  this.attributes = attributes;
5249
5103
  this.children = children;
5104
+ this.isSelfClosing = isSelfClosing;
5250
5105
  this.sourceSpan = sourceSpan;
5251
5106
  this.startSourceSpan = startSourceSpan;
5252
5107
  this.endSourceSpan = endSourceSpan;
@@ -5412,7 +5267,7 @@ function visitAll$1(visitor, nodes) {
5412
5267
  const result = [];
5413
5268
  if (visitor.visit) {
5414
5269
  for (const node of nodes) {
5415
- visitor.visit(node) || node.visit(visitor);
5270
+ visitor.visit(node);
5416
5271
  }
5417
5272
  }
5418
5273
  else {
@@ -7308,7 +7163,11 @@ function tupleOfTypes(types) {
7308
7163
  function compilePipeFromMetadata(metadata) {
7309
7164
  const definitionMapValues = [];
7310
7165
  // e.g. `name: 'myPipe'`
7311
- definitionMapValues.push({ key: 'name', value: literal$1(metadata.pipeName), quoted: false });
7166
+ definitionMapValues.push({
7167
+ key: 'name',
7168
+ value: literal$1(metadata.pipeName ?? metadata.name),
7169
+ quoted: false,
7170
+ });
7312
7171
  // e.g. `type: MyPipe`
7313
7172
  definitionMapValues.push({ key: 'type', value: metadata.type.value, quoted: false });
7314
7173
  // e.g. `pure: true`
@@ -10324,15 +10183,6 @@ function transformExpressionsInExpression(expr, transform, flags) {
10324
10183
  expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
10325
10184
  expr.index = transformExpressionsInExpression(expr.index, transform, flags);
10326
10185
  }
10327
- else if (expr instanceof WritePropExpr) {
10328
- expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
10329
- expr.value = transformExpressionsInExpression(expr.value, transform, flags);
10330
- }
10331
- else if (expr instanceof WriteKeyExpr) {
10332
- expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
10333
- expr.index = transformExpressionsInExpression(expr.index, transform, flags);
10334
- expr.value = transformExpressionsInExpression(expr.value, transform, flags);
10335
- }
10336
10186
  else if (expr instanceof InvokeFunctionExpr) {
10337
10187
  expr.fn = transformExpressionsInExpression(expr.fn, transform, flags);
10338
10188
  for (let i = 0; i < expr.args.length; i++) {
@@ -10362,9 +10212,6 @@ function transformExpressionsInExpression(expr, transform, flags) {
10362
10212
  else if (expr instanceof VoidExpr) {
10363
10213
  expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);
10364
10214
  }
10365
- else if (expr instanceof WriteVarExpr) {
10366
- expr.value = transformExpressionsInExpression(expr.value, transform, flags);
10367
- }
10368
10215
  else if (expr instanceof LocalizedString) {
10369
10216
  for (let i = 0; i < expr.expressions.length; i++) {
10370
10217
  expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform, flags);
@@ -11947,6 +11794,7 @@ const BINARY_OPERATORS$3 = new Map([
11947
11794
  ['|', BinaryOperator.BitwiseOr],
11948
11795
  ['&', BinaryOperator.BitwiseAnd],
11949
11796
  ['/', BinaryOperator.Divide],
11797
+ ['=', BinaryOperator.Assign],
11950
11798
  ['==', BinaryOperator.Equals],
11951
11799
  ['===', BinaryOperator.Identical],
11952
11800
  ['<', BinaryOperator.Lower],
@@ -13430,14 +13278,16 @@ class Element extends NodeWithI18n {
13430
13278
  attrs;
13431
13279
  directives;
13432
13280
  children;
13281
+ isSelfClosing;
13433
13282
  startSourceSpan;
13434
13283
  endSourceSpan;
13435
- constructor(name, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
13284
+ constructor(name, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
13436
13285
  super(sourceSpan, i18n);
13437
13286
  this.name = name;
13438
13287
  this.attrs = attrs;
13439
13288
  this.directives = directives;
13440
13289
  this.children = children;
13290
+ this.isSelfClosing = isSelfClosing;
13441
13291
  this.startSourceSpan = startSourceSpan;
13442
13292
  this.endSourceSpan = endSourceSpan;
13443
13293
  }
@@ -13483,9 +13333,10 @@ class Component extends NodeWithI18n {
13483
13333
  attrs;
13484
13334
  directives;
13485
13335
  children;
13336
+ isSelfClosing;
13486
13337
  startSourceSpan;
13487
13338
  endSourceSpan;
13488
- constructor(componentName, tagName, fullName, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
13339
+ constructor(componentName, tagName, fullName, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) {
13489
13340
  super(sourceSpan, i18n);
13490
13341
  this.componentName = componentName;
13491
13342
  this.tagName = tagName;
@@ -13493,6 +13344,7 @@ class Component extends NodeWithI18n {
13493
13344
  this.attrs = attrs;
13494
13345
  this.directives = directives;
13495
13346
  this.children = children;
13347
+ this.isSelfClosing = isSelfClosing;
13496
13348
  this.startSourceSpan = startSourceSpan;
13497
13349
  this.endSourceSpan = endSourceSpan;
13498
13350
  }
@@ -17404,7 +17256,7 @@ class _TreeBuilder {
17404
17256
  const span = new ParseSourceSpan(startTagToken.sourceSpan.start, end, startTagToken.sourceSpan.fullStart);
17405
17257
  // Create a separate `startSpan` because `span` will be modified when there is an `end` span.
17406
17258
  const startSpan = new ParseSourceSpan(startTagToken.sourceSpan.start, end, startTagToken.sourceSpan.fullStart);
17407
- const el = new Element(fullName, attrs, directives, [], span, startSpan, undefined);
17259
+ const el = new Element(fullName, attrs, directives, [], selfClosing, span, startSpan, undefined);
17408
17260
  const parent = this._getContainer();
17409
17261
  const isClosedByChild = parent !== null && !!this._getTagDefinition(parent)?.isClosedByChild(el.name);
17410
17262
  this._pushContainer(el, isClosedByChild);
@@ -17433,7 +17285,7 @@ class _TreeBuilder {
17433
17285
  const end = this._peek.sourceSpan.fullStart;
17434
17286
  const span = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart);
17435
17287
  const startSpan = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart);
17436
- const node = new Component(componentName, tagName, fullName, attrs, directives, [], span, startSpan, undefined);
17288
+ const node = new Component(componentName, tagName, fullName, attrs, directives, [], selfClosing, span, startSpan, undefined);
17437
17289
  const parent = this._getContainer();
17438
17290
  const isClosedByChild = parent !== null &&
17439
17291
  node.tagName !== null &&
@@ -17847,11 +17699,11 @@ class WhitespaceVisitor {
17847
17699
  if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
17848
17700
  // don't descent into elements where we need to preserve whitespaces
17849
17701
  // but still visit all attributes to eliminate one used as a market to preserve WS
17850
- const newElement = new Element(element.name, visitAllWithSiblings(this, element.attrs), visitAllWithSiblings(this, element.directives), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
17702
+ 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);
17851
17703
  this.originalNodeMap?.set(newElement, element);
17852
17704
  return newElement;
17853
17705
  }
17854
- const newElement = new Element(element.name, element.attrs, element.directives, visitAllWithSiblings(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
17706
+ const newElement = new Element(element.name, element.attrs, element.directives, visitAllWithSiblings(this, element.children), element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
17855
17707
  this.originalNodeMap?.set(newElement, element);
17856
17708
  return newElement;
17857
17709
  }
@@ -17930,11 +17782,11 @@ class WhitespaceVisitor {
17930
17782
  hasPreserveWhitespacesAttr(node.attrs)) {
17931
17783
  // don't descent into elements where we need to preserve whitespaces
17932
17784
  // but still visit all attributes to eliminate one used as a market to preserve WS
17933
- 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);
17785
+ 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);
17934
17786
  this.originalNodeMap?.set(newElement, node);
17935
17787
  return newElement;
17936
17788
  }
17937
- 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);
17789
+ 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);
17938
17790
  this.originalNodeMap?.set(newElement, node);
17939
17791
  return newElement;
17940
17792
  }
@@ -18534,20 +18386,23 @@ class TemplateBindingParseResult {
18534
18386
  }
18535
18387
  class Parser {
18536
18388
  _lexer;
18537
- errors = [];
18538
- constructor(_lexer) {
18389
+ _supportsDirectPipeReferences;
18390
+ constructor(_lexer, _supportsDirectPipeReferences = false) {
18539
18391
  this._lexer = _lexer;
18392
+ this._supportsDirectPipeReferences = _supportsDirectPipeReferences;
18540
18393
  }
18541
18394
  parseAction(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18542
- this._checkNoInterpolation(input, location, interpolationConfig);
18395
+ const errors = [];
18396
+ this._checkNoInterpolation(errors, input, location, interpolationConfig);
18543
18397
  const sourceToLex = this._stripComments(input);
18544
18398
  const tokens = this._lexer.tokenize(sourceToLex);
18545
- const ast = new _ParseAST(input, location, absoluteOffset, tokens, 1 /* ParseFlags.Action */, this.errors, 0).parseChain();
18546
- return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);
18399
+ const ast = new _ParseAST(input, location, absoluteOffset, tokens, 1 /* ParseFlags.Action */, errors, 0, this._supportsDirectPipeReferences).parseChain();
18400
+ return new ASTWithSource(ast, input, location, absoluteOffset, errors);
18547
18401
  }
18548
18402
  parseBinding(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18549
- const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig);
18550
- return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);
18403
+ const errors = [];
18404
+ const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors);
18405
+ return new ASTWithSource(ast, input, location, absoluteOffset, errors);
18551
18406
  }
18552
18407
  checkSimpleExpression(ast) {
18553
18408
  const checker = new SimpleExpressionChecker();
@@ -18556,21 +18411,19 @@ class Parser {
18556
18411
  }
18557
18412
  // Host bindings parsed here
18558
18413
  parseSimpleBinding(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18559
- const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig);
18560
- const errors = this.checkSimpleExpression(ast);
18561
- if (errors.length > 0) {
18562
- this._reportError(`Host binding expression cannot contain ${errors.join(' ')}`, input, location);
18414
+ const errors = [];
18415
+ const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors);
18416
+ const simplExpressionErrors = this.checkSimpleExpression(ast);
18417
+ if (simplExpressionErrors.length > 0) {
18418
+ errors.push(new ParserError(`Host binding expression cannot contain ${simplExpressionErrors.join(' ')}`, input, location));
18563
18419
  }
18564
- return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);
18565
- }
18566
- _reportError(message, input, errLocation, ctxLocation) {
18567
- this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
18420
+ return new ASTWithSource(ast, input, location, absoluteOffset, errors);
18568
18421
  }
18569
- _parseBindingAst(input, location, absoluteOffset, interpolationConfig) {
18570
- this._checkNoInterpolation(input, location, interpolationConfig);
18422
+ _parseBindingAst(input, location, absoluteOffset, interpolationConfig, errors) {
18423
+ this._checkNoInterpolation(errors, input, location, interpolationConfig);
18571
18424
  const sourceToLex = this._stripComments(input);
18572
18425
  const tokens = this._lexer.tokenize(sourceToLex);
18573
- return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0).parseChain();
18426
+ return new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, 0, this._supportsDirectPipeReferences).parseChain();
18574
18427
  }
18575
18428
  /**
18576
18429
  * Parse microsyntax template expression and return a list of bindings or
@@ -18600,14 +18453,16 @@ class Parser {
18600
18453
  */
18601
18454
  parseTemplateBindings(templateKey, templateValue, templateUrl, absoluteKeyOffset, absoluteValueOffset) {
18602
18455
  const tokens = this._lexer.tokenize(templateValue);
18603
- const parser = new _ParseAST(templateValue, templateUrl, absoluteValueOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0 /* relative offset */);
18456
+ const errors = [];
18457
+ const parser = new _ParseAST(templateValue, templateUrl, absoluteValueOffset, tokens, 0 /* ParseFlags.None */, errors, 0 /* relative offset */, this._supportsDirectPipeReferences);
18604
18458
  return parser.parseTemplateBindings({
18605
18459
  source: templateKey,
18606
18460
  span: new AbsoluteSourceSpan(absoluteKeyOffset, absoluteKeyOffset + templateKey.length),
18607
18461
  });
18608
18462
  }
18609
18463
  parseInterpolation(input, location, absoluteOffset, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18610
- const { strings, expressions, offsets } = this.splitInterpolation(input, location, interpolatedTokens, interpolationConfig);
18464
+ const errors = [];
18465
+ const { strings, expressions, offsets } = this.splitInterpolation(input, location, errors, interpolatedTokens, interpolationConfig);
18611
18466
  if (expressions.length === 0)
18612
18467
  return null;
18613
18468
  const expressionNodes = [];
@@ -18615,10 +18470,10 @@ class Parser {
18615
18470
  const expressionText = expressions[i].text;
18616
18471
  const sourceToLex = this._stripComments(expressionText);
18617
18472
  const tokens = this._lexer.tokenize(sourceToLex);
18618
- const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, offsets[i]).parseChain();
18473
+ const ast = new _ParseAST(input, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, offsets[i], this._supportsDirectPipeReferences).parseChain();
18619
18474
  expressionNodes.push(ast);
18620
18475
  }
18621
- return this.createInterpolationAst(strings.map((s) => s.text), expressionNodes, input, location, absoluteOffset);
18476
+ return this.createInterpolationAst(strings.map((s) => s.text), expressionNodes, input, location, absoluteOffset, errors);
18622
18477
  }
18623
18478
  /**
18624
18479
  * Similar to `parseInterpolation`, but treats the provided string as a single expression
@@ -18628,14 +18483,15 @@ class Parser {
18628
18483
  parseInterpolationExpression(expression, location, absoluteOffset) {
18629
18484
  const sourceToLex = this._stripComments(expression);
18630
18485
  const tokens = this._lexer.tokenize(sourceToLex);
18631
- const ast = new _ParseAST(expression, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, this.errors, 0).parseChain();
18486
+ const errors = [];
18487
+ const ast = new _ParseAST(expression, location, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, 0, this._supportsDirectPipeReferences).parseChain();
18632
18488
  const strings = ['', '']; // The prefix and suffix strings are both empty
18633
- return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset);
18489
+ return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset, errors);
18634
18490
  }
18635
- createInterpolationAst(strings, expressions, input, location, absoluteOffset) {
18491
+ createInterpolationAst(strings, expressions, input, location, absoluteOffset, errors) {
18636
18492
  const span = new ParseSpan(0, input.length);
18637
18493
  const interpolation = new Interpolation$1(span, span.toAbsolute(absoluteOffset), strings, expressions);
18638
- return new ASTWithSource(interpolation, input, location, absoluteOffset, this.errors);
18494
+ return new ASTWithSource(interpolation, input, location, absoluteOffset, errors);
18639
18495
  }
18640
18496
  /**
18641
18497
  * Splits a string of text into "raw" text segments and expressions present in interpolations in
@@ -18644,7 +18500,7 @@ class Parser {
18644
18500
  * `SplitInterpolation` with splits that look like
18645
18501
  * <raw text> <expression> <raw text> ... <raw text> <expression> <raw text>
18646
18502
  */
18647
- splitInterpolation(input, location, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18503
+ splitInterpolation(input, location, errors, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
18648
18504
  const strings = [];
18649
18505
  const expressions = [];
18650
18506
  const offsets = [];
@@ -18682,7 +18538,7 @@ class Parser {
18682
18538
  const fullEnd = exprEnd + interpEnd.length;
18683
18539
  const text = input.substring(exprStart, exprEnd);
18684
18540
  if (text.trim().length === 0) {
18685
- this._reportError('Blank expressions are not allowed in interpolated strings', input, `at column ${i} in`, location);
18541
+ errors.push(new ParserError('Blank expressions are not allowed in interpolated strings', input, `at column ${i} in`, location));
18686
18542
  }
18687
18543
  expressions.push({ text, start: fullStart, end: fullEnd });
18688
18544
  const startInOriginalTemplate = inputToTemplateIndexMap?.get(fullStart) ?? fullStart;
@@ -18707,7 +18563,7 @@ class Parser {
18707
18563
  }
18708
18564
  wrapLiteralPrimitive(input, location, absoluteOffset) {
18709
18565
  const span = new ParseSpan(0, input == null ? 0 : input.length);
18710
- return new ASTWithSource(new LiteralPrimitive(span, span.toAbsolute(absoluteOffset), input), input, location, absoluteOffset, this.errors);
18566
+ return new ASTWithSource(new LiteralPrimitive(span, span.toAbsolute(absoluteOffset), input), input, location, absoluteOffset, []);
18711
18567
  }
18712
18568
  _stripComments(input) {
18713
18569
  const i = this._commentStart(input);
@@ -18729,7 +18585,7 @@ class Parser {
18729
18585
  }
18730
18586
  return null;
18731
18587
  }
18732
- _checkNoInterpolation(input, location, { start, end }) {
18588
+ _checkNoInterpolation(errors, input, location, { start, end }) {
18733
18589
  let startIndex = -1;
18734
18590
  let endIndex = -1;
18735
18591
  for (const charIndex of this._forEachUnquotedChar(input, 0)) {
@@ -18746,7 +18602,7 @@ class Parser {
18746
18602
  }
18747
18603
  }
18748
18604
  if (startIndex > -1 && endIndex > -1) {
18749
- this._reportError(`Got interpolation (${start}${end}) where expression was expected`, input, `at column ${startIndex} in`, location);
18605
+ errors.push(new ParserError(`Got interpolation (${start}${end}) where expression was expected`, input, `at column ${startIndex} in`, location));
18750
18606
  }
18751
18607
  }
18752
18608
  /**
@@ -18811,6 +18667,7 @@ class _ParseAST {
18811
18667
  parseFlags;
18812
18668
  errors;
18813
18669
  offset;
18670
+ supportsDirectPipeReferences;
18814
18671
  rparensExpected = 0;
18815
18672
  rbracketsExpected = 0;
18816
18673
  rbracesExpected = 0;
@@ -18821,7 +18678,7 @@ class _ParseAST {
18821
18678
  // and may change for subsequent expressions visited by the parser.
18822
18679
  sourceSpanCache = new Map();
18823
18680
  index = 0;
18824
- constructor(input, location, absoluteOffset, tokens, parseFlags, errors, offset) {
18681
+ constructor(input, location, absoluteOffset, tokens, parseFlags, errors, offset, supportsDirectPipeReferences) {
18825
18682
  this.input = input;
18826
18683
  this.location = location;
18827
18684
  this.absoluteOffset = absoluteOffset;
@@ -18829,6 +18686,7 @@ class _ParseAST {
18829
18686
  this.parseFlags = parseFlags;
18830
18687
  this.errors = errors;
18831
18688
  this.offset = offset;
18689
+ this.supportsDirectPipeReferences = supportsDirectPipeReferences;
18832
18690
  }
18833
18691
  peek(offset) {
18834
18692
  const i = this.index + offset;
@@ -19057,7 +18915,18 @@ class _ParseAST {
19057
18915
  // If there are additional expressions beyond the name, then the artificial end for the
19058
18916
  // name is no longer relevant.
19059
18917
  }
19060
- result = new BindingPipe(this.span(start), this.sourceSpan(start, fullSpanEnd), result, nameId, args, nameSpan);
18918
+ let type;
18919
+ if (this.supportsDirectPipeReferences) {
18920
+ const charCode = nameId.charCodeAt(0);
18921
+ type =
18922
+ charCode === $_ || (charCode >= $A && charCode <= $Z)
18923
+ ? exports.BindingPipeType.ReferencedDirectly
18924
+ : exports.BindingPipeType.ReferencedByName;
18925
+ }
18926
+ else {
18927
+ type = exports.BindingPipeType.ReferencedByName;
18928
+ }
18929
+ result = new BindingPipe(this.span(start), this.sourceSpan(start, fullSpanEnd), result, nameId, args, type, nameSpan);
19061
18930
  } while (this.consumeOptionalOperator('|'));
19062
18931
  }
19063
18932
  return result;
@@ -19421,14 +19290,13 @@ class _ParseAST {
19421
19290
  return id;
19422
19291
  });
19423
19292
  const nameSpan = this.sourceSpan(nameStart);
19424
- let receiver;
19425
19293
  if (isSafe) {
19426
19294
  if (this.consumeOptionalOperator('=')) {
19427
19295
  this.error("The '?.' operator cannot be used in the assignment");
19428
- receiver = new EmptyExpr$1(this.span(start), this.sourceSpan(start));
19296
+ return new EmptyExpr$1(this.span(start), this.sourceSpan(start));
19429
19297
  }
19430
19298
  else {
19431
- receiver = new SafePropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
19299
+ return new SafePropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
19432
19300
  }
19433
19301
  }
19434
19302
  else {
@@ -19437,14 +19305,14 @@ class _ParseAST {
19437
19305
  this.error('Bindings cannot contain assignments');
19438
19306
  return new EmptyExpr$1(this.span(start), this.sourceSpan(start));
19439
19307
  }
19308
+ const receiver = new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
19440
19309
  const value = this.parseConditional();
19441
- receiver = new PropertyWrite(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id, value);
19310
+ return new Binary(this.span(start), this.sourceSpan(start), '=', receiver, value);
19442
19311
  }
19443
19312
  else {
19444
- receiver = new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
19313
+ return new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, readReceiver, id);
19445
19314
  }
19446
19315
  }
19447
- return receiver;
19448
19316
  }
19449
19317
  parseCall(receiver, start, isSafe) {
19450
19318
  const argumentStart = this.inputIndex;
@@ -19559,8 +19427,9 @@ class _ParseAST {
19559
19427
  this.error("The '?.' operator cannot be used in the assignment");
19560
19428
  }
19561
19429
  else {
19430
+ const binaryReceiver = new KeyedRead(this.span(start), this.sourceSpan(start), receiver, key);
19562
19431
  const value = this.parseConditional();
19563
- return new KeyedWrite(this.span(start), this.sourceSpan(start), receiver, key, value);
19432
+ return new Binary(this.span(start), this.sourceSpan(start), '=', binaryReceiver, value);
19564
19433
  }
19565
19434
  }
19566
19435
  else {
@@ -19863,9 +19732,6 @@ class SerializeExpressionVisitor {
19863
19732
  visitKeyedRead(ast, context) {
19864
19733
  return `${ast.receiver.visit(this, context)}[${ast.key.visit(this, context)}]`;
19865
19734
  }
19866
- visitKeyedWrite(ast, context) {
19867
- return `${ast.receiver.visit(this, context)}[${ast.key.visit(this, context)}] = ${ast.value.visit(this, context)}`;
19868
- }
19869
19735
  visitLiteralArray(ast, context) {
19870
19736
  return `[${ast.expressions.map((e) => e.visit(this, context)).join(', ')}]`;
19871
19737
  }
@@ -19906,14 +19772,6 @@ class SerializeExpressionVisitor {
19906
19772
  return `${ast.receiver.visit(this, context)}.${ast.name}`;
19907
19773
  }
19908
19774
  }
19909
- visitPropertyWrite(ast, context) {
19910
- if (ast.receiver instanceof ImplicitReceiver) {
19911
- return `${ast.name} = ${ast.value.visit(this, context)}`;
19912
- }
19913
- else {
19914
- return `${ast.receiver.visit(this, context)}.${ast.name} = ${ast.value.visit(this, context)}`;
19915
- }
19916
- }
19917
19775
  visitSafePropertyRead(ast, context) {
19918
19776
  return `${ast.receiver.visit(this, context)}?.${ast.name}`;
19919
19777
  }
@@ -21530,7 +21388,7 @@ function createGoogleGetMsgStatements(variable$1, message, closureVar, placehold
21530
21388
  // */
21531
21389
  // const MSG_... = goog.getMsg(..);
21532
21390
  // I18N_X = MSG_...;
21533
- const googGetMsgStmt = closureVar.set(variable(GOOG_GET_MSG).callFn(args)).toConstDecl();
21391
+ const googGetMsgStmt = new DeclareVarStmt(closureVar.name, variable(GOOG_GET_MSG).callFn(args), INFERRED_TYPE, exports.StmtModifier.Final);
21534
21392
  googGetMsgStmt.addLeadingComment(i18nMetaToJSDoc(message));
21535
21393
  const i18nAssignmentStmt = new ExpressionStatement(variable$1.set(closureVar));
21536
21394
  return [googGetMsgStmt, i18nAssignmentStmt];
@@ -26578,17 +26436,6 @@ function convertAst(ast, job, baseSourceSpan) {
26578
26436
  return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
26579
26437
  }
26580
26438
  }
26581
- else if (ast instanceof PropertyWrite) {
26582
- if (ast.receiver instanceof ImplicitReceiver) {
26583
- return new WritePropExpr(
26584
- // TODO: Is it correct to always use the root context in place of the implicit receiver?
26585
- new ContextExpr(job.root.xref), ast.name, convertAst(ast.value, job, baseSourceSpan), null, convertSourceSpan(ast.span, baseSourceSpan));
26586
- }
26587
- return new WritePropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, convertAst(ast.value, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
26588
- }
26589
- else if (ast instanceof KeyedWrite) {
26590
- return new WriteKeyExpr(convertAst(ast.receiver, job, baseSourceSpan), convertAst(ast.key, job, baseSourceSpan), convertAst(ast.value, job, baseSourceSpan), undefined, convertSourceSpan(ast.span, baseSourceSpan));
26591
- }
26592
26439
  else if (ast instanceof Call) {
26593
26440
  if (ast.receiver instanceof ImplicitReceiver) {
26594
26441
  throw new Error(`Unexpected ImplicitReceiver`);
@@ -28865,7 +28712,7 @@ class HtmlAstToIvyAst {
28865
28712
  if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
28866
28713
  const selector = preparsedElement.selectAttr;
28867
28714
  const attrs = element.attrs.map((attr) => this.visitAttribute(attr));
28868
- parsedElement = new Content(selector, attrs, children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28715
+ parsedElement = new Content(selector, attrs, children, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28869
28716
  this.ngContentSelectors.push(selector);
28870
28717
  }
28871
28718
  else if (isTemplateElement) {
@@ -28873,11 +28720,11 @@ class HtmlAstToIvyAst {
28873
28720
  const attrs = this.categorizePropertyAttributes(element.name, parsedProperties, i18nAttrsMeta);
28874
28721
  parsedElement = new Template(element.name, attributes, attrs.bound, boundEvents, directives, [
28875
28722
  /* no template attributes */
28876
- ], children, references, variables, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28723
+ ], children, references, variables, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28877
28724
  }
28878
28725
  else {
28879
28726
  const attrs = this.categorizePropertyAttributes(element.name, parsedProperties, i18nAttrsMeta);
28880
- parsedElement = new Element$1(element.name, attributes, attrs.bound, boundEvents, directives, children, references, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28727
+ parsedElement = new Element$1(element.name, attributes, attrs.bound, boundEvents, directives, children, references, element.isSelfClosing, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
28881
28728
  }
28882
28729
  if (elementHasInlineTemplate) {
28883
28730
  // If this node is an inline-template (e.g. has *ngFor) then we need to create a template
@@ -28972,7 +28819,7 @@ class HtmlAstToIvyAst {
28972
28819
  children = visitAll(this, component.children, component.children);
28973
28820
  }
28974
28821
  const attrs = this.categorizePropertyAttributes(component.tagName, parsedProperties, i18nAttrsMeta);
28975
- 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);
28822
+ 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);
28976
28823
  if (elementHasInlineTemplate) {
28977
28824
  node = this.wrapInTemplate(node, templateParsedProperties, templateVariables, i18nAttrsMeta, false, isI18nRootElement);
28978
28825
  }
@@ -29312,7 +29159,7 @@ class HtmlAstToIvyAst {
29312
29159
  // Do not copy over the directives.
29313
29160
  ], templateAttrs, [node], [
29314
29161
  // Do not copy over the references.
29315
- ], templateVariables, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, i18n);
29162
+ ], templateVariables, false, node.sourceSpan, node.startSourceSpan, node.endSourceSpan, i18n);
29316
29163
  }
29317
29164
  _visitTextWithInterpolation(value, sourceSpan, interpolatedTokens, i18n) {
29318
29165
  const valueNoNgsp = replaceNgsp(value);
@@ -29383,7 +29230,7 @@ class NonBindableVisitor {
29383
29230
  /* inputs */ [],
29384
29231
  /* outputs */ [],
29385
29232
  /* directives */ [], children,
29386
- /* references */ [], ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
29233
+ /* references */ [], ast.isSelfClosing, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
29387
29234
  }
29388
29235
  visitComment(comment) {
29389
29236
  return null;
@@ -29424,7 +29271,7 @@ class NonBindableVisitor {
29424
29271
  /* inputs */ [],
29425
29272
  /* outputs */ [],
29426
29273
  /* directives */ [], children,
29427
- /* references */ [], ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
29274
+ /* references */ [], ast.isSelfClosing, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
29428
29275
  }
29429
29276
  visitDirective(directive, context) {
29430
29277
  return null;
@@ -29456,7 +29303,8 @@ const LEADING_TRIVIA_CHARS = [' ', '\n', '\r', '\t'];
29456
29303
  */
29457
29304
  function parseTemplate(template, templateUrl, options = {}) {
29458
29305
  const { interpolationConfig, preserveWhitespaces, enableI18nLegacyMessageIdFormat } = options;
29459
- const bindingParser = makeBindingParser(interpolationConfig);
29306
+ const selectorlessEnabled = options.enableSelectorless ?? false;
29307
+ const bindingParser = makeBindingParser(interpolationConfig, selectorlessEnabled);
29460
29308
  const htmlParser = new HtmlParser();
29461
29309
  const parseResult = htmlParser.parse(template, templateUrl, {
29462
29310
  leadingTriviaChars: LEADING_TRIVIA_CHARS,
@@ -29464,7 +29312,7 @@ function parseTemplate(template, templateUrl, options = {}) {
29464
29312
  tokenizeExpansionForms: true,
29465
29313
  tokenizeBlocks: options.enableBlockSyntax ?? true,
29466
29314
  tokenizeLet: options.enableLetSyntax ?? true,
29467
- selectorlessEnabled: options.enableSelectorless ?? false,
29315
+ selectorlessEnabled,
29468
29316
  });
29469
29317
  if (!options.alwaysAttemptHtmlToR3AstConversion &&
29470
29318
  parseResult.errors &&
@@ -29563,8 +29411,8 @@ const elementRegistry = new DomElementSchemaRegistry();
29563
29411
  /**
29564
29412
  * Construct a `BindingParser` with a default configuration.
29565
29413
  */
29566
- function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
29567
- return new BindingParser(new Parser(new Lexer()), interpolationConfig, elementRegistry, []);
29414
+ function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG, selectorlessEnabled = false) {
29415
+ return new BindingParser(new Parser(new Lexer(), selectorlessEnabled), interpolationConfig, elementRegistry, []);
29568
29416
  }
29569
29417
 
29570
29418
  const COMPONENT_VARIABLE = '%COMP%';
@@ -30074,6 +29922,132 @@ function compileDeferResolverFunction(meta) {
30074
29922
  return arrowFn([], literalArr(depExpressions));
30075
29923
  }
30076
29924
 
29925
+ /*!
29926
+ * @license
29927
+ * Copyright Google LLC All Rights Reserved.
29928
+ *
29929
+ * Use of this source code is governed by an MIT-style license that can be
29930
+ * found in the LICENSE file at https://angular.dev/license
29931
+ */
29932
+ /**
29933
+ * Visitor that traverses all template and expression AST nodes in a template.
29934
+ * Useful for cases where every single node needs to be visited.
29935
+ */
29936
+ class CombinedRecursiveAstVisitor extends RecursiveAstVisitor {
29937
+ visit(node) {
29938
+ if (node instanceof ASTWithSource) {
29939
+ this.visit(node.ast);
29940
+ }
29941
+ else {
29942
+ node.visit(this);
29943
+ }
29944
+ }
29945
+ visitElement(element) {
29946
+ this.visitAllTemplateNodes(element.attributes);
29947
+ this.visitAllTemplateNodes(element.inputs);
29948
+ this.visitAllTemplateNodes(element.outputs);
29949
+ this.visitAllTemplateNodes(element.directives);
29950
+ this.visitAllTemplateNodes(element.references);
29951
+ this.visitAllTemplateNodes(element.children);
29952
+ }
29953
+ visitTemplate(template) {
29954
+ this.visitAllTemplateNodes(template.attributes);
29955
+ this.visitAllTemplateNodes(template.inputs);
29956
+ this.visitAllTemplateNodes(template.outputs);
29957
+ this.visitAllTemplateNodes(template.directives);
29958
+ this.visitAllTemplateNodes(template.templateAttrs);
29959
+ this.visitAllTemplateNodes(template.variables);
29960
+ this.visitAllTemplateNodes(template.references);
29961
+ this.visitAllTemplateNodes(template.children);
29962
+ }
29963
+ visitContent(content) {
29964
+ this.visitAllTemplateNodes(content.children);
29965
+ }
29966
+ visitBoundAttribute(attribute) {
29967
+ this.visit(attribute.value);
29968
+ }
29969
+ visitBoundEvent(attribute) {
29970
+ this.visit(attribute.handler);
29971
+ }
29972
+ visitBoundText(text) {
29973
+ this.visit(text.value);
29974
+ }
29975
+ visitIcu(icu) {
29976
+ Object.keys(icu.vars).forEach((key) => this.visit(icu.vars[key]));
29977
+ Object.keys(icu.placeholders).forEach((key) => this.visit(icu.placeholders[key]));
29978
+ }
29979
+ visitDeferredBlock(deferred) {
29980
+ deferred.visitAll(this);
29981
+ }
29982
+ visitDeferredTrigger(trigger) {
29983
+ if (trigger instanceof BoundDeferredTrigger) {
29984
+ this.visit(trigger.value);
29985
+ }
29986
+ }
29987
+ visitDeferredBlockPlaceholder(block) {
29988
+ this.visitAllTemplateNodes(block.children);
29989
+ }
29990
+ visitDeferredBlockError(block) {
29991
+ this.visitAllTemplateNodes(block.children);
29992
+ }
29993
+ visitDeferredBlockLoading(block) {
29994
+ this.visitAllTemplateNodes(block.children);
29995
+ }
29996
+ visitSwitchBlock(block) {
29997
+ this.visit(block.expression);
29998
+ this.visitAllTemplateNodes(block.cases);
29999
+ }
30000
+ visitSwitchBlockCase(block) {
30001
+ block.expression && this.visit(block.expression);
30002
+ this.visitAllTemplateNodes(block.children);
30003
+ }
30004
+ visitForLoopBlock(block) {
30005
+ block.item.visit(this);
30006
+ this.visitAllTemplateNodes(block.contextVariables);
30007
+ this.visit(block.expression);
30008
+ this.visitAllTemplateNodes(block.children);
30009
+ block.empty?.visit(this);
30010
+ }
30011
+ visitForLoopBlockEmpty(block) {
30012
+ this.visitAllTemplateNodes(block.children);
30013
+ }
30014
+ visitIfBlock(block) {
30015
+ this.visitAllTemplateNodes(block.branches);
30016
+ }
30017
+ visitIfBlockBranch(block) {
30018
+ block.expression && this.visit(block.expression);
30019
+ block.expressionAlias?.visit(this);
30020
+ this.visitAllTemplateNodes(block.children);
30021
+ }
30022
+ visitLetDeclaration(decl) {
30023
+ this.visit(decl.value);
30024
+ }
30025
+ visitComponent(component) {
30026
+ this.visitAllTemplateNodes(component.attributes);
30027
+ this.visitAllTemplateNodes(component.inputs);
30028
+ this.visitAllTemplateNodes(component.outputs);
30029
+ this.visitAllTemplateNodes(component.directives);
30030
+ this.visitAllTemplateNodes(component.references);
30031
+ this.visitAllTemplateNodes(component.children);
30032
+ }
30033
+ visitDirective(directive) {
30034
+ this.visitAllTemplateNodes(directive.attributes);
30035
+ this.visitAllTemplateNodes(directive.inputs);
30036
+ this.visitAllTemplateNodes(directive.outputs);
30037
+ this.visitAllTemplateNodes(directive.references);
30038
+ }
30039
+ visitVariable(variable) { }
30040
+ visitReference(reference) { }
30041
+ visitTextAttribute(attribute) { }
30042
+ visitText(text) { }
30043
+ visitUnknownBlock(block) { }
30044
+ visitAllTemplateNodes(nodes) {
30045
+ for (const node of nodes) {
30046
+ this.visit(node);
30047
+ }
30048
+ }
30049
+ }
30050
+
30077
30051
  /**
30078
30052
  * Processes `Target`s with a given set of directives and performs a binding operation, which
30079
30053
  * returns an object similar to TypeScript's `ts.TypeChecker` that contains knowledge about the
@@ -30115,9 +30089,7 @@ class R3TargetBinder {
30115
30089
  // - bindings: Map of inputs, outputs, and attributes to the directive/element that claims
30116
30090
  // them. TODO(alxhub): handle multiple directives claiming an input/output/etc.
30117
30091
  // - references: Map of #references to their targets.
30118
- if (this.directiveMatcher !== null) {
30119
- DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30120
- }
30092
+ DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30121
30093
  // Finally, run the TemplateBinder to bind references, variables, and other entities within the
30122
30094
  // template. This extracts all the metadata that doesn't depend on directive matching.
30123
30095
  TemplateBinder.applyWithScope(target.template, scope, expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
@@ -30451,6 +30423,13 @@ class DirectiveBinder {
30451
30423
  this.directiveMatcher.match(cssSelector, (_, results) => directives.push(...results));
30452
30424
  this.trackSelectorBasedBindingsAndDirectives(node, directives);
30453
30425
  }
30426
+ else {
30427
+ node.references.forEach((ref) => {
30428
+ if (ref.value.trim() === '') {
30429
+ this.references.set(ref, node);
30430
+ }
30431
+ });
30432
+ }
30454
30433
  node.directives.forEach((directive) => directive.visit(this));
30455
30434
  node.children.forEach((child) => child.visit(this));
30456
30435
  }
@@ -30553,7 +30532,7 @@ class DirectiveBinder {
30553
30532
  * Expressions are visited by the superclass `RecursiveAstVisitor`, with custom logic provided
30554
30533
  * by overridden methods from that visitor.
30555
30534
  */
30556
- class TemplateBinder extends RecursiveAstVisitor {
30535
+ class TemplateBinder extends CombinedRecursiveAstVisitor {
30557
30536
  bindings;
30558
30537
  symbols;
30559
30538
  usedPipes;
@@ -30563,7 +30542,7 @@ class TemplateBinder extends RecursiveAstVisitor {
30563
30542
  scope;
30564
30543
  rootNode;
30565
30544
  level;
30566
- visitNode;
30545
+ visitNode = (node) => node.visit(this);
30567
30546
  constructor(bindings, symbols, usedPipes, eagerPipes, deferBlocks, nestingLevel, scope, rootNode, level) {
30568
30547
  super();
30569
30548
  this.bindings = bindings;
@@ -30575,19 +30554,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30575
30554
  this.scope = scope;
30576
30555
  this.rootNode = rootNode;
30577
30556
  this.level = level;
30578
- // Save a bit of processing time by constructing this closure in advance.
30579
- this.visitNode = (node) => node.visit(this);
30580
- }
30581
- // This method is defined to reconcile the type of TemplateBinder since both
30582
- // RecursiveAstVisitor and Visitor define the visit() method in their
30583
- // interfaces.
30584
- visit(node, context) {
30585
- if (node instanceof AST) {
30586
- node.visit(this, context);
30587
- }
30588
- else {
30589
- node.visit(this);
30590
- }
30591
30557
  }
30592
30558
  /**
30593
30559
  * Process a template and extract metadata about expressions and symbols within.
@@ -30656,14 +30622,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30656
30622
  nodeOrNodes.forEach(this.visitNode);
30657
30623
  }
30658
30624
  }
30659
- visitElement(element) {
30660
- // Visit the inputs, outputs, and children of the element.
30661
- element.inputs.forEach(this.visitNode);
30662
- element.outputs.forEach(this.visitNode);
30663
- element.directives.forEach(this.visitNode);
30664
- element.children.forEach(this.visitNode);
30665
- element.references.forEach(this.visitNode);
30666
- }
30667
30625
  visitTemplate(template) {
30668
30626
  // First, visit inputs, outputs and template attributes of the template node.
30669
30627
  template.inputs.forEach(this.visitNode);
@@ -30686,34 +30644,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30686
30644
  this.symbols.set(reference, this.rootNode);
30687
30645
  }
30688
30646
  }
30689
- visitComponent(component) {
30690
- component.inputs.forEach(this.visitNode);
30691
- component.outputs.forEach(this.visitNode);
30692
- component.directives.forEach(this.visitNode);
30693
- component.children.forEach(this.visitNode);
30694
- component.references.forEach(this.visitNode);
30695
- }
30696
- visitDirective(directive) {
30697
- directive.inputs.forEach(this.visitNode);
30698
- directive.outputs.forEach(this.visitNode);
30699
- directive.references.forEach(this.visitNode);
30700
- }
30701
- // Unused template visitors
30702
- visitText(text) { }
30703
- visitTextAttribute(attribute) { }
30704
- visitUnknownBlock(block) { }
30705
- visitDeferredTrigger() { }
30706
- visitIcu(icu) {
30707
- Object.keys(icu.vars).forEach((key) => icu.vars[key].visit(this));
30708
- Object.keys(icu.placeholders).forEach((key) => icu.placeholders[key].visit(this));
30709
- }
30710
- // The remaining visitors are concerned with processing AST expressions within template bindings
30711
- visitBoundAttribute(attribute) {
30712
- attribute.value.visit(this);
30713
- }
30714
- visitBoundEvent(event) {
30715
- event.handler.visit(this);
30716
- }
30717
30647
  visitDeferredBlock(deferred) {
30718
30648
  this.ingestScopedNode(deferred);
30719
30649
  deferred.triggers.when?.value.visit(this);
@@ -30733,10 +30663,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30733
30663
  visitDeferredBlockLoading(block) {
30734
30664
  this.ingestScopedNode(block);
30735
30665
  }
30736
- visitSwitchBlock(block) {
30737
- block.expression.visit(this);
30738
- block.cases.forEach(this.visitNode);
30739
- }
30740
30666
  visitSwitchBlockCase(block) {
30741
30667
  block.expression?.visit(this);
30742
30668
  this.ingestScopedNode(block);
@@ -30749,9 +30675,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30749
30675
  visitForLoopBlockEmpty(block) {
30750
30676
  this.ingestScopedNode(block);
30751
30677
  }
30752
- visitIfBlock(block) {
30753
- block.branches.forEach((node) => node.visit(this));
30754
- }
30755
30678
  visitIfBlockBranch(block) {
30756
30679
  block.expression?.visit(this);
30757
30680
  this.ingestScopedNode(block);
@@ -30759,11 +30682,8 @@ class TemplateBinder extends RecursiveAstVisitor {
30759
30682
  visitContent(content) {
30760
30683
  this.ingestScopedNode(content);
30761
30684
  }
30762
- visitBoundText(text) {
30763
- text.value.visit(this);
30764
- }
30765
30685
  visitLetDeclaration(decl) {
30766
- decl.value.visit(this);
30686
+ super.visitLetDeclaration(decl);
30767
30687
  if (this.rootNode !== null) {
30768
30688
  this.symbols.set(decl, this.rootNode);
30769
30689
  }
@@ -30785,10 +30705,6 @@ class TemplateBinder extends RecursiveAstVisitor {
30785
30705
  this.maybeMap(ast, ast.name);
30786
30706
  return super.visitSafePropertyRead(ast, context);
30787
30707
  }
30788
- visitPropertyWrite(ast, context) {
30789
- this.maybeMap(ast, ast.name);
30790
- return super.visitPropertyWrite(ast, context);
30791
- }
30792
30708
  ingestScopedNode(node) {
30793
30709
  const childScope = this.scope.getChildScope(node);
30794
30710
  const binder = new TemplateBinder(this.bindings, this.symbols, this.usedPipes, this.eagerPipes, this.deferBlocks, this.nestingLevel, childScope, node, this.level + 1);
@@ -31757,7 +31673,7 @@ class _Visitor {
31757
31673
  this._init(_VisitorMode.Merge, interpolationConfig);
31758
31674
  this._translations = translations;
31759
31675
  // Construct a single fake root element
31760
- const wrapper = new Element('wrapper', [], [], nodes, undefined, undefined, undefined);
31676
+ const wrapper = new Element('wrapper', [], [], nodes, false, undefined, undefined, undefined);
31761
31677
  const translatedNode = wrapper.visit(this, null);
31762
31678
  if (this._inI18nBlock) {
31763
31679
  this._reportError(nodes[nodes.length - 1], 'Unclosed block');
@@ -31935,10 +31851,10 @@ class _Visitor {
31935
31851
  this._inImplicitNode = wasInImplicitNode;
31936
31852
  if (this._mode === _VisitorMode.Merge) {
31937
31853
  if (node instanceof Element) {
31938
- return new Element(node.name, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
31854
+ return new Element(node.name, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
31939
31855
  }
31940
31856
  else {
31941
- return new Component(node.componentName, node.tagName, node.fullName, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
31857
+ return new Component(node.componentName, node.tagName, node.fullName, this._translateAttributes(node), this._translateDirectives(node), childNodes, node.isSelfClosing, node.sourceSpan, node.startSourceSpan, node.endSourceSpan);
31942
31858
  }
31943
31859
  }
31944
31860
  return null;
@@ -32166,7 +32082,7 @@ function isAttrNode(ast) {
32166
32082
  * @description
32167
32083
  * Entry point for all public APIs of the compiler package.
32168
32084
  */
32169
- new Version('20.0.1');
32085
+ new Version('20.1.0-next.0');
32170
32086
 
32171
32087
  //////////////////////////////////////
32172
32088
  // THIS FILE HAS GLOBAL SIDE EFFECT //
@@ -32329,6 +32245,10 @@ exports.ErrorCode = void 0;
32329
32245
  * class used as a component).
32330
32246
  */
32331
32247
  ErrorCode[ErrorCode["INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE"] = 2025] = "INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE";
32248
+ /**
32249
+ * Raised for `@Component` fields that aren't supported in a selectorless context.
32250
+ */
32251
+ ErrorCode[ErrorCode["UNSUPPORTED_SELECTORLESS_COMPONENT_FIELD"] = 2026] = "UNSUPPORTED_SELECTORLESS_COMPONENT_FIELD";
32332
32252
  ErrorCode[ErrorCode["SYMBOL_NOT_EXPORTED"] = 3001] = "SYMBOL_NOT_EXPORTED";
32333
32253
  /**
32334
32254
  * Raised when a relationship between directives and/or pipes would cause a cyclic import to be
@@ -33182,7 +33102,7 @@ class NodeJSPathManipulation {
33182
33102
  // G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
33183
33103
  // CommonJS/ESM interop for determining the current file name and containing dir.
33184
33104
  const isCommonJS = typeof __filename !== 'undefined';
33185
- const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-Bu1Wu4f7.cjs', document.baseURI).href));
33105
+ const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-CuQvkMhs.cjs', document.baseURI).href));
33186
33106
  const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
33187
33107
  /**
33188
33108
  * A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
@@ -38319,24 +38239,6 @@ class ExpressionTranslatorVisitor {
38319
38239
  this.setSourceMapRange(identifier, ast.sourceSpan);
38320
38240
  return identifier;
38321
38241
  }
38322
- visitWriteVarExpr(expr, context) {
38323
- const assignment = this.factory.createAssignment(this.setSourceMapRange(this.factory.createIdentifier(expr.name), expr.sourceSpan), expr.value.visitExpression(this, context));
38324
- return context.isStatement
38325
- ? assignment
38326
- : this.factory.createParenthesizedExpression(assignment);
38327
- }
38328
- visitWriteKeyExpr(expr, context) {
38329
- const exprContext = context.withExpressionMode;
38330
- const target = this.factory.createElementAccess(expr.receiver.visitExpression(this, exprContext), expr.index.visitExpression(this, exprContext));
38331
- const assignment = this.factory.createAssignment(target, expr.value.visitExpression(this, exprContext));
38332
- return context.isStatement
38333
- ? assignment
38334
- : this.factory.createParenthesizedExpression(assignment);
38335
- }
38336
- visitWritePropExpr(expr, context) {
38337
- const target = this.factory.createPropertyAccess(expr.receiver.visitExpression(this, context), expr.name);
38338
- return this.factory.createAssignment(target, expr.value.visitExpression(this, context));
38339
- }
38340
38242
  visitInvokeFunctionExpr(ast, context) {
38341
38243
  return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
38342
38244
  }
@@ -38457,6 +38359,9 @@ class ExpressionTranslatorVisitor {
38457
38359
  : ast.body.visitExpression(this, context));
38458
38360
  }
38459
38361
  visitBinaryOperatorExpr(ast, context) {
38362
+ if (ast.operator === BinaryOperator.Assign) {
38363
+ return this.factory.createAssignment(ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context));
38364
+ }
38460
38365
  if (!BINARY_OPERATORS$1.has(ast.operator)) {
38461
38366
  throw new Error(`Unknown binary operator: ${BinaryOperator[ast.operator]}`);
38462
38367
  }
@@ -38789,15 +38694,6 @@ class TypeTranslatorVisitor {
38789
38694
  }
38790
38695
  return ts.factory.createTypeQueryNode(ts.factory.createIdentifier(ast.name));
38791
38696
  }
38792
- visitWriteVarExpr(expr, context) {
38793
- throw new Error('Method not implemented.');
38794
- }
38795
- visitWriteKeyExpr(expr, context) {
38796
- throw new Error('Method not implemented.');
38797
- }
38798
- visitWritePropExpr(expr, context) {
38799
- throw new Error('Method not implemented.');
38800
- }
38801
38697
  visitInvokeFunctionExpr(ast, context) {
38802
38698
  throw new Error('Method not implemented.');
38803
38699
  }
@@ -39490,6 +39386,7 @@ exports.ComponentScopeKind = void 0;
39490
39386
  (function (ComponentScopeKind) {
39491
39387
  ComponentScopeKind[ComponentScopeKind["NgModule"] = 0] = "NgModule";
39492
39388
  ComponentScopeKind[ComponentScopeKind["Standalone"] = 1] = "Standalone";
39389
+ ComponentScopeKind[ComponentScopeKind["Selectorless"] = 2] = "Selectorless";
39493
39390
  })(exports.ComponentScopeKind || (exports.ComponentScopeKind = {}));
39494
39391
 
39495
39392
  /**
@@ -39912,7 +39809,7 @@ const QUERY_TYPES = new Set(queryDecoratorNames);
39912
39809
  * appear in the declarations of an `NgModule` and additional verification is done when processing
39913
39810
  * the module.
39914
39811
  */
39915
- function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, evaluator, refEmitter, referencesRegistry, isCore, annotateForClosureCompiler, compilationMode, defaultSelector, strictStandalone, implicitStandaloneValue) {
39812
+ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, evaluator, refEmitter, referencesRegistry, isCore, annotateForClosureCompiler, compilationMode, defaultSelector, strictStandalone, implicitStandaloneValue, emitDeclarationOnly) {
39916
39813
  let directive;
39917
39814
  if (decorator.args === null || decorator.args.length === 0) {
39918
39815
  directive = new Map();
@@ -39938,8 +39835,8 @@ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, ev
39938
39835
  const coreModule = isCore ? undefined : '@angular/core';
39939
39836
  // Construct the map of inputs both from the @Directive/@Component
39940
39837
  // decorator, and the decorated fields.
39941
- const inputsFromMeta = parseInputsArray(clazz, directive, evaluator, reflector, refEmitter, compilationMode);
39942
- const inputsFromFields = parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromMeta, decorator);
39838
+ const inputsFromMeta = parseInputsArray(clazz, directive, evaluator, reflector, refEmitter, compilationMode, emitDeclarationOnly);
39839
+ const inputsFromFields = parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromMeta, decorator, emitDeclarationOnly);
39943
39840
  const inputs = ClassPropertyMapping.fromMappedObject({ ...inputsFromMeta, ...inputsFromFields });
39944
39841
  // And outputs.
39945
39842
  const outputsFromMeta = parseOutputsArray(directive, evaluator);
@@ -40049,7 +39946,7 @@ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, ev
40049
39946
  const rawHostDirectives = directive.get('hostDirectives') || null;
40050
39947
  const hostDirectives = rawHostDirectives === null
40051
39948
  ? null
40052
- : extractHostDirectives(rawHostDirectives, evaluator, compilationMode, createForwardRefResolver(isCore));
39949
+ : extractHostDirectives(rawHostDirectives, evaluator, reflector, compilationMode, createForwardRefResolver(isCore), emitDeclarationOnly);
40053
39950
  if (compilationMode !== exports.CompilationMode.LOCAL && hostDirectives !== null) {
40054
39951
  // In global compilation mode where we do type checking, the template type-checker will need to
40055
39952
  // import host directive types, so add them as referenced by `clazz`. This will ensure that
@@ -40397,7 +40294,7 @@ function parseMappingString(value) {
40397
40294
  return [bindingPropertyName ?? fieldName, fieldName];
40398
40295
  }
40399
40296
  /** Parses the `inputs` array of a directive/component decorator. */
40400
- function parseInputsArray(clazz, decoratorMetadata, evaluator, reflector, refEmitter, compilationMode) {
40297
+ function parseInputsArray(clazz, decoratorMetadata, evaluator, reflector, refEmitter, compilationMode, emitDeclarationOnly) {
40401
40298
  const inputsField = decoratorMetadata.get('inputs');
40402
40299
  if (inputsField === undefined) {
40403
40300
  return {};
@@ -40435,7 +40332,7 @@ function parseInputsArray(clazz, decoratorMetadata, evaluator, reflector, refEmi
40435
40332
  if (!(transformValue instanceof DynamicValue) && !(transformValue instanceof Reference)) {
40436
40333
  throw createValueHasWrongTypeError(inputsField, transformValue, `Transform of value at position ${i} of @Directive.inputs array must be a function`);
40437
40334
  }
40438
- transform = parseDecoratorInputTransformFunction(clazz, name, transformValue, reflector, refEmitter, compilationMode);
40335
+ transform = parseDecoratorInputTransformFunction(clazz, name, transformValue, reflector, refEmitter, compilationMode, emitDeclarationOnly);
40439
40336
  }
40440
40337
  inputs[name] = {
40441
40338
  classPropertyName: name,
@@ -40464,7 +40361,7 @@ function tryGetDecoratorOnMember(member, decoratorName, isCore) {
40464
40361
  }
40465
40362
  return null;
40466
40363
  }
40467
- function tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode) {
40364
+ function tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode, emitDeclarationOnly) {
40468
40365
  const classPropertyName = member.name;
40469
40366
  const decorator = tryGetDecoratorOnMember(member, 'Input', isCore);
40470
40367
  const signalInputMapping = tryParseSignalInputMapping(member, reflector, importTracker);
@@ -40502,7 +40399,7 @@ function tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTr
40502
40399
  if (!(transformValue instanceof DynamicValue) && !(transformValue instanceof Reference)) {
40503
40400
  throw createValueHasWrongTypeError(optionsNode, transformValue, `Input transform must be a function`);
40504
40401
  }
40505
- transform = parseDecoratorInputTransformFunction(clazz, classPropertyName, transformValue, reflector, refEmitter, compilationMode);
40402
+ transform = parseDecoratorInputTransformFunction(clazz, classPropertyName, transformValue, reflector, refEmitter, compilationMode, emitDeclarationOnly);
40506
40403
  }
40507
40404
  return {
40508
40405
  isSignal: false,
@@ -40522,11 +40419,11 @@ function tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTr
40522
40419
  return null;
40523
40420
  }
40524
40421
  /** Parses the class members that declare inputs (via decorator or initializer). */
40525
- function parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromClassDecorator, classDecorator) {
40422
+ function parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromClassDecorator, classDecorator, emitDeclarationOnly) {
40526
40423
  const inputs = {};
40527
40424
  for (const member of members) {
40528
40425
  const classPropertyName = member.name;
40529
- const inputMapping = tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode);
40426
+ const inputMapping = tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode, emitDeclarationOnly);
40530
40427
  if (inputMapping === null) {
40531
40428
  continue;
40532
40429
  }
@@ -40552,7 +40449,22 @@ function parseInputFields(clazz, members, evaluator, reflector, importTracker, r
40552
40449
  * automatically captured in the type of the `InputSignal`.
40553
40450
  *
40554
40451
  */
40555
- function parseDecoratorInputTransformFunction(clazz, classPropertyName, value, reflector, refEmitter, compilationMode) {
40452
+ function parseDecoratorInputTransformFunction(clazz, classPropertyName, value, reflector, refEmitter, compilationMode, emitDeclarationOnly) {
40453
+ if (emitDeclarationOnly) {
40454
+ const chain = {
40455
+ messageText: '@Input decorators with a transform function are not supported in experimental declaration-only emission mode',
40456
+ category: ts.DiagnosticCategory.Error,
40457
+ code: 0,
40458
+ next: [
40459
+ {
40460
+ messageText: `Consider converting '${clazz.name.text}.${classPropertyName}' to an input signal`,
40461
+ category: ts.DiagnosticCategory.Message,
40462
+ code: 0,
40463
+ },
40464
+ ],
40465
+ };
40466
+ throw new FatalDiagnosticError(exports.ErrorCode.DECORATOR_UNEXPECTED, value.node, chain);
40467
+ }
40556
40468
  // In local compilation mode we can skip type checking the function args. This is because usually
40557
40469
  // the type check is done in a separate build which runs in full compilation mode. So here we skip
40558
40470
  // all the diagnostics.
@@ -40830,7 +40742,7 @@ function getHostBindingErrorNode(error, hostExpr) {
40830
40742
  * Extracts and prepares the host directives metadata from an array literal expression.
40831
40743
  * @param rawHostDirectives Expression that defined the `hostDirectives`.
40832
40744
  */
40833
- function extractHostDirectives(rawHostDirectives, evaluator, compilationMode, forwardRefResolver) {
40745
+ function extractHostDirectives(rawHostDirectives, evaluator, reflector, compilationMode, forwardRefResolver, emitDeclarationOnly) {
40834
40746
  const resolved = evaluator.evaluate(rawHostDirectives, forwardRefResolver);
40835
40747
  if (!Array.isArray(resolved)) {
40836
40748
  throw createValueHasWrongTypeError(rawHostDirectives, resolved, 'hostDirectives must be an array');
@@ -40856,9 +40768,28 @@ function extractHostDirectives(rawHostDirectives, evaluator, compilationMode, fo
40856
40768
  // forward ref for imported symbols?!)
40857
40769
  if (!ts.isIdentifier(hostReference.node) &&
40858
40770
  !ts.isPropertyAccessExpression(hostReference.node)) {
40859
- throw new FatalDiagnosticError(exports.ErrorCode.LOCAL_COMPILATION_UNSUPPORTED_EXPRESSION, hostReference.node, `In local compilation mode, host directive cannot be an expression. Use an identifier instead`);
40771
+ const compilationModeName = emitDeclarationOnly
40772
+ ? 'experimental declaration-only emission'
40773
+ : 'local compilation';
40774
+ throw new FatalDiagnosticError(exports.ErrorCode.LOCAL_COMPILATION_UNSUPPORTED_EXPRESSION, hostReference.node, `In ${compilationModeName} mode, host directive cannot be an expression. Use an identifier instead`);
40775
+ }
40776
+ if (emitDeclarationOnly) {
40777
+ if (ts.isIdentifier(hostReference.node)) {
40778
+ const importInfo = reflector.getImportOfIdentifier(hostReference.node);
40779
+ if (importInfo) {
40780
+ directive = new ExternalReference(importInfo.from, importInfo.name);
40781
+ }
40782
+ else {
40783
+ throw new FatalDiagnosticError(exports.ErrorCode.LOCAL_COMPILATION_UNSUPPORTED_EXPRESSION, hostReference.node, `In experimental declaration-only emission mode, host directive cannot use indirect external indentifiers. Use a direct external identifier instead`);
40784
+ }
40785
+ }
40786
+ else {
40787
+ throw new FatalDiagnosticError(exports.ErrorCode.LOCAL_COMPILATION_UNSUPPORTED_EXPRESSION, hostReference.node, `In experimental declaration-only emission mode, host directive cannot be an expression. Use an identifier instead`);
40788
+ }
40789
+ }
40790
+ else {
40791
+ directive = new WrappedNodeExpr(hostReference.node);
40860
40792
  }
40861
- directive = new WrappedNodeExpr(hostReference.node);
40862
40793
  }
40863
40794
  else if (hostReference instanceof Reference) {
40864
40795
  directive = hostReference;
@@ -40898,6 +40829,12 @@ function toHostDirectiveMetadata(hostDirective, context, refEmitter) {
40898
40829
  if (hostDirective.directive instanceof Reference) {
40899
40830
  directive = toR3Reference(hostDirective.directive.node, hostDirective.directive, context, refEmitter);
40900
40831
  }
40832
+ else if (hostDirective.directive instanceof ExternalReference) {
40833
+ directive = {
40834
+ value: new ExternalExpr(hostDirective.directive),
40835
+ type: new ExternalExpr(hostDirective.directive),
40836
+ };
40837
+ }
40901
40838
  else {
40902
40839
  directive = {
40903
40840
  value: hostDirective.directive,
@@ -41117,6 +41054,8 @@ exports.SymbolKind = void 0;
41117
41054
  SymbolKind[SymbolKind["DomBinding"] = 9] = "DomBinding";
41118
41055
  SymbolKind[SymbolKind["Pipe"] = 10] = "Pipe";
41119
41056
  SymbolKind[SymbolKind["LetDeclaration"] = 11] = "LetDeclaration";
41057
+ SymbolKind[SymbolKind["SelectorlessComponent"] = 12] = "SelectorlessComponent";
41058
+ SymbolKind[SymbolKind["SelectorlessDirective"] = 13] = "SelectorlessDirective";
41120
41059
  })(exports.SymbolKind || (exports.SymbolKind = {}));
41121
41060
 
41122
41061
  /**
@@ -41414,6 +41353,10 @@ class CompletionEngine {
41414
41353
  tcbPath;
41415
41354
  tcbIsShim;
41416
41355
  componentContext;
41356
+ /**
41357
+ * Get the `TcbLocation` for the global context, which is the location of the `this` variable.
41358
+ */
41359
+ globalTsContext;
41417
41360
  /**
41418
41361
  * Cache of completions for various levels of the template, including the root template (`null`).
41419
41362
  * Memoizes `getTemplateContextCompletions`.
@@ -41439,11 +41382,20 @@ class CompletionEngine {
41439
41382
  // for the component context.
41440
41383
  positionInFile: globalRead.name.getStart(),
41441
41384
  };
41385
+ this.globalTsContext = {
41386
+ tcbPath: this.tcbPath,
41387
+ isShimFile: this.tcbIsShim,
41388
+ positionInFile: globalRead.name.getStart() - 1,
41389
+ };
41442
41390
  }
41443
41391
  else {
41444
41392
  this.componentContext = null;
41393
+ this.globalTsContext = null;
41445
41394
  }
41446
41395
  }
41396
+ getGlobalTsContext() {
41397
+ return this.globalTsContext;
41398
+ }
41447
41399
  /**
41448
41400
  * Get global completions within the given template context and AST node.
41449
41401
  *
@@ -41499,7 +41451,7 @@ class CompletionEngine {
41499
41451
  }
41500
41452
  // Completion works inside property reads and method calls.
41501
41453
  let tsExpr = null;
41502
- if (expr instanceof PropertyRead || expr instanceof PropertyWrite) {
41454
+ if (expr instanceof PropertyRead) {
41503
41455
  // Non-safe navigation operations are trivial: `foo.bar` or `foo.bar()`
41504
41456
  tsExpr = findFirstMatchingNode(this.tcb, {
41505
41457
  filter: ts.isPropertyAccessExpression,
@@ -44463,10 +44415,11 @@ class OutOfBandDiagnosticRecorderImpl {
44463
44415
  missingNamedTemplateDependency(id, node) {
44464
44416
  this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts.DiagnosticCategory.Error, ngErrorCode(exports.ErrorCode.MISSING_NAMED_TEMPLATE_DEPENDENCY),
44465
44417
  // Wording is meant to mimic the wording TS uses in their diagnostic for missing symbols.
44466
- `Cannot find name "${node instanceof Directive$1 ? node.name : node.componentName}".`));
44418
+ `Cannot find name "${node instanceof Directive$1 ? node.name : node.componentName}". ` +
44419
+ `Selectorless references are only supported to classes or non-type import statements.`));
44467
44420
  }
44468
44421
  incorrectTemplateDependencyType(id, node) {
44469
- this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts.DiagnosticCategory.Error, ngErrorCode(exports.ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be an ${node instanceof Component$1 ? '@Component' : '@Directive'}.`));
44422
+ this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts.DiagnosticCategory.Error, ngErrorCode(exports.ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be a standalone ${node instanceof Component$1 ? '@Component' : '@Directive'}.`));
44470
44423
  }
44471
44424
  unclaimedDirectiveBinding(id, directive, node) {
44472
44425
  const errorMsg = `Directive ${directive.name} does not have an ` +
@@ -44627,6 +44580,7 @@ const BINARY_OPS = new Map([
44627
44580
  ['>', ts.SyntaxKind.GreaterThanToken],
44628
44581
  ['<=', ts.SyntaxKind.LessThanEqualsToken],
44629
44582
  ['>=', ts.SyntaxKind.GreaterThanEqualsToken],
44583
+ ['=', ts.SyntaxKind.EqualsToken],
44630
44584
  ['==', ts.SyntaxKind.EqualsEqualsToken],
44631
44585
  ['===', ts.SyntaxKind.EqualsEqualsEqualsToken],
44632
44586
  ['*', ts.SyntaxKind.AsteriskToken],
@@ -44737,16 +44691,6 @@ class AstTranslator {
44737
44691
  addParseSpanInfo(node, ast.sourceSpan);
44738
44692
  return node;
44739
44693
  }
44740
- visitKeyedWrite(ast) {
44741
- const receiver = wrapForDiagnostics(this.translate(ast.receiver));
44742
- const left = ts.factory.createElementAccessExpression(receiver, this.translate(ast.key));
44743
- // TODO(joost): annotate `left` with the span of the element access, which is not currently
44744
- // available on `ast`.
44745
- const right = wrapForTypeChecker(this.translate(ast.value));
44746
- const node = wrapForDiagnostics(ts.factory.createBinaryExpression(left, ts.SyntaxKind.EqualsToken, right));
44747
- addParseSpanInfo(node, ast.sourceSpan);
44748
- return node;
44749
- }
44750
44694
  visitLiteralArray(ast) {
44751
44695
  const elements = ast.expressions.map((expr) => this.translate(expr));
44752
44696
  const literal = ts.factory.createArrayLiteralExpression(elements);
@@ -44826,27 +44770,6 @@ class AstTranslator {
44826
44770
  addParseSpanInfo(node, ast.sourceSpan);
44827
44771
  return node;
44828
44772
  }
44829
- visitPropertyWrite(ast) {
44830
- const receiver = wrapForDiagnostics(this.translate(ast.receiver));
44831
- const left = ts.factory.createPropertyAccessExpression(receiver, ast.name);
44832
- addParseSpanInfo(left, ast.nameSpan);
44833
- // TypeScript reports assignment errors on the entire lvalue expression. Annotate the lvalue of
44834
- // the assignment with the sourceSpan, which includes receivers, rather than nameSpan for
44835
- // consistency of the diagnostic location.
44836
- // a.b.c = 1
44837
- // ^^^^^^^^^ sourceSpan
44838
- // ^ nameSpan
44839
- const leftWithPath = wrapForDiagnostics(left);
44840
- addParseSpanInfo(leftWithPath, ast.sourceSpan);
44841
- // The right needs to be wrapped in parens as well or we cannot accurately match its
44842
- // span to just the RHS. For example, the span in `e = $event /*0,10*/` is ambiguous.
44843
- // It could refer to either the whole binary expression or just the RHS.
44844
- // We should instead generate `e = ($event /*0,10*/)` so we know the span 0,10 matches RHS.
44845
- const right = wrapForTypeChecker(this.translate(ast.value));
44846
- const node = wrapForDiagnostics(ts.factory.createBinaryExpression(leftWithPath, ts.SyntaxKind.EqualsToken, right));
44847
- addParseSpanInfo(node, ast.sourceSpan);
44848
- return node;
44849
- }
44850
44773
  visitSafePropertyRead(ast) {
44851
44774
  let node;
44852
44775
  const receiver = wrapForDiagnostics(this.translate(ast.receiver));
@@ -45036,9 +44959,6 @@ class VeSafeLhsInferenceBugDetector {
45036
44959
  visitKeyedRead(ast) {
45037
44960
  return false;
45038
44961
  }
45039
- visitKeyedWrite(ast) {
45040
- return false;
45041
- }
45042
44962
  visitLiteralArray(ast) {
45043
44963
  return true;
45044
44964
  }
@@ -45066,9 +44986,6 @@ class VeSafeLhsInferenceBugDetector {
45066
44986
  visitPropertyRead(ast) {
45067
44987
  return false;
45068
44988
  }
45069
- visitPropertyWrite(ast) {
45070
- return false;
45071
- }
45072
44989
  visitSafePropertyRead(ast) {
45073
44990
  return false;
45074
44991
  }
@@ -47329,7 +47246,7 @@ class Scope {
47329
47246
  const directives = this.tcb.boundTarget.getDirectivesOfNode(directive);
47330
47247
  if (directives === null ||
47331
47248
  directives.length === 0 ||
47332
- directives.some((dir) => dir.isComponent)) {
47249
+ directives.some((dir) => dir.isComponent || !dir.isStandalone)) {
47333
47250
  this.tcb.oobRecorder.incorrectTemplateDependencyType(this.tcb.id, directive);
47334
47251
  continue;
47335
47252
  }
@@ -47402,7 +47319,7 @@ class Scope {
47402
47319
  const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
47403
47320
  if (directives === null ||
47404
47321
  directives.length === 0 ||
47405
- directives.every((dir) => !dir.isComponent)) {
47322
+ directives.every((dir) => !dir.isComponent || !dir.isStandalone)) {
47406
47323
  this.tcb.oobRecorder.incorrectTemplateDependencyType(this.tcb.id, node);
47407
47324
  return;
47408
47325
  }
@@ -47552,21 +47469,25 @@ class TcbExpressionTranslator {
47552
47469
  }
47553
47470
  return targetExpression;
47554
47471
  }
47555
- else if (ast instanceof PropertyWrite && ast.receiver instanceof ImplicitReceiver) {
47556
- const target = this.tcb.boundTarget.getExpressionTarget(ast);
47472
+ else if (ast instanceof Binary &&
47473
+ ast.operation === '=' &&
47474
+ ast.left instanceof PropertyRead &&
47475
+ ast.left.receiver instanceof ImplicitReceiver) {
47476
+ const read = ast.left;
47477
+ const target = this.tcb.boundTarget.getExpressionTarget(read);
47557
47478
  if (target === null) {
47558
47479
  return null;
47559
47480
  }
47560
- const targetExpression = this.getTargetNodeExpression(target, ast);
47561
- const expr = this.translate(ast.value);
47481
+ const targetExpression = this.getTargetNodeExpression(target, read);
47482
+ const expr = this.translate(ast.right);
47562
47483
  const result = ts.factory.createParenthesizedExpression(ts.factory.createBinaryExpression(targetExpression, ts.SyntaxKind.EqualsToken, expr));
47563
- addParseSpanInfo(result, ast.sourceSpan);
47484
+ addParseSpanInfo(result, read.sourceSpan);
47564
47485
  // Ignore diagnostics from TS produced for writes to `@let` and re-report them using
47565
47486
  // our own infrastructure. We can't rely on the TS reporting, because it includes
47566
47487
  // the name of the auto-generated TCB variable name.
47567
47488
  if (target instanceof LetDeclaration$1) {
47568
47489
  markIgnoreDiagnostics(result);
47569
- this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, ast, target);
47490
+ this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, read, target);
47570
47491
  }
47571
47492
  return result;
47572
47493
  }
@@ -48554,6 +48475,12 @@ class SymbolBuilder {
48554
48475
  else if (node instanceof Element$1) {
48555
48476
  symbol = this.getSymbolOfElement(node);
48556
48477
  }
48478
+ else if (node instanceof Component$1) {
48479
+ symbol = this.getSymbolOfSelectorlessComponent(node);
48480
+ }
48481
+ else if (node instanceof Directive$1) {
48482
+ symbol = this.getSymbolOfSelectorlessDirective(node);
48483
+ }
48557
48484
  else if (node instanceof Template) {
48558
48485
  symbol = this.getSymbolOfAstTemplate(node);
48559
48486
  }
@@ -48604,8 +48531,38 @@ class SymbolBuilder {
48604
48531
  templateNode: element,
48605
48532
  };
48606
48533
  }
48607
- getDirectivesOfNode(element) {
48608
- const elementSourceSpan = element.startSourceSpan ?? element.sourceSpan;
48534
+ getSymbolOfSelectorlessComponent(node) {
48535
+ const directives = this.getDirectivesOfNode(node);
48536
+ const primaryDirective = directives.find((dir) => !dir.isHostDirective && dir.isComponent) ?? null;
48537
+ if (primaryDirective === null) {
48538
+ return null;
48539
+ }
48540
+ return {
48541
+ tsType: primaryDirective.tsType,
48542
+ tsSymbol: primaryDirective.tsSymbol,
48543
+ tcbLocation: primaryDirective.tcbLocation,
48544
+ kind: exports.SymbolKind.SelectorlessComponent,
48545
+ directives,
48546
+ templateNode: node,
48547
+ };
48548
+ }
48549
+ getSymbolOfSelectorlessDirective(node) {
48550
+ const directives = this.getDirectivesOfNode(node);
48551
+ const primaryDirective = directives.find((dir) => !dir.isHostDirective && !dir.isComponent) ?? null;
48552
+ if (primaryDirective === null) {
48553
+ return null;
48554
+ }
48555
+ return {
48556
+ tsType: primaryDirective.tsType,
48557
+ tsSymbol: primaryDirective.tsSymbol,
48558
+ tcbLocation: primaryDirective.tcbLocation,
48559
+ kind: exports.SymbolKind.SelectorlessDirective,
48560
+ directives,
48561
+ templateNode: node,
48562
+ };
48563
+ }
48564
+ getDirectivesOfNode(templateNode) {
48565
+ const elementSourceSpan = templateNode.startSourceSpan ?? templateNode.sourceSpan;
48609
48566
  const tcbSourceFile = this.typeCheckBlock.getSourceFile();
48610
48567
  // directives could be either:
48611
48568
  // - var _t1: TestDir /*T:D*/ = null! as TestDir;
@@ -48618,6 +48575,7 @@ class SymbolBuilder {
48618
48575
  filter: isDirectiveDeclaration,
48619
48576
  });
48620
48577
  const symbols = [];
48578
+ const seenDirectives = new Set();
48621
48579
  for (const node of nodes) {
48622
48580
  const symbol = this.getSymbolOfTsNode(node.parent);
48623
48581
  if (symbol === null ||
@@ -48625,11 +48583,14 @@ class SymbolBuilder {
48625
48583
  !ts.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
48626
48584
  continue;
48627
48585
  }
48628
- const meta = this.getDirectiveMeta(element, symbol.tsSymbol.valueDeclaration);
48629
- if (meta !== null && meta.selector !== null) {
48630
- const ref = new Reference(symbol.tsSymbol.valueDeclaration);
48586
+ const declaration = symbol.tsSymbol.valueDeclaration;
48587
+ const meta = this.getDirectiveMeta(templateNode, declaration);
48588
+ // Host directives will be added as identifiers with the same offset as the host
48589
+ // which means that they'll get added twice. De-duplicate them to avoid confusion.
48590
+ if (meta !== null && !seenDirectives.has(declaration)) {
48591
+ const ref = new Reference(declaration);
48631
48592
  if (meta.hostDirectives !== null) {
48632
- this.addHostDirectiveSymbols(element, meta.hostDirectives, symbols);
48593
+ this.addHostDirectiveSymbols(templateNode, meta.hostDirectives, symbols, seenDirectives);
48633
48594
  }
48634
48595
  const directiveSymbol = {
48635
48596
  ...symbol,
@@ -48637,30 +48598,33 @@ class SymbolBuilder {
48637
48598
  tsSymbol: symbol.tsSymbol,
48638
48599
  selector: meta.selector,
48639
48600
  isComponent: meta.isComponent,
48640
- ngModule: this.getDirectiveModule(symbol.tsSymbol.valueDeclaration),
48601
+ ngModule: this.getDirectiveModule(declaration),
48641
48602
  kind: exports.SymbolKind.Directive,
48642
48603
  isStructural: meta.isStructural,
48643
48604
  isInScope: true,
48644
48605
  isHostDirective: false,
48606
+ tsCompletionEntryInfo: null,
48645
48607
  };
48646
48608
  symbols.push(directiveSymbol);
48609
+ seenDirectives.add(declaration);
48647
48610
  }
48648
48611
  }
48649
48612
  return symbols;
48650
48613
  }
48651
- addHostDirectiveSymbols(host, hostDirectives, symbols) {
48614
+ addHostDirectiveSymbols(host, hostDirectives, symbols, seenDirectives) {
48652
48615
  for (const current of hostDirectives) {
48653
48616
  if (!isHostDirectiveMetaForGlobalMode(current)) {
48654
48617
  throw new Error('Impossible state: typecheck code path in local compilation mode.');
48655
48618
  }
48656
- if (!ts.isClassDeclaration(current.directive.node)) {
48619
+ const node = current.directive.node;
48620
+ if (!ts.isClassDeclaration(node) || seenDirectives.has(node)) {
48657
48621
  continue;
48658
48622
  }
48659
- const symbol = this.getSymbolOfTsNode(current.directive.node);
48660
- const meta = this.getDirectiveMeta(host, current.directive.node);
48623
+ const symbol = this.getSymbolOfTsNode(node);
48624
+ const meta = this.getDirectiveMeta(host, node);
48661
48625
  if (meta !== null && symbol !== null && isSymbolWithValueDeclaration(symbol.tsSymbol)) {
48662
48626
  if (meta.hostDirectives !== null) {
48663
- this.addHostDirectiveSymbols(host, meta.hostDirectives, symbols);
48627
+ this.addHostDirectiveSymbols(host, meta.hostDirectives, symbols, seenDirectives);
48664
48628
  }
48665
48629
  const directiveSymbol = {
48666
48630
  ...symbol,
@@ -48671,12 +48635,14 @@ class SymbolBuilder {
48671
48635
  exposedOutputs: current.outputs,
48672
48636
  selector: meta.selector,
48673
48637
  isComponent: meta.isComponent,
48674
- ngModule: this.getDirectiveModule(current.directive.node),
48638
+ ngModule: this.getDirectiveModule(node),
48675
48639
  kind: exports.SymbolKind.Directive,
48676
48640
  isStructural: meta.isStructural,
48677
48641
  isInScope: true,
48642
+ tsCompletionEntryInfo: null,
48678
48643
  };
48679
48644
  symbols.push(directiveSymbol);
48645
+ seenDirectives.add(node);
48680
48646
  }
48681
48647
  }
48682
48648
  }
@@ -48685,16 +48651,19 @@ class SymbolBuilder {
48685
48651
  // `getDirectivesOfNode` will not return the directives intended for an element
48686
48652
  // on a microsyntax template, for example `<div *ngFor="let user of users;" dir>`,
48687
48653
  // the `dir` will be skipped, but it's needed in language service.
48688
- const firstChild = host.children[0];
48689
- if (firstChild instanceof Element$1) {
48690
- const isMicrosyntaxTemplate = host instanceof Template && sourceSpanEqual(firstChild.sourceSpan, host.sourceSpan);
48691
- if (isMicrosyntaxTemplate) {
48692
- const firstChildDirectives = this.typeCheckData.boundTarget.getDirectivesOfNode(firstChild);
48693
- if (firstChildDirectives !== null && directives !== null) {
48694
- directives = directives.concat(firstChildDirectives);
48695
- }
48696
- else {
48697
- directives = directives ?? firstChildDirectives;
48654
+ if (!(host instanceof Directive$1)) {
48655
+ const firstChild = host.children[0];
48656
+ if (firstChild instanceof Element$1) {
48657
+ const isMicrosyntaxTemplate = host instanceof Template &&
48658
+ sourceSpanEqual(firstChild.sourceSpan, host.sourceSpan);
48659
+ if (isMicrosyntaxTemplate) {
48660
+ const firstChildDirectives = this.typeCheckData.boundTarget.getDirectivesOfNode(firstChild);
48661
+ if (firstChildDirectives !== null && directives !== null) {
48662
+ directives = directives.concat(firstChildDirectives);
48663
+ }
48664
+ else {
48665
+ directives = directives ?? firstChildDirectives;
48666
+ }
48698
48667
  }
48699
48668
  }
48700
48669
  }
@@ -48898,9 +48867,7 @@ class SymbolBuilder {
48898
48867
  getDirectiveSymbolForAccessExpression(fieldAccessExpr, { isComponent, selector, isStructural }) {
48899
48868
  // In all cases, `_t1["index"]` or `_t1.index`, `node.expression` is _t1.
48900
48869
  const tsSymbol = this.getTypeChecker().getSymbolAtLocation(fieldAccessExpr.expression);
48901
- if (tsSymbol?.declarations === undefined ||
48902
- tsSymbol.declarations.length === 0 ||
48903
- selector === null) {
48870
+ if (tsSymbol?.declarations === undefined || tsSymbol.declarations.length === 0) {
48904
48871
  return null;
48905
48872
  }
48906
48873
  const [declaration] = tsSymbol.declarations;
@@ -48931,6 +48898,7 @@ class SymbolBuilder {
48931
48898
  ngModule,
48932
48899
  isHostDirective: false,
48933
48900
  isInScope: true, // TODO: this should always be in scope in this context, right?
48901
+ tsCompletionEntryInfo: null,
48934
48902
  };
48935
48903
  }
48936
48904
  getSymbolOfVariable(variable) {
@@ -49087,11 +49055,15 @@ class SymbolBuilder {
49087
49055
  return this.getSymbol(expressionTarget);
49088
49056
  }
49089
49057
  let withSpan = expression.sourceSpan;
49090
- // The `name` part of a `PropertyWrite` and `ASTWithName` do not have their own
49058
+ // The `name` part of a property write and `ASTWithName` do not have their own
49091
49059
  // AST so there is no way to retrieve a `Symbol` for just the `name` via a specific node.
49092
49060
  // Also skipping SafePropertyReads as it breaks nullish coalescing not nullable extended diagnostic
49093
- if (expression instanceof PropertyWrite ||
49094
- (expression instanceof ASTWithName && !(expression instanceof SafePropertyRead))) {
49061
+ if (expression instanceof Binary &&
49062
+ expression.operation === '=' &&
49063
+ expression.left instanceof PropertyRead) {
49064
+ withSpan = expression.left.nameSpan;
49065
+ }
49066
+ else if (expression instanceof ASTWithName && !(expression instanceof SafePropertyRead)) {
49095
49067
  withSpan = expression.nameSpan;
49096
49068
  }
49097
49069
  let node = null;
@@ -49703,37 +49675,44 @@ class TemplateTypeCheckerImpl {
49703
49675
  this.symbolBuilderCache.set(component, builder);
49704
49676
  return builder;
49705
49677
  }
49706
- getPotentialTemplateDirectives(component) {
49707
- const typeChecker = this.programDriver.getProgram().getTypeChecker();
49708
- const inScopeDirectives = this.getScopeData(component)?.directives ?? [];
49709
- const resultingDirectives = new Map();
49710
- // First, all in scope directives can be used.
49711
- for (const d of inScopeDirectives) {
49712
- resultingDirectives.set(d.ref.node, d);
49678
+ getGlobalTsContext(component) {
49679
+ const engine = this.getOrCreateCompletionEngine(component);
49680
+ if (engine === null) {
49681
+ return null;
49713
49682
  }
49714
- // Any additional directives found from the global registry can be used, but are not in scope.
49715
- // In the future, we can also walk other registries for .d.ts files, or traverse the
49716
- // import/export graph.
49717
- for (const directiveClass of this.localMetaReader.getKnown(exports.MetaKind.Directive)) {
49718
- const directiveMeta = this.metaReader.getDirectiveMetadata(new Reference(directiveClass));
49719
- if (directiveMeta === null)
49720
- continue;
49721
- if (resultingDirectives.has(directiveClass))
49722
- continue;
49723
- const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveMeta);
49724
- if (withScope === null)
49683
+ return engine.getGlobalTsContext();
49684
+ }
49685
+ getPotentialTemplateDirectives(component, tsLs, options) {
49686
+ const scope = this.getComponentScope(component);
49687
+ // Don't resolve directives for selectorless components since they're already in the file.
49688
+ if (scope?.kind === exports.ComponentScopeKind.Selectorless) {
49689
+ return [];
49690
+ }
49691
+ const resultingDirectives = new Map();
49692
+ const directivesInScope = this.getTemplateDirectiveInScope(component);
49693
+ const directiveInGlobal = this.getElementsInGlobal(component, tsLs, options);
49694
+ for (const directive of [...directivesInScope, ...directiveInGlobal]) {
49695
+ if (resultingDirectives.has(directive.ref.node)) {
49725
49696
  continue;
49726
- resultingDirectives.set(directiveClass, { ...withScope, isInScope: false });
49697
+ }
49698
+ resultingDirectives.set(directive.ref.node, directive);
49727
49699
  }
49728
49700
  return Array.from(resultingDirectives.values());
49729
49701
  }
49730
49702
  getPotentialPipes(component) {
49703
+ const scope = this.getComponentScope(component);
49704
+ // Don't resolve pipes for selectorless components since they're already in the file.
49705
+ if (scope?.kind === exports.ComponentScopeKind.Selectorless) {
49706
+ return [];
49707
+ }
49731
49708
  // Very similar to the above `getPotentialTemplateDirectives`, but on pipes.
49732
49709
  const typeChecker = this.programDriver.getProgram().getTypeChecker();
49733
- const inScopePipes = this.getScopeData(component)?.pipes ?? [];
49734
49710
  const resultingPipes = new Map();
49735
- for (const p of inScopePipes) {
49736
- resultingPipes.set(p.ref.node, p);
49711
+ if (scope !== null) {
49712
+ const inScopePipes = this.getScopeData(component, scope)?.pipes ?? [];
49713
+ for (const p of inScopePipes) {
49714
+ resultingPipes.set(p.ref.node, p);
49715
+ }
49737
49716
  }
49738
49717
  for (const pipeClass of this.localMetaReader.getKnown(exports.MetaKind.Pipe)) {
49739
49718
  const pipeMeta = this.metaReader.getPipeMetadata(new Reference(pipeClass));
@@ -49766,7 +49745,156 @@ class TemplateTypeCheckerImpl {
49766
49745
  }
49767
49746
  return this.metaReader.getPipeMetadata(new Reference(pipe));
49768
49747
  }
49769
- getPotentialElementTags(component) {
49748
+ getTemplateDirectiveInScope(component) {
49749
+ const resultingDirectives = new Map();
49750
+ const scope = this.getComponentScope(component);
49751
+ // Don't resolve directives for selectorless components since they're already in the file.
49752
+ if (scope?.kind === exports.ComponentScopeKind.Selectorless) {
49753
+ return [];
49754
+ }
49755
+ if (scope !== null) {
49756
+ const inScopeDirectives = this.getScopeData(component, scope)?.directives ?? [];
49757
+ // First, all in scope directives can be used.
49758
+ for (const d of inScopeDirectives) {
49759
+ resultingDirectives.set(d.ref.node, d);
49760
+ }
49761
+ }
49762
+ const typeChecker = this.programDriver.getProgram().getTypeChecker();
49763
+ const currentComponentFileName = component.getSourceFile().fileName;
49764
+ // Any additional directives found from the global registry can be used, only includes the directives includes in the current
49765
+ // component file.
49766
+ //
49767
+ // This means only the inputs in the decorator are needed to be updated, no need to update the import statement.
49768
+ for (const directiveClass of this.localMetaReader.getKnown(exports.MetaKind.Directive)) {
49769
+ if (directiveClass.getSourceFile().fileName !== currentComponentFileName) {
49770
+ continue;
49771
+ }
49772
+ const directiveMeta = this.metaReader.getDirectiveMetadata(new Reference(directiveClass));
49773
+ if (directiveMeta === null)
49774
+ continue;
49775
+ if (resultingDirectives.has(directiveClass))
49776
+ continue;
49777
+ const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveMeta);
49778
+ if (withScope === null)
49779
+ continue;
49780
+ resultingDirectives.set(directiveClass, { ...withScope, isInScope: false });
49781
+ }
49782
+ return Array.from(resultingDirectives.values());
49783
+ }
49784
+ getDirectiveScopeData(component, isInScope, tsCompletionEntryInfo) {
49785
+ const typeChecker = this.programDriver.getProgram().getTypeChecker();
49786
+ if (!isNamedClassDeclaration(component)) {
49787
+ return null;
49788
+ }
49789
+ const directiveMeta = this.metaReader.getDirectiveMetadata(new Reference(component));
49790
+ if (directiveMeta === null) {
49791
+ return null;
49792
+ }
49793
+ const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveMeta);
49794
+ if (withScope === null) {
49795
+ return null;
49796
+ }
49797
+ return {
49798
+ ...withScope,
49799
+ isInScope,
49800
+ tsCompletionEntryInfo,
49801
+ };
49802
+ }
49803
+ getElementsInFileScope(component) {
49804
+ const tagMap = new Map();
49805
+ const potentialDirectives = this.getTemplateDirectiveInScope(component);
49806
+ for (const directive of potentialDirectives) {
49807
+ if (directive.selector === null) {
49808
+ continue;
49809
+ }
49810
+ for (const selector of CssSelector.parse(directive.selector)) {
49811
+ if (selector.element === null || tagMap.has(selector.element)) {
49812
+ // Skip this directive if it doesn't match an element tag, or if another directive has
49813
+ // already been included with the same element name.
49814
+ continue;
49815
+ }
49816
+ tagMap.set(selector.element, directive);
49817
+ }
49818
+ }
49819
+ return tagMap;
49820
+ }
49821
+ getElementsInGlobal(component, tsLs, options) {
49822
+ // Add the additional directives from the global registry, which are not in scope and in different file with the current
49823
+ // component file.
49824
+ //
49825
+ // This means the inputs and the import statement in the decorator are needed to be updated.
49826
+ const tsContext = this.getGlobalTsContext(component);
49827
+ if (tsContext === null) {
49828
+ return [];
49829
+ }
49830
+ if (!options.includeExternalModule) {
49831
+ return [];
49832
+ }
49833
+ const entries = tsLs.getCompletionsAtPosition(tsContext.tcbPath, tsContext.positionInFile, {
49834
+ includeSymbol: true,
49835
+ includeCompletionsForModuleExports: true,
49836
+ })?.entries;
49837
+ const typeChecker = this.programDriver.getProgram().getTypeChecker();
49838
+ const resultingDirectives = new Map();
49839
+ const currentComponentFileName = component.getSourceFile().fileName;
49840
+ for (const { symbol, data } of entries ?? []) {
49841
+ const symbolFileName = symbol?.declarations?.[0]?.getSourceFile().fileName;
49842
+ if (symbolFileName === undefined) {
49843
+ continue;
49844
+ }
49845
+ if (symbolFileName === currentComponentFileName) {
49846
+ continue;
49847
+ }
49848
+ const decl = getClassDeclFromSymbol(symbol, typeChecker);
49849
+ if (decl === null) {
49850
+ continue;
49851
+ }
49852
+ const directiveDecls = [];
49853
+ const ref = new Reference(decl);
49854
+ const directiveMeta = this.metaReader.getDirectiveMetadata(ref);
49855
+ if (directiveMeta?.isStandalone) {
49856
+ directiveDecls.push({
49857
+ meta: directiveMeta,
49858
+ ref,
49859
+ });
49860
+ }
49861
+ else {
49862
+ const ngModuleMeta = this.metaReader.getNgModuleMetadata(ref);
49863
+ if (ngModuleMeta === null) {
49864
+ continue;
49865
+ }
49866
+ for (const moduleExports of ngModuleMeta.exports) {
49867
+ const directiveMeta = this.metaReader.getDirectiveMetadata(moduleExports);
49868
+ if (directiveMeta === null) {
49869
+ continue;
49870
+ }
49871
+ directiveDecls.push({
49872
+ meta: directiveMeta,
49873
+ ref: moduleExports,
49874
+ });
49875
+ }
49876
+ }
49877
+ for (const directiveDecl of directiveDecls) {
49878
+ if (resultingDirectives.has(directiveDecl.ref.node)) {
49879
+ continue;
49880
+ }
49881
+ const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveDecl.meta);
49882
+ if (withScope === null) {
49883
+ continue;
49884
+ }
49885
+ resultingDirectives.set(directiveDecl.ref.node, {
49886
+ ...withScope,
49887
+ isInScope: false,
49888
+ tsCompletionEntryInfo: {
49889
+ tsCompletionEntryData: data,
49890
+ tsCompletionEntrySymbolFileName: symbolFileName,
49891
+ },
49892
+ });
49893
+ }
49894
+ }
49895
+ return Array.from(resultingDirectives.values());
49896
+ }
49897
+ getPotentialElementTags(component, tsLs, options) {
49770
49898
  if (this.elementTagCache.has(component)) {
49771
49899
  return this.elementTagCache.get(component);
49772
49900
  }
@@ -49774,7 +49902,7 @@ class TemplateTypeCheckerImpl {
49774
49902
  for (const tag of REGISTRY.allKnownElementNames()) {
49775
49903
  tagMap.set(tag, null);
49776
49904
  }
49777
- const potentialDirectives = this.getPotentialTemplateDirectives(component);
49905
+ const potentialDirectives = this.getPotentialTemplateDirectives(component, tsLs, options);
49778
49906
  for (const directive of potentialDirectives) {
49779
49907
  if (directive.selector === null) {
49780
49908
  continue;
@@ -49897,16 +50025,15 @@ class TemplateTypeCheckerImpl {
49897
50025
  }
49898
50026
  return imports;
49899
50027
  }
49900
- getScopeData(component) {
49901
- if (this.scopeCache.has(component)) {
49902
- return this.scopeCache.get(component);
49903
- }
50028
+ getComponentScope(component) {
49904
50029
  if (!isNamedClassDeclaration(component)) {
49905
50030
  throw new Error(`AssertionError: components must have names`);
49906
50031
  }
49907
- const scope = this.componentScopeReader.getScopeForComponent(component);
49908
- if (scope === null) {
49909
- return null;
50032
+ return this.componentScopeReader.getScopeForComponent(component);
50033
+ }
50034
+ getScopeData(component, scope) {
50035
+ if (this.scopeCache.has(component)) {
50036
+ return this.scopeCache.get(component);
49910
50037
  }
49911
50038
  const dependencies = scope.kind === exports.ComponentScopeKind.NgModule
49912
50039
  ? scope.compilation.dependencies
@@ -49957,6 +50084,7 @@ class TemplateTypeCheckerImpl {
49957
50084
  selector: dep.selector,
49958
50085
  tsSymbol,
49959
50086
  ngModule,
50087
+ tsCompletionEntryInfo: null,
49960
50088
  };
49961
50089
  }
49962
50090
  scopeDataOfPipeMeta(typeChecker, dep) {
@@ -49968,6 +50096,7 @@ class TemplateTypeCheckerImpl {
49968
50096
  ref: dep.ref,
49969
50097
  name: dep.name,
49970
50098
  tsSymbol,
50099
+ tsCompletionEntryInfo: null,
49971
50100
  };
49972
50101
  }
49973
50102
  }
@@ -50082,15 +50211,37 @@ class SingleShimTypeCheckingHost extends SingleFileTypeCheckingHost {
50082
50211
  return !this.fileData.shimData.has(shimPath);
50083
50212
  }
50084
50213
  }
50214
+ function getClassDeclFromSymbol(symbol, checker) {
50215
+ const tsDecl = symbol?.getDeclarations();
50216
+ if (tsDecl === undefined) {
50217
+ return null;
50218
+ }
50219
+ let decl = tsDecl.length > 0 ? tsDecl[0] : undefined;
50220
+ if (decl === undefined) {
50221
+ return null;
50222
+ }
50223
+ if (ts.isExportAssignment(decl)) {
50224
+ const symbol = checker.getTypeAtLocation(decl.expression).symbol;
50225
+ return getClassDeclFromSymbol(symbol, checker);
50226
+ }
50227
+ if (ts.isExportSpecifier(decl)) {
50228
+ const symbol = checker.getTypeAtLocation(decl).symbol;
50229
+ return getClassDeclFromSymbol(symbol, checker);
50230
+ }
50231
+ if (isNamedClassDeclaration(decl)) {
50232
+ return decl;
50233
+ }
50234
+ return null;
50235
+ }
50085
50236
 
50086
50237
  exports.AST = AST;
50087
50238
  exports.ASTWithSource = ASTWithSource;
50088
50239
  exports.AbsoluteModuleStrategy = AbsoluteModuleStrategy;
50089
50240
  exports.ArrowFunctionExpr = ArrowFunctionExpr;
50090
50241
  exports.Binary = Binary;
50242
+ exports.BindingPipe = BindingPipe;
50091
50243
  exports.BlockPlaceholder = BlockPlaceholder;
50092
50244
  exports.BoundAttribute = BoundAttribute;
50093
- exports.BoundDeferredTrigger = BoundDeferredTrigger;
50094
50245
  exports.BoundEvent = BoundEvent;
50095
50246
  exports.COMPILER_ERRORS_WITH_GUIDES = COMPILER_ERRORS_WITH_GUIDES;
50096
50247
  exports.CR = CR;
@@ -50099,6 +50250,7 @@ exports.Call = Call;
50099
50250
  exports.Chain = Chain;
50100
50251
  exports.ClassPropertyMapping = ClassPropertyMapping;
50101
50252
  exports.CloneVisitor = CloneVisitor;
50253
+ exports.CombinedRecursiveAstVisitor = CombinedRecursiveAstVisitor;
50102
50254
  exports.Component = Component$1;
50103
50255
  exports.CompoundMetadataReader = CompoundMetadataReader;
50104
50256
  exports.Conditional = Conditional;
@@ -50154,7 +50306,6 @@ exports.ParseSourceSpan = ParseSourceSpan;
50154
50306
  exports.Parser = Parser$1;
50155
50307
  exports.Placeholder = Placeholder;
50156
50308
  exports.PropertyRead = PropertyRead;
50157
- exports.PropertyWrite = PropertyWrite;
50158
50309
  exports.QUERY_INITIALIZER_FNS = QUERY_INITIALIZER_FNS;
50159
50310
  exports.R3TargetBinder = R3TargetBinder;
50160
50311
  exports.ReadVarExpr = ReadVarExpr;
@@ -50171,6 +50322,7 @@ exports.SafeCall = SafeCall;
50171
50322
  exports.SafeKeyedRead = SafeKeyedRead;
50172
50323
  exports.SafePropertyRead = SafePropertyRead;
50173
50324
  exports.SelectorMatcher = SelectorMatcher;
50325
+ exports.SelectorlessMatcher = SelectorlessMatcher;
50174
50326
  exports.Serializer = Serializer;
50175
50327
  exports.StaticInterpreter = StaticInterpreter;
50176
50328
  exports.SyntheticValue = SyntheticValue;