@angular/core 18.1.0-next.1 → 18.1.0-next.3

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 (47) hide show
  1. package/esm2022/rxjs-interop/src/to_signal.mjs +7 -3
  2. package/esm2022/src/authoring/model/model_signal.mjs +2 -3
  3. package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +2 -2
  4. package/esm2022/src/core.mjs +1 -1
  5. package/esm2022/src/core_render3_private_export.mjs +2 -2
  6. package/esm2022/src/defer/instructions.mjs +2 -10
  7. package/esm2022/src/errors.mjs +1 -1
  8. package/esm2022/src/event_emitter.mjs +20 -11
  9. package/esm2022/src/hydration/event_replay.mjs +32 -14
  10. package/esm2022/src/linker/component_factory.mjs +1 -1
  11. package/esm2022/src/pending_tasks.mjs +15 -20
  12. package/esm2022/src/render3/after_render_hooks.mjs +67 -132
  13. package/esm2022/src/render3/chained_injector.mjs +34 -0
  14. package/esm2022/src/render3/component.mjs +1 -1
  15. package/esm2022/src/render3/component_ref.mjs +23 -35
  16. package/esm2022/src/render3/index.mjs +2 -2
  17. package/esm2022/src/render3/instructions/all.mjs +2 -1
  18. package/esm2022/src/render3/instructions/change_detection.mjs +27 -24
  19. package/esm2022/src/render3/instructions/let_declaration.mjs +39 -0
  20. package/esm2022/src/render3/jit/environment.mjs +4 -1
  21. package/esm2022/src/render3/reactive_lview_consumer.mjs +56 -3
  22. package/esm2022/src/render3/util/injector_discovery_utils.mjs +14 -5
  23. package/esm2022/src/render3/util/injector_utils.mjs +10 -1
  24. package/esm2022/src/version.mjs +1 -1
  25. package/esm2022/testing/src/logger.mjs +3 -3
  26. package/fesm2022/core.mjs +500 -424
  27. package/fesm2022/core.mjs.map +1 -1
  28. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  29. package/fesm2022/primitives/signals.mjs +1 -1
  30. package/fesm2022/rxjs-interop.mjs +7 -3
  31. package/fesm2022/rxjs-interop.mjs.map +1 -1
  32. package/fesm2022/testing.mjs +1 -1
  33. package/index.d.ts +246 -32
  34. package/package.json +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 +13 -6
  38. package/schematics/migrations/after-render-phase/bundle.js +623 -0
  39. package/schematics/migrations/after-render-phase/bundle.js.map +7 -0
  40. package/schematics/migrations/invalid-two-way-bindings/bundle.js +265 -61
  41. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +4 -4
  42. package/schematics/migrations.json +5 -0
  43. package/schematics/ng-generate/control-flow-migration/bundle.js +272 -61
  44. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  45. package/schematics/ng-generate/standalone-migration/bundle.js +320 -727
  46. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  47. package/testing/index.d.ts +1 -1
@@ -9,6 +9,11 @@
9
9
  "version": "18.0.0",
10
10
  "description": "Replace deprecated HTTP related modules with provider functions",
11
11
  "factory": "./migrations/http-providers/bundle"
12
+ },
13
+ "migration-after-render-phase": {
14
+ "version": "18.1.0",
15
+ "description": "Updates calls to afterRender with an explicit phase to the new API",
16
+ "factory": "./migrations/after-render-phase/bundle"
12
17
  }
13
18
  }
14
19
  }
@@ -2676,6 +2676,15 @@ var Identifiers = _Identifiers;
2676
2676
  (() => {
2677
2677
  _Identifiers.twoWayListener = { name: "\u0275\u0275twoWayListener", moduleName: CORE };
2678
2678
  })();
2679
+ (() => {
2680
+ _Identifiers.declareLet = { name: "\u0275\u0275declareLet", moduleName: CORE };
2681
+ })();
2682
+ (() => {
2683
+ _Identifiers.storeLet = { name: "\u0275\u0275storeLet", moduleName: CORE };
2684
+ })();
2685
+ (() => {
2686
+ _Identifiers.readContextLet = { name: "\u0275\u0275readContextLet", moduleName: CORE };
2687
+ })();
2679
2688
  (() => {
2680
2689
  _Identifiers.NgOnChangesFeature = { name: "\u0275\u0275NgOnChangesFeature", moduleName: CORE };
2681
2690
  })();
@@ -6163,16 +6172,18 @@ var OpKind;
6163
6172
  OpKind2[OpKind2["Repeater"] = 35] = "Repeater";
6164
6173
  OpKind2[OpKind2["TwoWayProperty"] = 36] = "TwoWayProperty";
6165
6174
  OpKind2[OpKind2["TwoWayListener"] = 37] = "TwoWayListener";
6166
- OpKind2[OpKind2["I18nStart"] = 38] = "I18nStart";
6167
- OpKind2[OpKind2["I18n"] = 39] = "I18n";
6168
- OpKind2[OpKind2["I18nEnd"] = 40] = "I18nEnd";
6169
- OpKind2[OpKind2["I18nExpression"] = 41] = "I18nExpression";
6170
- OpKind2[OpKind2["I18nApply"] = 42] = "I18nApply";
6171
- OpKind2[OpKind2["IcuStart"] = 43] = "IcuStart";
6172
- OpKind2[OpKind2["IcuEnd"] = 44] = "IcuEnd";
6173
- OpKind2[OpKind2["IcuPlaceholder"] = 45] = "IcuPlaceholder";
6174
- OpKind2[OpKind2["I18nContext"] = 46] = "I18nContext";
6175
- OpKind2[OpKind2["I18nAttributes"] = 47] = "I18nAttributes";
6175
+ OpKind2[OpKind2["DeclareLet"] = 38] = "DeclareLet";
6176
+ OpKind2[OpKind2["StoreLet"] = 39] = "StoreLet";
6177
+ OpKind2[OpKind2["I18nStart"] = 40] = "I18nStart";
6178
+ OpKind2[OpKind2["I18n"] = 41] = "I18n";
6179
+ OpKind2[OpKind2["I18nEnd"] = 42] = "I18nEnd";
6180
+ OpKind2[OpKind2["I18nExpression"] = 43] = "I18nExpression";
6181
+ OpKind2[OpKind2["I18nApply"] = 44] = "I18nApply";
6182
+ OpKind2[OpKind2["IcuStart"] = 45] = "IcuStart";
6183
+ OpKind2[OpKind2["IcuEnd"] = 46] = "IcuEnd";
6184
+ OpKind2[OpKind2["IcuPlaceholder"] = 47] = "IcuPlaceholder";
6185
+ OpKind2[OpKind2["I18nContext"] = 48] = "I18nContext";
6186
+ OpKind2[OpKind2["I18nAttributes"] = 49] = "I18nAttributes";
6176
6187
  })(OpKind || (OpKind = {}));
6177
6188
  var ExpressionKind;
6178
6189
  (function(ExpressionKind2) {
@@ -6182,24 +6193,26 @@ var ExpressionKind;
6182
6193
  ExpressionKind2[ExpressionKind2["ReadVariable"] = 3] = "ReadVariable";
6183
6194
  ExpressionKind2[ExpressionKind2["NextContext"] = 4] = "NextContext";
6184
6195
  ExpressionKind2[ExpressionKind2["Reference"] = 5] = "Reference";
6185
- ExpressionKind2[ExpressionKind2["GetCurrentView"] = 6] = "GetCurrentView";
6186
- ExpressionKind2[ExpressionKind2["RestoreView"] = 7] = "RestoreView";
6187
- ExpressionKind2[ExpressionKind2["ResetView"] = 8] = "ResetView";
6188
- ExpressionKind2[ExpressionKind2["PureFunctionExpr"] = 9] = "PureFunctionExpr";
6189
- ExpressionKind2[ExpressionKind2["PureFunctionParameterExpr"] = 10] = "PureFunctionParameterExpr";
6190
- ExpressionKind2[ExpressionKind2["PipeBinding"] = 11] = "PipeBinding";
6191
- ExpressionKind2[ExpressionKind2["PipeBindingVariadic"] = 12] = "PipeBindingVariadic";
6192
- ExpressionKind2[ExpressionKind2["SafePropertyRead"] = 13] = "SafePropertyRead";
6193
- ExpressionKind2[ExpressionKind2["SafeKeyedRead"] = 14] = "SafeKeyedRead";
6194
- ExpressionKind2[ExpressionKind2["SafeInvokeFunction"] = 15] = "SafeInvokeFunction";
6195
- ExpressionKind2[ExpressionKind2["SafeTernaryExpr"] = 16] = "SafeTernaryExpr";
6196
- ExpressionKind2[ExpressionKind2["EmptyExpr"] = 17] = "EmptyExpr";
6197
- ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 18] = "AssignTemporaryExpr";
6198
- ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 19] = "ReadTemporaryExpr";
6199
- ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 20] = "SlotLiteralExpr";
6200
- ExpressionKind2[ExpressionKind2["ConditionalCase"] = 21] = "ConditionalCase";
6201
- ExpressionKind2[ExpressionKind2["ConstCollected"] = 22] = "ConstCollected";
6202
- ExpressionKind2[ExpressionKind2["TwoWayBindingSet"] = 23] = "TwoWayBindingSet";
6196
+ ExpressionKind2[ExpressionKind2["StoreLet"] = 6] = "StoreLet";
6197
+ ExpressionKind2[ExpressionKind2["ContextLetReference"] = 7] = "ContextLetReference";
6198
+ ExpressionKind2[ExpressionKind2["GetCurrentView"] = 8] = "GetCurrentView";
6199
+ ExpressionKind2[ExpressionKind2["RestoreView"] = 9] = "RestoreView";
6200
+ ExpressionKind2[ExpressionKind2["ResetView"] = 10] = "ResetView";
6201
+ ExpressionKind2[ExpressionKind2["PureFunctionExpr"] = 11] = "PureFunctionExpr";
6202
+ ExpressionKind2[ExpressionKind2["PureFunctionParameterExpr"] = 12] = "PureFunctionParameterExpr";
6203
+ ExpressionKind2[ExpressionKind2["PipeBinding"] = 13] = "PipeBinding";
6204
+ ExpressionKind2[ExpressionKind2["PipeBindingVariadic"] = 14] = "PipeBindingVariadic";
6205
+ ExpressionKind2[ExpressionKind2["SafePropertyRead"] = 15] = "SafePropertyRead";
6206
+ ExpressionKind2[ExpressionKind2["SafeKeyedRead"] = 16] = "SafeKeyedRead";
6207
+ ExpressionKind2[ExpressionKind2["SafeInvokeFunction"] = 17] = "SafeInvokeFunction";
6208
+ ExpressionKind2[ExpressionKind2["SafeTernaryExpr"] = 18] = "SafeTernaryExpr";
6209
+ ExpressionKind2[ExpressionKind2["EmptyExpr"] = 19] = "EmptyExpr";
6210
+ ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 20] = "AssignTemporaryExpr";
6211
+ ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 21] = "ReadTemporaryExpr";
6212
+ ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 22] = "SlotLiteralExpr";
6213
+ ExpressionKind2[ExpressionKind2["ConditionalCase"] = 23] = "ConditionalCase";
6214
+ ExpressionKind2[ExpressionKind2["ConstCollected"] = 24] = "ConstCollected";
6215
+ ExpressionKind2[ExpressionKind2["TwoWayBindingSet"] = 25] = "TwoWayBindingSet";
6203
6216
  })(ExpressionKind || (ExpressionKind = {}));
6204
6217
  var VariableFlags;
6205
6218
  (function(VariableFlags2) {
@@ -6294,8 +6307,8 @@ var TRAIT_CONSUMES_VARS = {
6294
6307
  function hasConsumesSlotTrait(op) {
6295
6308
  return op[ConsumesSlot] === true;
6296
6309
  }
6297
- function hasDependsOnSlotContextTrait(op) {
6298
- return op[DependsOnSlotContext] === true;
6310
+ function hasDependsOnSlotContextTrait(value) {
6311
+ return value[DependsOnSlotContext] === true;
6299
6312
  }
6300
6313
  function hasConsumesVarsTrait(value) {
6301
6314
  return value[ConsumesVarsTrait] === true;
@@ -6505,6 +6518,15 @@ function createI18nApplyOp(owner, handle, sourceSpan) {
6505
6518
  sourceSpan
6506
6519
  }, NEW_OP);
6507
6520
  }
6521
+ function createStoreLetOp(target, declaredName, value, sourceSpan) {
6522
+ return __spreadValues(__spreadValues(__spreadValues({
6523
+ kind: OpKind.StoreLet,
6524
+ target,
6525
+ declaredName,
6526
+ value,
6527
+ sourceSpan
6528
+ }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
6529
+ }
6508
6530
 
6509
6531
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/expression.mjs
6510
6532
  var _a;
@@ -6513,6 +6535,8 @@ var _c;
6513
6535
  var _d;
6514
6536
  var _e;
6515
6537
  var _f;
6538
+ var _g;
6539
+ var _h;
6516
6540
  function isIrExpression(expr) {
6517
6541
  return expr instanceof ExpressionBase;
6518
6542
  }
@@ -6563,6 +6587,56 @@ var ReferenceExpr = class extends ExpressionBase {
6563
6587
  return new ReferenceExpr(this.target, this.targetSlot, this.offset);
6564
6588
  }
6565
6589
  };
6590
+ var _StoreLetExpr = class extends ExpressionBase {
6591
+ constructor(target, value, sourceSpan) {
6592
+ super();
6593
+ this.target = target;
6594
+ this.value = value;
6595
+ this.sourceSpan = sourceSpan;
6596
+ this.kind = ExpressionKind.StoreLet;
6597
+ this[_a] = true;
6598
+ this[_b] = true;
6599
+ }
6600
+ visitExpression() {
6601
+ }
6602
+ isEquivalent(e) {
6603
+ return e instanceof _StoreLetExpr && e.target === this.target && e.value.isEquivalent(this.value);
6604
+ }
6605
+ isConstant() {
6606
+ return false;
6607
+ }
6608
+ transformInternalExpressions(transform2, flags) {
6609
+ this.value = transformExpressionsInExpression(this.value, transform2, flags);
6610
+ }
6611
+ clone() {
6612
+ return new _StoreLetExpr(this.target, this.value, this.sourceSpan);
6613
+ }
6614
+ };
6615
+ var StoreLetExpr = _StoreLetExpr;
6616
+ (() => {
6617
+ _a = ConsumesVarsTrait, _b = DependsOnSlotContext;
6618
+ })();
6619
+ var ContextLetReferenceExpr = class extends ExpressionBase {
6620
+ constructor(target, targetSlot) {
6621
+ super();
6622
+ this.target = target;
6623
+ this.targetSlot = targetSlot;
6624
+ this.kind = ExpressionKind.ContextLetReference;
6625
+ }
6626
+ visitExpression() {
6627
+ }
6628
+ isEquivalent(e) {
6629
+ return e instanceof ContextLetReferenceExpr && e.target === this.target;
6630
+ }
6631
+ isConstant() {
6632
+ return false;
6633
+ }
6634
+ transformInternalExpressions() {
6635
+ }
6636
+ clone() {
6637
+ return new ContextLetReferenceExpr(this.target, this.targetSlot);
6638
+ }
6639
+ };
6566
6640
  var ContextExpr = class extends ExpressionBase {
6567
6641
  constructor(view) {
6568
6642
  super();
@@ -6751,8 +6825,8 @@ var _PureFunctionExpr = class extends ExpressionBase {
6751
6825
  constructor(expression, args) {
6752
6826
  super();
6753
6827
  this.kind = ExpressionKind.PureFunctionExpr;
6754
- this[_a] = true;
6755
- this[_b] = true;
6828
+ this[_c] = true;
6829
+ this[_d] = true;
6756
6830
  this.varOffset = null;
6757
6831
  this.fn = null;
6758
6832
  this.body = expression;
@@ -6794,7 +6868,7 @@ var _PureFunctionExpr = class extends ExpressionBase {
6794
6868
  };
6795
6869
  var PureFunctionExpr = _PureFunctionExpr;
6796
6870
  (() => {
6797
- _a = ConsumesVarsTrait, _b = UsesVarOffset;
6871
+ _c = ConsumesVarsTrait, _d = UsesVarOffset;
6798
6872
  })();
6799
6873
  var PureFunctionParameterExpr = class extends ExpressionBase {
6800
6874
  constructor(index) {
@@ -6824,8 +6898,8 @@ var _PipeBindingExpr = class extends ExpressionBase {
6824
6898
  this.name = name;
6825
6899
  this.args = args;
6826
6900
  this.kind = ExpressionKind.PipeBinding;
6827
- this[_c] = true;
6828
- this[_d] = true;
6901
+ this[_e] = true;
6902
+ this[_f] = true;
6829
6903
  this.varOffset = null;
6830
6904
  }
6831
6905
  visitExpression(visitor, context) {
@@ -6852,7 +6926,7 @@ var _PipeBindingExpr = class extends ExpressionBase {
6852
6926
  };
6853
6927
  var PipeBindingExpr = _PipeBindingExpr;
6854
6928
  (() => {
6855
- _c = ConsumesVarsTrait, _d = UsesVarOffset;
6929
+ _e = ConsumesVarsTrait, _f = UsesVarOffset;
6856
6930
  })();
6857
6931
  var _PipeBindingVariadicExpr = class extends ExpressionBase {
6858
6932
  constructor(target, targetSlot, name, args, numArgs) {
@@ -6863,8 +6937,8 @@ var _PipeBindingVariadicExpr = class extends ExpressionBase {
6863
6937
  this.args = args;
6864
6938
  this.numArgs = numArgs;
6865
6939
  this.kind = ExpressionKind.PipeBindingVariadic;
6866
- this[_e] = true;
6867
- this[_f] = true;
6940
+ this[_g] = true;
6941
+ this[_h] = true;
6868
6942
  this.varOffset = null;
6869
6943
  }
6870
6944
  visitExpression(visitor, context) {
@@ -6887,7 +6961,7 @@ var _PipeBindingVariadicExpr = class extends ExpressionBase {
6887
6961
  };
6888
6962
  var PipeBindingVariadicExpr = _PipeBindingVariadicExpr;
6889
6963
  (() => {
6890
- _e = ConsumesVarsTrait, _f = UsesVarOffset;
6964
+ _g = ConsumesVarsTrait, _h = UsesVarOffset;
6891
6965
  })();
6892
6966
  var SafePropertyReadExpr = class extends ExpressionBase {
6893
6967
  constructor(receiver, name) {
@@ -7246,6 +7320,9 @@ function transformExpressionsInOp(op, transform2, flags) {
7246
7320
  case OpKind.DeferWhen:
7247
7321
  op.expr = transformExpressionsInExpression(op.expr, transform2, flags);
7248
7322
  break;
7323
+ case OpKind.StoreLet:
7324
+ op.value = transformExpressionsInExpression(op.value, transform2, flags);
7325
+ break;
7249
7326
  case OpKind.Advance:
7250
7327
  case OpKind.Container:
7251
7328
  case OpKind.ContainerEnd:
@@ -7271,6 +7348,7 @@ function transformExpressionsInOp(op, transform2, flags) {
7271
7348
  case OpKind.Text:
7272
7349
  case OpKind.I18nAttributes:
7273
7350
  case OpKind.IcuPlaceholder:
7351
+ case OpKind.DeclareLet:
7274
7352
  break;
7275
7353
  default:
7276
7354
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -7786,6 +7864,15 @@ function createDeferOnOp(defer2, trigger, prefetch, sourceSpan) {
7786
7864
  sourceSpan
7787
7865
  }, NEW_OP);
7788
7866
  }
7867
+ function createDeclareLetOp(xref, declaredName, sourceSpan) {
7868
+ return __spreadValues(__spreadValues({
7869
+ kind: OpKind.DeclareLet,
7870
+ xref,
7871
+ declaredName,
7872
+ sourceSpan,
7873
+ handle: new SlotHandle()
7874
+ }, TRAIT_CONSUMES_SLOT), NEW_OP);
7875
+ }
7789
7876
  function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
7790
7877
  return __spreadValues({
7791
7878
  kind: OpKind.I18nMessage,
@@ -8331,7 +8418,8 @@ var CHAINABLE = /* @__PURE__ */ new Set([
8331
8418
  Identifiers.syntheticHostProperty,
8332
8419
  Identifiers.templateCreate,
8333
8420
  Identifiers.twoWayProperty,
8334
- Identifiers.twoWayListener
8421
+ Identifiers.twoWayListener,
8422
+ Identifiers.declareLet
8335
8423
  ]);
8336
8424
  function chain(job) {
8337
8425
  for (const unit of job.units) {
@@ -9235,18 +9323,29 @@ function generateAdvance(job) {
9235
9323
  }
9236
9324
  let slotContext = 0;
9237
9325
  for (const op of unit.update) {
9238
- if (!hasDependsOnSlotContextTrait(op)) {
9326
+ let consumer = null;
9327
+ if (hasDependsOnSlotContextTrait(op)) {
9328
+ consumer = op;
9329
+ } else {
9330
+ visitExpressionsInOp(op, (expr) => {
9331
+ if (consumer === null && hasDependsOnSlotContextTrait(expr)) {
9332
+ consumer = expr;
9333
+ }
9334
+ });
9335
+ }
9336
+ if (consumer === null) {
9239
9337
  continue;
9240
- } else if (!slotMap.has(op.target)) {
9241
- throw new Error(`AssertionError: reference to unknown slot for target ${op.target}`);
9242
9338
  }
9243
- const slot = slotMap.get(op.target);
9339
+ if (!slotMap.has(consumer.target)) {
9340
+ throw new Error(`AssertionError: reference to unknown slot for target ${consumer.target}`);
9341
+ }
9342
+ const slot = slotMap.get(consumer.target);
9244
9343
  if (slotContext !== slot) {
9245
9344
  const delta = slot - slotContext;
9246
9345
  if (delta < 0) {
9247
9346
  throw new Error(`AssertionError: slot counter should never need to move backwards`);
9248
9347
  }
9249
- OpList.insertBefore(createAdvanceOp(delta, op.sourceSpan), op);
9348
+ OpList.insertBefore(createAdvanceOp(delta, consumer.sourceSpan), op);
9250
9349
  slotContext = slot;
9251
9350
  }
9252
9351
  }
@@ -9301,12 +9400,11 @@ function recursivelyProcessView(view, parentScope) {
9301
9400
  break;
9302
9401
  case OpKind.Listener:
9303
9402
  case OpKind.TwoWayListener:
9304
- op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
9403
+ op.handlerOps.prepend(generateVariablesInScopeForView(view, scope, true));
9305
9404
  break;
9306
9405
  }
9307
9406
  }
9308
- const preambleOps = generateVariablesInScopeForView(view, scope);
9309
- view.update.prepend(preambleOps);
9407
+ view.update.prepend(generateVariablesInScopeForView(view, scope, false));
9310
9408
  }
9311
9409
  function getScopeForView(view, parent) {
9312
9410
  const scope = {
@@ -9319,6 +9417,7 @@ function getScopeForView(view, parent) {
9319
9417
  contextVariables: /* @__PURE__ */ new Map(),
9320
9418
  aliases: view.aliases,
9321
9419
  references: [],
9420
+ letDeclarations: [],
9322
9421
  parent
9323
9422
  };
9324
9423
  for (const identifier of view.contextVariables.keys()) {
@@ -9349,11 +9448,22 @@ function getScopeForView(view, parent) {
9349
9448
  });
9350
9449
  }
9351
9450
  break;
9451
+ case OpKind.DeclareLet:
9452
+ scope.letDeclarations.push({
9453
+ targetId: op.xref,
9454
+ targetSlot: op.handle,
9455
+ variable: {
9456
+ kind: SemanticVariableKind.Identifier,
9457
+ name: null,
9458
+ identifier: op.declaredName
9459
+ }
9460
+ });
9461
+ break;
9352
9462
  }
9353
9463
  }
9354
9464
  return scope;
9355
9465
  }
9356
- function generateVariablesInScopeForView(view, scope) {
9466
+ function generateVariablesInScopeForView(view, scope, isListener) {
9357
9467
  const newOps = [];
9358
9468
  if (scope.view !== view.xref) {
9359
9469
  newOps.push(createVariableOp(view.job.allocateXrefId(), scope.viewContextVariable, new NextContextExpr(), VariableFlags.None));
@@ -9370,8 +9480,13 @@ function generateVariablesInScopeForView(view, scope) {
9370
9480
  for (const ref of scope.references) {
9371
9481
  newOps.push(createVariableOp(view.job.allocateXrefId(), ref.variable, new ReferenceExpr(ref.targetId, ref.targetSlot, ref.offset), VariableFlags.None));
9372
9482
  }
9483
+ if (scope.view !== view.xref || isListener) {
9484
+ for (const decl of scope.letDeclarations) {
9485
+ newOps.push(createVariableOp(view.job.allocateXrefId(), decl.variable, new ContextLetReferenceExpr(decl.targetId, decl.targetSlot), VariableFlags.None));
9486
+ }
9487
+ }
9373
9488
  if (scope.parent !== null) {
9374
- newOps.push(...generateVariablesInScopeForView(view, scope.parent));
9489
+ newOps.push(...generateVariablesInScopeForView(view, scope.parent, false));
9375
9490
  }
9376
9491
  return newOps;
9377
9492
  }
@@ -10493,13 +10608,15 @@ var _ParseAST = class {
10493
10608
  const keyStart = this.inputIndex;
10494
10609
  const quoted = this.next.isString();
10495
10610
  const key = this.expectIdentifierOrKeywordOrString();
10496
- keys.push({ key, quoted });
10611
+ const literalMapKey = { key, quoted };
10612
+ keys.push(literalMapKey);
10497
10613
  if (quoted) {
10498
10614
  this.expectCharacter($COLON);
10499
10615
  values.push(this.parsePipe());
10500
10616
  } else if (this.consumeOptionalCharacter($COLON)) {
10501
10617
  values.push(this.parsePipe());
10502
10618
  } else {
10619
+ literalMapKey.isShorthandInitialized = true;
10503
10620
  const span = this.span(keyStart);
10504
10621
  const sourceSpan = this.sourceSpan(keyStart);
10505
10622
  values.push(new PropertyRead(span, sourceSpan, sourceSpan, new ImplicitReceiver(span, sourceSpan), key));
@@ -16221,6 +16338,7 @@ function mergeNextContextsInOps(ops) {
16221
16338
  break;
16222
16339
  case ExpressionKind.GetCurrentView:
16223
16340
  case ExpressionKind.Reference:
16341
+ case ExpressionKind.ContextLetReference:
16224
16342
  tryToMerge = false;
16225
16343
  break;
16226
16344
  }
@@ -16840,6 +16958,15 @@ function repeater(collection, sourceSpan) {
16840
16958
  function deferWhen(prefetch, expr, sourceSpan) {
16841
16959
  return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
16842
16960
  }
16961
+ function declareLet(slot, sourceSpan) {
16962
+ return call(Identifiers.declareLet, [literal(slot)], sourceSpan);
16963
+ }
16964
+ function storeLet(value, sourceSpan) {
16965
+ return importExpr(Identifiers.storeLet).callFn([value], sourceSpan);
16966
+ }
16967
+ function readContextLet(slot) {
16968
+ return importExpr(Identifiers.readContextLet).callFn([literal(slot)]);
16969
+ }
16843
16970
  function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
16844
16971
  const args = [literal(slot), literal(constIndex)];
16845
16972
  if (subTemplateIndex) {
@@ -17154,7 +17281,7 @@ function reify(job) {
17154
17281
  }
17155
17282
  }
17156
17283
  function reifyCreateOperations(unit, ops) {
17157
- var _a2, _b2, _c2, _d2, _e2, _f2, _g;
17284
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
17158
17285
  for (const op of ops) {
17159
17286
  transformExpressionsInOp(op, reifyIrExpression, VisitorContextFlag.None);
17160
17287
  switch (op.kind) {
@@ -17213,6 +17340,9 @@ function reifyCreateOperations(unit, ops) {
17213
17340
  case OpKind.Pipe:
17214
17341
  OpList.replace(op, pipe(op.handle.slot, op.name));
17215
17342
  break;
17343
+ case OpKind.DeclareLet:
17344
+ OpList.replace(op, declareLet(op.handle.slot, op.sourceSpan));
17345
+ break;
17216
17346
  case OpKind.Listener:
17217
17347
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17218
17348
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
@@ -17259,7 +17389,7 @@ function reifyCreateOperations(unit, ops) {
17259
17389
  case DeferTriggerKind.Interaction:
17260
17390
  case DeferTriggerKind.Hover:
17261
17391
  case DeferTriggerKind.Viewport:
17262
- if (((_g = op.trigger.targetSlot) == null ? void 0 : _g.slot) == null || op.trigger.targetSlotViewSteps === null) {
17392
+ if (((_g2 = op.trigger.targetSlot) == null ? void 0 : _g2.slot) == null || op.trigger.targetSlotViewSteps === null) {
17263
17393
  throw new Error(`Slot or view steps not set in trigger reification for trigger kind ${op.trigger.kind}`);
17264
17394
  }
17265
17395
  args = [op.trigger.targetSlot.slot];
@@ -17420,6 +17550,8 @@ function reifyUpdateOperations(_unit, ops) {
17420
17550
  case OpKind.DeferWhen:
17421
17551
  OpList.replace(op, deferWhen(op.prefetch, op.expr, op.sourceSpan));
17422
17552
  break;
17553
+ case OpKind.StoreLet:
17554
+ throw new Error(`AssertionError: unexpected storeLet ${op.declaredName}`);
17423
17555
  case OpKind.Statement:
17424
17556
  break;
17425
17557
  default:
@@ -17477,6 +17609,10 @@ function reifyIrExpression(expr) {
17477
17609
  return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
17478
17610
  case ExpressionKind.SlotLiteralExpr:
17479
17611
  return literal(expr.slot.slot);
17612
+ case ExpressionKind.ContextLetReference:
17613
+ return readContextLet(expr.targetSlot.slot);
17614
+ case ExpressionKind.StoreLet:
17615
+ return storeLet(expr.value, expr.sourceSpan);
17480
17616
  default:
17481
17617
  throw new Error(`AssertionError: Unsupported reification of ir.Expression kind: ${ExpressionKind[expr.kind]}`);
17482
17618
  }
@@ -18029,7 +18165,7 @@ function saveAndRestoreView(job) {
18029
18165
  if (!needsRestoreView) {
18030
18166
  for (const handlerOp of op.handlerOps) {
18031
18167
  visitExpressionsInOp(handlerOp, (expr) => {
18032
- if (expr instanceof ReferenceExpr) {
18168
+ if (expr instanceof ReferenceExpr || expr instanceof ContextLetReferenceExpr) {
18033
18169
  needsRestoreView = true;
18034
18170
  }
18035
18171
  });
@@ -18354,6 +18490,7 @@ function varsUsedByOp(op) {
18354
18490
  case OpKind.I18nExpression:
18355
18491
  case OpKind.Conditional:
18356
18492
  case OpKind.DeferWhen:
18493
+ case OpKind.StoreLet:
18357
18494
  return 1;
18358
18495
  case OpKind.RepeaterCreate:
18359
18496
  return op.emptyView ? 1 : 0;
@@ -18369,6 +18506,8 @@ function varsUsedByIrExpression(expr) {
18369
18506
  return 1 + expr.args.length;
18370
18507
  case ExpressionKind.PipeBindingVariadic:
18371
18508
  return 1 + expr.numArgs;
18509
+ case ExpressionKind.StoreLet:
18510
+ return 1;
18372
18511
  default:
18373
18512
  throw new Error(`AssertionError: unhandled ConsumesVarsTrait expression ${expr.constructor.name}`);
18374
18513
  }
@@ -18520,7 +18659,10 @@ function fencesForIrExpression(expr) {
18520
18659
  return Fence.ViewContextRead | Fence.ViewContextWrite;
18521
18660
  case ExpressionKind.RestoreView:
18522
18661
  return Fence.ViewContextRead | Fence.ViewContextWrite | Fence.SideEffectful;
18662
+ case ExpressionKind.StoreLet:
18663
+ return Fence.SideEffectful;
18523
18664
  case ExpressionKind.Reference:
18665
+ case ExpressionKind.ContextLetReference:
18524
18666
  return Fence.ViewContextRead;
18525
18667
  default:
18526
18668
  return Fence.None;
@@ -18662,6 +18804,59 @@ function wrapI18nIcus(job) {
18662
18804
  }
18663
18805
  }
18664
18806
 
18807
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/store_let_optimization.mjs
18808
+ function optimizeStoreLet(job) {
18809
+ const letUsedExternally = /* @__PURE__ */ new Set();
18810
+ for (const unit of job.units) {
18811
+ for (const op of unit.ops()) {
18812
+ visitExpressionsInOp(op, (expr) => {
18813
+ if (expr instanceof ContextLetReferenceExpr) {
18814
+ letUsedExternally.add(expr.target);
18815
+ }
18816
+ });
18817
+ }
18818
+ }
18819
+ for (const unit of job.units) {
18820
+ for (const op of unit.update) {
18821
+ transformExpressionsInOp(op, (expression) => expression instanceof StoreLetExpr && !letUsedExternally.has(expression.target) ? expression.value : expression, VisitorContextFlag.None);
18822
+ }
18823
+ }
18824
+ }
18825
+
18826
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/remove_illegal_let_references.mjs
18827
+ function removeIllegalLetReferences(job) {
18828
+ for (const unit of job.units) {
18829
+ for (const op of unit.update) {
18830
+ if (op.kind !== OpKind.Variable || op.variable.kind !== SemanticVariableKind.Identifier || !(op.initializer instanceof StoreLetExpr)) {
18831
+ continue;
18832
+ }
18833
+ const name = op.variable.identifier;
18834
+ let current = op;
18835
+ while (current && current.kind !== OpKind.ListEnd) {
18836
+ transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal(void 0) : expr, VisitorContextFlag.None);
18837
+ current = current.prev;
18838
+ }
18839
+ }
18840
+ }
18841
+ }
18842
+
18843
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/generate_local_let_references.mjs
18844
+ function generateLocalLetReferences(job) {
18845
+ for (const unit of job.units) {
18846
+ for (const op of unit.update) {
18847
+ if (op.kind !== OpKind.StoreLet) {
18848
+ continue;
18849
+ }
18850
+ const variable2 = {
18851
+ kind: SemanticVariableKind.Identifier,
18852
+ name: null,
18853
+ identifier: op.declaredName
18854
+ };
18855
+ OpList.replace(op, createVariableOp(job.allocateXrefId(), variable2, new StoreLetExpr(op.target, op.value, op.sourceSpan), VariableFlags.None));
18856
+ }
18857
+ }
18858
+ }
18859
+
18665
18860
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/emit.mjs
18666
18861
  var phases = [
18667
18862
  { kind: CompilationJobKind.Tmpl, fn: removeContentSelectors },
@@ -18689,11 +18884,13 @@ var phases = [
18689
18884
  { kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
18690
18885
  { kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
18691
18886
  { kind: CompilationJobKind.Tmpl, fn: generateProjectionDefs },
18887
+ { kind: CompilationJobKind.Tmpl, fn: generateLocalLetReferences },
18692
18888
  { kind: CompilationJobKind.Tmpl, fn: generateVariables },
18693
18889
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
18694
18890
  { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
18695
18891
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
18696
18892
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
18893
+ { kind: CompilationJobKind.Tmpl, fn: removeIllegalLetReferences },
18697
18894
  { kind: CompilationJobKind.Both, fn: resolveNames },
18698
18895
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
18699
18896
  { kind: CompilationJobKind.Tmpl, fn: transformTwoWayBindingSet },
@@ -18705,6 +18902,7 @@ var phases = [
18705
18902
  { kind: CompilationJobKind.Both, fn: expandSafeReads },
18706
18903
  { kind: CompilationJobKind.Both, fn: generateTemporaryVariables },
18707
18904
  { kind: CompilationJobKind.Both, fn: optimizeVariables },
18905
+ { kind: CompilationJobKind.Both, fn: optimizeStoreLet },
18708
18906
  { kind: CompilationJobKind.Tmpl, fn: allocateSlots },
18709
18907
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
18710
18908
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
@@ -18921,6 +19119,7 @@ function ingestNodes(unit, template2) {
18921
19119
  } else if (node instanceof ForLoopBlock) {
18922
19120
  ingestForBlock(unit, node);
18923
19121
  } else if (node instanceof LetDeclaration) {
19122
+ ingestLetDeclaration(unit, node);
18924
19123
  } else {
18925
19124
  throw new Error(`Unsupported template node: ${node.constructor.name}`);
18926
19125
  }
@@ -19093,7 +19292,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19093
19292
  return templateOp;
19094
19293
  }
19095
19294
  function ingestDeferBlock(unit, deferBlock) {
19096
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
19295
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
19097
19296
  let ownResolverFn = null;
19098
19297
  if (unit.job.deferMeta.mode === 0) {
19099
19298
  if (!unit.job.deferMeta.blocks.has(deferBlock)) {
@@ -19103,8 +19302,8 @@ function ingestDeferBlock(unit, deferBlock) {
19103
19302
  }
19104
19303
  const main = ingestDeferView(unit, "", deferBlock.i18n, deferBlock.children, deferBlock.sourceSpan);
19105
19304
  const loading = ingestDeferView(unit, "Loading", (_b2 = deferBlock.loading) == null ? void 0 : _b2.i18n, (_c2 = deferBlock.loading) == null ? void 0 : _c2.children, (_d2 = deferBlock.loading) == null ? void 0 : _d2.sourceSpan);
19106
- const placeholder = ingestDeferView(unit, "Placeholder", (_e2 = deferBlock.placeholder) == null ? void 0 : _e2.i18n, (_f2 = deferBlock.placeholder) == null ? void 0 : _f2.children, (_g = deferBlock.placeholder) == null ? void 0 : _g.sourceSpan);
19107
- const error = ingestDeferView(unit, "Error", (_h = deferBlock.error) == null ? void 0 : _h.i18n, (_i = deferBlock.error) == null ? void 0 : _i.children, (_j = deferBlock.error) == null ? void 0 : _j.sourceSpan);
19305
+ const placeholder = ingestDeferView(unit, "Placeholder", (_e2 = deferBlock.placeholder) == null ? void 0 : _e2.i18n, (_f2 = deferBlock.placeholder) == null ? void 0 : _f2.children, (_g2 = deferBlock.placeholder) == null ? void 0 : _g2.sourceSpan);
19306
+ const error = ingestDeferView(unit, "Error", (_h2 = deferBlock.error) == null ? void 0 : _h2.i18n, (_i = deferBlock.error) == null ? void 0 : _i.children, (_j = deferBlock.error) == null ? void 0 : _j.sourceSpan);
19108
19307
  const deferXref = unit.job.allocateXrefId();
19109
19308
  const deferOp = createDeferOp(deferXref, main.xref, main.handle, ownResolverFn, unit.job.allDeferrableDepsFn, deferBlock.sourceSpan);
19110
19309
  deferOp.placeholderView = (_k = placeholder == null ? void 0 : placeholder.xref) != null ? _k : null;
@@ -19267,6 +19466,11 @@ function getComputedForLoopVariableExpression(variable2, indexName, countName) {
19267
19466
  throw new Error(`AssertionError: unknown @for loop variable ${variable2.value}`);
19268
19467
  }
19269
19468
  }
19469
+ function ingestLetDeclaration(unit, node) {
19470
+ const target = unit.job.allocateXrefId();
19471
+ unit.create.push(createDeclareLetOp(target, node.name, node.sourceSpan));
19472
+ unit.update.push(createStoreLetOp(target, node.name, convertAst(node.value, unit.job, node.valueSpan), node.sourceSpan));
19473
+ }
19270
19474
  function convertAst(ast, job, baseSourceSpan) {
19271
19475
  if (ast instanceof ASTWithSource) {
19272
19476
  return convertAst(ast.ast, job, baseSourceSpan);
@@ -22733,7 +22937,7 @@ function convertDirectiveFacadeToMetadata(facade) {
22733
22937
  });
22734
22938
  }
22735
22939
  function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
22736
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i;
22940
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
22737
22941
  return {
22738
22942
  name: declaration.type.name,
22739
22943
  type: wrapReference(declaration.type),
@@ -22747,11 +22951,11 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
22747
22951
  providers: declaration.providers !== void 0 ? new WrappedNodeExpr(declaration.providers) : null,
22748
22952
  exportAs: (_e2 = declaration.exportAs) != null ? _e2 : null,
22749
22953
  usesInheritance: (_f2 = declaration.usesInheritance) != null ? _f2 : false,
22750
- lifecycle: { usesOnChanges: (_g = declaration.usesOnChanges) != null ? _g : false },
22954
+ lifecycle: { usesOnChanges: (_g2 = declaration.usesOnChanges) != null ? _g2 : false },
22751
22955
  deps: null,
22752
22956
  typeArgumentCount: 0,
22753
22957
  fullInheritance: false,
22754
- isStandalone: (_h = declaration.isStandalone) != null ? _h : false,
22958
+ isStandalone: (_h2 = declaration.isStandalone) != null ? _h2 : false,
22755
22959
  isSignal: (_i = declaration.isSignal) != null ? _i : false,
22756
22960
  hostDirectives: convertHostDirectivesToMetadata(declaration)
22757
22961
  };
@@ -23053,7 +23257,7 @@ function publishFacade(global) {
23053
23257
  }
23054
23258
 
23055
23259
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
23056
- var VERSION2 = new Version("18.1.0-next.1");
23260
+ var VERSION2 = new Version("18.1.0-next.3");
23057
23261
 
23058
23262
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
23059
23263
  var _VisitorMode;
@@ -24556,6 +24760,13 @@ function generateErrorMessage(path2, errors) {
24556
24760
  }
24557
24761
  // Annotate the CommonJS export names for ESM import in node:
24558
24762
  0 && (module.exports = {});
24763
+ /*!
24764
+ * @license
24765
+ * Copyright Google LLC All Rights Reserved.
24766
+ *
24767
+ * Use of this source code is governed by an MIT-style license that can be
24768
+ * found in the LICENSE file at https://angular.io/license
24769
+ */
24559
24770
  /**
24560
24771
  *
24561
24772
  * @license