@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
@@ -2805,6 +2805,15 @@ var Identifiers = _Identifiers;
2805
2805
  (() => {
2806
2806
  _Identifiers.twoWayListener = { name: "\u0275\u0275twoWayListener", moduleName: CORE };
2807
2807
  })();
2808
+ (() => {
2809
+ _Identifiers.declareLet = { name: "\u0275\u0275declareLet", moduleName: CORE };
2810
+ })();
2811
+ (() => {
2812
+ _Identifiers.storeLet = { name: "\u0275\u0275storeLet", moduleName: CORE };
2813
+ })();
2814
+ (() => {
2815
+ _Identifiers.readContextLet = { name: "\u0275\u0275readContextLet", moduleName: CORE };
2816
+ })();
2808
2817
  (() => {
2809
2818
  _Identifiers.NgOnChangesFeature = { name: "\u0275\u0275NgOnChangesFeature", moduleName: CORE };
2810
2819
  })();
@@ -6368,16 +6377,18 @@ var OpKind;
6368
6377
  OpKind2[OpKind2["Repeater"] = 35] = "Repeater";
6369
6378
  OpKind2[OpKind2["TwoWayProperty"] = 36] = "TwoWayProperty";
6370
6379
  OpKind2[OpKind2["TwoWayListener"] = 37] = "TwoWayListener";
6371
- OpKind2[OpKind2["I18nStart"] = 38] = "I18nStart";
6372
- OpKind2[OpKind2["I18n"] = 39] = "I18n";
6373
- OpKind2[OpKind2["I18nEnd"] = 40] = "I18nEnd";
6374
- OpKind2[OpKind2["I18nExpression"] = 41] = "I18nExpression";
6375
- OpKind2[OpKind2["I18nApply"] = 42] = "I18nApply";
6376
- OpKind2[OpKind2["IcuStart"] = 43] = "IcuStart";
6377
- OpKind2[OpKind2["IcuEnd"] = 44] = "IcuEnd";
6378
- OpKind2[OpKind2["IcuPlaceholder"] = 45] = "IcuPlaceholder";
6379
- OpKind2[OpKind2["I18nContext"] = 46] = "I18nContext";
6380
- OpKind2[OpKind2["I18nAttributes"] = 47] = "I18nAttributes";
6380
+ OpKind2[OpKind2["DeclareLet"] = 38] = "DeclareLet";
6381
+ OpKind2[OpKind2["StoreLet"] = 39] = "StoreLet";
6382
+ OpKind2[OpKind2["I18nStart"] = 40] = "I18nStart";
6383
+ OpKind2[OpKind2["I18n"] = 41] = "I18n";
6384
+ OpKind2[OpKind2["I18nEnd"] = 42] = "I18nEnd";
6385
+ OpKind2[OpKind2["I18nExpression"] = 43] = "I18nExpression";
6386
+ OpKind2[OpKind2["I18nApply"] = 44] = "I18nApply";
6387
+ OpKind2[OpKind2["IcuStart"] = 45] = "IcuStart";
6388
+ OpKind2[OpKind2["IcuEnd"] = 46] = "IcuEnd";
6389
+ OpKind2[OpKind2["IcuPlaceholder"] = 47] = "IcuPlaceholder";
6390
+ OpKind2[OpKind2["I18nContext"] = 48] = "I18nContext";
6391
+ OpKind2[OpKind2["I18nAttributes"] = 49] = "I18nAttributes";
6381
6392
  })(OpKind || (OpKind = {}));
6382
6393
  var ExpressionKind;
6383
6394
  (function(ExpressionKind2) {
@@ -6387,24 +6398,26 @@ var ExpressionKind;
6387
6398
  ExpressionKind2[ExpressionKind2["ReadVariable"] = 3] = "ReadVariable";
6388
6399
  ExpressionKind2[ExpressionKind2["NextContext"] = 4] = "NextContext";
6389
6400
  ExpressionKind2[ExpressionKind2["Reference"] = 5] = "Reference";
6390
- ExpressionKind2[ExpressionKind2["GetCurrentView"] = 6] = "GetCurrentView";
6391
- ExpressionKind2[ExpressionKind2["RestoreView"] = 7] = "RestoreView";
6392
- ExpressionKind2[ExpressionKind2["ResetView"] = 8] = "ResetView";
6393
- ExpressionKind2[ExpressionKind2["PureFunctionExpr"] = 9] = "PureFunctionExpr";
6394
- ExpressionKind2[ExpressionKind2["PureFunctionParameterExpr"] = 10] = "PureFunctionParameterExpr";
6395
- ExpressionKind2[ExpressionKind2["PipeBinding"] = 11] = "PipeBinding";
6396
- ExpressionKind2[ExpressionKind2["PipeBindingVariadic"] = 12] = "PipeBindingVariadic";
6397
- ExpressionKind2[ExpressionKind2["SafePropertyRead"] = 13] = "SafePropertyRead";
6398
- ExpressionKind2[ExpressionKind2["SafeKeyedRead"] = 14] = "SafeKeyedRead";
6399
- ExpressionKind2[ExpressionKind2["SafeInvokeFunction"] = 15] = "SafeInvokeFunction";
6400
- ExpressionKind2[ExpressionKind2["SafeTernaryExpr"] = 16] = "SafeTernaryExpr";
6401
- ExpressionKind2[ExpressionKind2["EmptyExpr"] = 17] = "EmptyExpr";
6402
- ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 18] = "AssignTemporaryExpr";
6403
- ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 19] = "ReadTemporaryExpr";
6404
- ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 20] = "SlotLiteralExpr";
6405
- ExpressionKind2[ExpressionKind2["ConditionalCase"] = 21] = "ConditionalCase";
6406
- ExpressionKind2[ExpressionKind2["ConstCollected"] = 22] = "ConstCollected";
6407
- ExpressionKind2[ExpressionKind2["TwoWayBindingSet"] = 23] = "TwoWayBindingSet";
6401
+ ExpressionKind2[ExpressionKind2["StoreLet"] = 6] = "StoreLet";
6402
+ ExpressionKind2[ExpressionKind2["ContextLetReference"] = 7] = "ContextLetReference";
6403
+ ExpressionKind2[ExpressionKind2["GetCurrentView"] = 8] = "GetCurrentView";
6404
+ ExpressionKind2[ExpressionKind2["RestoreView"] = 9] = "RestoreView";
6405
+ ExpressionKind2[ExpressionKind2["ResetView"] = 10] = "ResetView";
6406
+ ExpressionKind2[ExpressionKind2["PureFunctionExpr"] = 11] = "PureFunctionExpr";
6407
+ ExpressionKind2[ExpressionKind2["PureFunctionParameterExpr"] = 12] = "PureFunctionParameterExpr";
6408
+ ExpressionKind2[ExpressionKind2["PipeBinding"] = 13] = "PipeBinding";
6409
+ ExpressionKind2[ExpressionKind2["PipeBindingVariadic"] = 14] = "PipeBindingVariadic";
6410
+ ExpressionKind2[ExpressionKind2["SafePropertyRead"] = 15] = "SafePropertyRead";
6411
+ ExpressionKind2[ExpressionKind2["SafeKeyedRead"] = 16] = "SafeKeyedRead";
6412
+ ExpressionKind2[ExpressionKind2["SafeInvokeFunction"] = 17] = "SafeInvokeFunction";
6413
+ ExpressionKind2[ExpressionKind2["SafeTernaryExpr"] = 18] = "SafeTernaryExpr";
6414
+ ExpressionKind2[ExpressionKind2["EmptyExpr"] = 19] = "EmptyExpr";
6415
+ ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 20] = "AssignTemporaryExpr";
6416
+ ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 21] = "ReadTemporaryExpr";
6417
+ ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 22] = "SlotLiteralExpr";
6418
+ ExpressionKind2[ExpressionKind2["ConditionalCase"] = 23] = "ConditionalCase";
6419
+ ExpressionKind2[ExpressionKind2["ConstCollected"] = 24] = "ConstCollected";
6420
+ ExpressionKind2[ExpressionKind2["TwoWayBindingSet"] = 25] = "TwoWayBindingSet";
6408
6421
  })(ExpressionKind || (ExpressionKind = {}));
6409
6422
  var VariableFlags;
6410
6423
  (function(VariableFlags2) {
@@ -6499,8 +6512,8 @@ var TRAIT_CONSUMES_VARS = {
6499
6512
  function hasConsumesSlotTrait(op) {
6500
6513
  return op[ConsumesSlot] === true;
6501
6514
  }
6502
- function hasDependsOnSlotContextTrait(op) {
6503
- return op[DependsOnSlotContext] === true;
6515
+ function hasDependsOnSlotContextTrait(value) {
6516
+ return value[DependsOnSlotContext] === true;
6504
6517
  }
6505
6518
  function hasConsumesVarsTrait(value) {
6506
6519
  return value[ConsumesVarsTrait] === true;
@@ -6710,6 +6723,15 @@ function createI18nApplyOp(owner, handle, sourceSpan) {
6710
6723
  sourceSpan
6711
6724
  }, NEW_OP);
6712
6725
  }
6726
+ function createStoreLetOp(target, declaredName, value, sourceSpan) {
6727
+ return __spreadValues(__spreadValues(__spreadValues({
6728
+ kind: OpKind.StoreLet,
6729
+ target,
6730
+ declaredName,
6731
+ value,
6732
+ sourceSpan
6733
+ }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
6734
+ }
6713
6735
 
6714
6736
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/expression.mjs
6715
6737
  var _a;
@@ -6718,6 +6740,8 @@ var _c;
6718
6740
  var _d;
6719
6741
  var _e;
6720
6742
  var _f;
6743
+ var _g;
6744
+ var _h;
6721
6745
  function isIrExpression(expr) {
6722
6746
  return expr instanceof ExpressionBase;
6723
6747
  }
@@ -6768,6 +6792,56 @@ var ReferenceExpr = class extends ExpressionBase {
6768
6792
  return new ReferenceExpr(this.target, this.targetSlot, this.offset);
6769
6793
  }
6770
6794
  };
6795
+ var _StoreLetExpr = class extends ExpressionBase {
6796
+ constructor(target, value, sourceSpan) {
6797
+ super();
6798
+ this.target = target;
6799
+ this.value = value;
6800
+ this.sourceSpan = sourceSpan;
6801
+ this.kind = ExpressionKind.StoreLet;
6802
+ this[_a] = true;
6803
+ this[_b] = true;
6804
+ }
6805
+ visitExpression() {
6806
+ }
6807
+ isEquivalent(e) {
6808
+ return e instanceof _StoreLetExpr && e.target === this.target && e.value.isEquivalent(this.value);
6809
+ }
6810
+ isConstant() {
6811
+ return false;
6812
+ }
6813
+ transformInternalExpressions(transform2, flags) {
6814
+ this.value = transformExpressionsInExpression(this.value, transform2, flags);
6815
+ }
6816
+ clone() {
6817
+ return new _StoreLetExpr(this.target, this.value, this.sourceSpan);
6818
+ }
6819
+ };
6820
+ var StoreLetExpr = _StoreLetExpr;
6821
+ (() => {
6822
+ _a = ConsumesVarsTrait, _b = DependsOnSlotContext;
6823
+ })();
6824
+ var ContextLetReferenceExpr = class extends ExpressionBase {
6825
+ constructor(target, targetSlot) {
6826
+ super();
6827
+ this.target = target;
6828
+ this.targetSlot = targetSlot;
6829
+ this.kind = ExpressionKind.ContextLetReference;
6830
+ }
6831
+ visitExpression() {
6832
+ }
6833
+ isEquivalent(e) {
6834
+ return e instanceof ContextLetReferenceExpr && e.target === this.target;
6835
+ }
6836
+ isConstant() {
6837
+ return false;
6838
+ }
6839
+ transformInternalExpressions() {
6840
+ }
6841
+ clone() {
6842
+ return new ContextLetReferenceExpr(this.target, this.targetSlot);
6843
+ }
6844
+ };
6771
6845
  var ContextExpr = class extends ExpressionBase {
6772
6846
  constructor(view) {
6773
6847
  super();
@@ -6956,8 +7030,8 @@ var _PureFunctionExpr = class extends ExpressionBase {
6956
7030
  constructor(expression, args) {
6957
7031
  super();
6958
7032
  this.kind = ExpressionKind.PureFunctionExpr;
6959
- this[_a] = true;
6960
- this[_b] = true;
7033
+ this[_c] = true;
7034
+ this[_d] = true;
6961
7035
  this.varOffset = null;
6962
7036
  this.fn = null;
6963
7037
  this.body = expression;
@@ -6999,7 +7073,7 @@ var _PureFunctionExpr = class extends ExpressionBase {
6999
7073
  };
7000
7074
  var PureFunctionExpr = _PureFunctionExpr;
7001
7075
  (() => {
7002
- _a = ConsumesVarsTrait, _b = UsesVarOffset;
7076
+ _c = ConsumesVarsTrait, _d = UsesVarOffset;
7003
7077
  })();
7004
7078
  var PureFunctionParameterExpr = class extends ExpressionBase {
7005
7079
  constructor(index) {
@@ -7029,8 +7103,8 @@ var _PipeBindingExpr = class extends ExpressionBase {
7029
7103
  this.name = name;
7030
7104
  this.args = args;
7031
7105
  this.kind = ExpressionKind.PipeBinding;
7032
- this[_c] = true;
7033
- this[_d] = true;
7106
+ this[_e] = true;
7107
+ this[_f] = true;
7034
7108
  this.varOffset = null;
7035
7109
  }
7036
7110
  visitExpression(visitor, context) {
@@ -7057,7 +7131,7 @@ var _PipeBindingExpr = class extends ExpressionBase {
7057
7131
  };
7058
7132
  var PipeBindingExpr = _PipeBindingExpr;
7059
7133
  (() => {
7060
- _c = ConsumesVarsTrait, _d = UsesVarOffset;
7134
+ _e = ConsumesVarsTrait, _f = UsesVarOffset;
7061
7135
  })();
7062
7136
  var _PipeBindingVariadicExpr = class extends ExpressionBase {
7063
7137
  constructor(target, targetSlot, name, args, numArgs) {
@@ -7068,8 +7142,8 @@ var _PipeBindingVariadicExpr = class extends ExpressionBase {
7068
7142
  this.args = args;
7069
7143
  this.numArgs = numArgs;
7070
7144
  this.kind = ExpressionKind.PipeBindingVariadic;
7071
- this[_e] = true;
7072
- this[_f] = true;
7145
+ this[_g] = true;
7146
+ this[_h] = true;
7073
7147
  this.varOffset = null;
7074
7148
  }
7075
7149
  visitExpression(visitor, context) {
@@ -7092,7 +7166,7 @@ var _PipeBindingVariadicExpr = class extends ExpressionBase {
7092
7166
  };
7093
7167
  var PipeBindingVariadicExpr = _PipeBindingVariadicExpr;
7094
7168
  (() => {
7095
- _e = ConsumesVarsTrait, _f = UsesVarOffset;
7169
+ _g = ConsumesVarsTrait, _h = UsesVarOffset;
7096
7170
  })();
7097
7171
  var SafePropertyReadExpr = class extends ExpressionBase {
7098
7172
  constructor(receiver, name) {
@@ -7451,6 +7525,9 @@ function transformExpressionsInOp(op, transform2, flags) {
7451
7525
  case OpKind.DeferWhen:
7452
7526
  op.expr = transformExpressionsInExpression(op.expr, transform2, flags);
7453
7527
  break;
7528
+ case OpKind.StoreLet:
7529
+ op.value = transformExpressionsInExpression(op.value, transform2, flags);
7530
+ break;
7454
7531
  case OpKind.Advance:
7455
7532
  case OpKind.Container:
7456
7533
  case OpKind.ContainerEnd:
@@ -7476,6 +7553,7 @@ function transformExpressionsInOp(op, transform2, flags) {
7476
7553
  case OpKind.Text:
7477
7554
  case OpKind.I18nAttributes:
7478
7555
  case OpKind.IcuPlaceholder:
7556
+ case OpKind.DeclareLet:
7479
7557
  break;
7480
7558
  default:
7481
7559
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -7991,6 +8069,15 @@ function createDeferOnOp(defer2, trigger, prefetch, sourceSpan) {
7991
8069
  sourceSpan
7992
8070
  }, NEW_OP);
7993
8071
  }
8072
+ function createDeclareLetOp(xref, declaredName, sourceSpan) {
8073
+ return __spreadValues(__spreadValues({
8074
+ kind: OpKind.DeclareLet,
8075
+ xref,
8076
+ declaredName,
8077
+ sourceSpan,
8078
+ handle: new SlotHandle()
8079
+ }, TRAIT_CONSUMES_SLOT), NEW_OP);
8080
+ }
7994
8081
  function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
7995
8082
  return __spreadValues({
7996
8083
  kind: OpKind.I18nMessage,
@@ -8536,7 +8623,8 @@ var CHAINABLE = /* @__PURE__ */ new Set([
8536
8623
  Identifiers.syntheticHostProperty,
8537
8624
  Identifiers.templateCreate,
8538
8625
  Identifiers.twoWayProperty,
8539
- Identifiers.twoWayListener
8626
+ Identifiers.twoWayListener,
8627
+ Identifiers.declareLet
8540
8628
  ]);
8541
8629
  function chain(job) {
8542
8630
  for (const unit of job.units) {
@@ -9440,18 +9528,29 @@ function generateAdvance(job) {
9440
9528
  }
9441
9529
  let slotContext = 0;
9442
9530
  for (const op of unit.update) {
9443
- if (!hasDependsOnSlotContextTrait(op)) {
9531
+ let consumer = null;
9532
+ if (hasDependsOnSlotContextTrait(op)) {
9533
+ consumer = op;
9534
+ } else {
9535
+ visitExpressionsInOp(op, (expr) => {
9536
+ if (consumer === null && hasDependsOnSlotContextTrait(expr)) {
9537
+ consumer = expr;
9538
+ }
9539
+ });
9540
+ }
9541
+ if (consumer === null) {
9444
9542
  continue;
9445
- } else if (!slotMap.has(op.target)) {
9446
- throw new Error(`AssertionError: reference to unknown slot for target ${op.target}`);
9447
9543
  }
9448
- const slot = slotMap.get(op.target);
9544
+ if (!slotMap.has(consumer.target)) {
9545
+ throw new Error(`AssertionError: reference to unknown slot for target ${consumer.target}`);
9546
+ }
9547
+ const slot = slotMap.get(consumer.target);
9449
9548
  if (slotContext !== slot) {
9450
9549
  const delta = slot - slotContext;
9451
9550
  if (delta < 0) {
9452
9551
  throw new Error(`AssertionError: slot counter should never need to move backwards`);
9453
9552
  }
9454
- OpList.insertBefore(createAdvanceOp(delta, op.sourceSpan), op);
9553
+ OpList.insertBefore(createAdvanceOp(delta, consumer.sourceSpan), op);
9455
9554
  slotContext = slot;
9456
9555
  }
9457
9556
  }
@@ -9506,12 +9605,11 @@ function recursivelyProcessView(view, parentScope) {
9506
9605
  break;
9507
9606
  case OpKind.Listener:
9508
9607
  case OpKind.TwoWayListener:
9509
- op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
9608
+ op.handlerOps.prepend(generateVariablesInScopeForView(view, scope, true));
9510
9609
  break;
9511
9610
  }
9512
9611
  }
9513
- const preambleOps = generateVariablesInScopeForView(view, scope);
9514
- view.update.prepend(preambleOps);
9612
+ view.update.prepend(generateVariablesInScopeForView(view, scope, false));
9515
9613
  }
9516
9614
  function getScopeForView(view, parent) {
9517
9615
  const scope = {
@@ -9524,6 +9622,7 @@ function getScopeForView(view, parent) {
9524
9622
  contextVariables: /* @__PURE__ */ new Map(),
9525
9623
  aliases: view.aliases,
9526
9624
  references: [],
9625
+ letDeclarations: [],
9527
9626
  parent
9528
9627
  };
9529
9628
  for (const identifier of view.contextVariables.keys()) {
@@ -9554,11 +9653,22 @@ function getScopeForView(view, parent) {
9554
9653
  });
9555
9654
  }
9556
9655
  break;
9656
+ case OpKind.DeclareLet:
9657
+ scope.letDeclarations.push({
9658
+ targetId: op.xref,
9659
+ targetSlot: op.handle,
9660
+ variable: {
9661
+ kind: SemanticVariableKind.Identifier,
9662
+ name: null,
9663
+ identifier: op.declaredName
9664
+ }
9665
+ });
9666
+ break;
9557
9667
  }
9558
9668
  }
9559
9669
  return scope;
9560
9670
  }
9561
- function generateVariablesInScopeForView(view, scope) {
9671
+ function generateVariablesInScopeForView(view, scope, isListener) {
9562
9672
  const newOps = [];
9563
9673
  if (scope.view !== view.xref) {
9564
9674
  newOps.push(createVariableOp(view.job.allocateXrefId(), scope.viewContextVariable, new NextContextExpr(), VariableFlags.None));
@@ -9575,8 +9685,13 @@ function generateVariablesInScopeForView(view, scope) {
9575
9685
  for (const ref of scope.references) {
9576
9686
  newOps.push(createVariableOp(view.job.allocateXrefId(), ref.variable, new ReferenceExpr(ref.targetId, ref.targetSlot, ref.offset), VariableFlags.None));
9577
9687
  }
9688
+ if (scope.view !== view.xref || isListener) {
9689
+ for (const decl of scope.letDeclarations) {
9690
+ newOps.push(createVariableOp(view.job.allocateXrefId(), decl.variable, new ContextLetReferenceExpr(decl.targetId, decl.targetSlot), VariableFlags.None));
9691
+ }
9692
+ }
9578
9693
  if (scope.parent !== null) {
9579
- newOps.push(...generateVariablesInScopeForView(view, scope.parent));
9694
+ newOps.push(...generateVariablesInScopeForView(view, scope.parent, false));
9580
9695
  }
9581
9696
  return newOps;
9582
9697
  }
@@ -10698,13 +10813,15 @@ var _ParseAST = class {
10698
10813
  const keyStart = this.inputIndex;
10699
10814
  const quoted = this.next.isString();
10700
10815
  const key = this.expectIdentifierOrKeywordOrString();
10701
- keys.push({ key, quoted });
10816
+ const literalMapKey = { key, quoted };
10817
+ keys.push(literalMapKey);
10702
10818
  if (quoted) {
10703
10819
  this.expectCharacter($COLON);
10704
10820
  values.push(this.parsePipe());
10705
10821
  } else if (this.consumeOptionalCharacter($COLON)) {
10706
10822
  values.push(this.parsePipe());
10707
10823
  } else {
10824
+ literalMapKey.isShorthandInitialized = true;
10708
10825
  const span = this.span(keyStart);
10709
10826
  const sourceSpan = this.sourceSpan(keyStart);
10710
10827
  values.push(new PropertyRead(span, sourceSpan, sourceSpan, new ImplicitReceiver(span, sourceSpan), key));
@@ -16383,6 +16500,7 @@ function mergeNextContextsInOps(ops) {
16383
16500
  break;
16384
16501
  case ExpressionKind.GetCurrentView:
16385
16502
  case ExpressionKind.Reference:
16503
+ case ExpressionKind.ContextLetReference:
16386
16504
  tryToMerge = false;
16387
16505
  break;
16388
16506
  }
@@ -17002,6 +17120,15 @@ function repeater(collection, sourceSpan) {
17002
17120
  function deferWhen(prefetch, expr, sourceSpan) {
17003
17121
  return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
17004
17122
  }
17123
+ function declareLet(slot, sourceSpan) {
17124
+ return call(Identifiers.declareLet, [literal(slot)], sourceSpan);
17125
+ }
17126
+ function storeLet(value, sourceSpan) {
17127
+ return importExpr(Identifiers.storeLet).callFn([value], sourceSpan);
17128
+ }
17129
+ function readContextLet(slot) {
17130
+ return importExpr(Identifiers.readContextLet).callFn([literal(slot)]);
17131
+ }
17005
17132
  function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
17006
17133
  const args = [literal(slot), literal(constIndex)];
17007
17134
  if (subTemplateIndex) {
@@ -17316,7 +17443,7 @@ function reify(job) {
17316
17443
  }
17317
17444
  }
17318
17445
  function reifyCreateOperations(unit, ops) {
17319
- var _a2, _b2, _c2, _d2, _e2, _f2, _g;
17446
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
17320
17447
  for (const op of ops) {
17321
17448
  transformExpressionsInOp(op, reifyIrExpression, VisitorContextFlag.None);
17322
17449
  switch (op.kind) {
@@ -17375,6 +17502,9 @@ function reifyCreateOperations(unit, ops) {
17375
17502
  case OpKind.Pipe:
17376
17503
  OpList.replace(op, pipe(op.handle.slot, op.name));
17377
17504
  break;
17505
+ case OpKind.DeclareLet:
17506
+ OpList.replace(op, declareLet(op.handle.slot, op.sourceSpan));
17507
+ break;
17378
17508
  case OpKind.Listener:
17379
17509
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17380
17510
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
@@ -17421,7 +17551,7 @@ function reifyCreateOperations(unit, ops) {
17421
17551
  case DeferTriggerKind.Interaction:
17422
17552
  case DeferTriggerKind.Hover:
17423
17553
  case DeferTriggerKind.Viewport:
17424
- if (((_g = op.trigger.targetSlot) == null ? void 0 : _g.slot) == null || op.trigger.targetSlotViewSteps === null) {
17554
+ if (((_g2 = op.trigger.targetSlot) == null ? void 0 : _g2.slot) == null || op.trigger.targetSlotViewSteps === null) {
17425
17555
  throw new Error(`Slot or view steps not set in trigger reification for trigger kind ${op.trigger.kind}`);
17426
17556
  }
17427
17557
  args = [op.trigger.targetSlot.slot];
@@ -17582,6 +17712,8 @@ function reifyUpdateOperations(_unit, ops) {
17582
17712
  case OpKind.DeferWhen:
17583
17713
  OpList.replace(op, deferWhen(op.prefetch, op.expr, op.sourceSpan));
17584
17714
  break;
17715
+ case OpKind.StoreLet:
17716
+ throw new Error(`AssertionError: unexpected storeLet ${op.declaredName}`);
17585
17717
  case OpKind.Statement:
17586
17718
  break;
17587
17719
  default:
@@ -17639,6 +17771,10 @@ function reifyIrExpression(expr) {
17639
17771
  return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
17640
17772
  case ExpressionKind.SlotLiteralExpr:
17641
17773
  return literal(expr.slot.slot);
17774
+ case ExpressionKind.ContextLetReference:
17775
+ return readContextLet(expr.targetSlot.slot);
17776
+ case ExpressionKind.StoreLet:
17777
+ return storeLet(expr.value, expr.sourceSpan);
17642
17778
  default:
17643
17779
  throw new Error(`AssertionError: Unsupported reification of ir.Expression kind: ${ExpressionKind[expr.kind]}`);
17644
17780
  }
@@ -18191,7 +18327,7 @@ function saveAndRestoreView(job) {
18191
18327
  if (!needsRestoreView) {
18192
18328
  for (const handlerOp of op.handlerOps) {
18193
18329
  visitExpressionsInOp(handlerOp, (expr) => {
18194
- if (expr instanceof ReferenceExpr) {
18330
+ if (expr instanceof ReferenceExpr || expr instanceof ContextLetReferenceExpr) {
18195
18331
  needsRestoreView = true;
18196
18332
  }
18197
18333
  });
@@ -18516,6 +18652,7 @@ function varsUsedByOp(op) {
18516
18652
  case OpKind.I18nExpression:
18517
18653
  case OpKind.Conditional:
18518
18654
  case OpKind.DeferWhen:
18655
+ case OpKind.StoreLet:
18519
18656
  return 1;
18520
18657
  case OpKind.RepeaterCreate:
18521
18658
  return op.emptyView ? 1 : 0;
@@ -18531,6 +18668,8 @@ function varsUsedByIrExpression(expr) {
18531
18668
  return 1 + expr.args.length;
18532
18669
  case ExpressionKind.PipeBindingVariadic:
18533
18670
  return 1 + expr.numArgs;
18671
+ case ExpressionKind.StoreLet:
18672
+ return 1;
18534
18673
  default:
18535
18674
  throw new Error(`AssertionError: unhandled ConsumesVarsTrait expression ${expr.constructor.name}`);
18536
18675
  }
@@ -18682,7 +18821,10 @@ function fencesForIrExpression(expr) {
18682
18821
  return Fence.ViewContextRead | Fence.ViewContextWrite;
18683
18822
  case ExpressionKind.RestoreView:
18684
18823
  return Fence.ViewContextRead | Fence.ViewContextWrite | Fence.SideEffectful;
18824
+ case ExpressionKind.StoreLet:
18825
+ return Fence.SideEffectful;
18685
18826
  case ExpressionKind.Reference:
18827
+ case ExpressionKind.ContextLetReference:
18686
18828
  return Fence.ViewContextRead;
18687
18829
  default:
18688
18830
  return Fence.None;
@@ -18824,6 +18966,59 @@ function wrapI18nIcus(job) {
18824
18966
  }
18825
18967
  }
18826
18968
 
18969
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/store_let_optimization.mjs
18970
+ function optimizeStoreLet(job) {
18971
+ const letUsedExternally = /* @__PURE__ */ new Set();
18972
+ for (const unit of job.units) {
18973
+ for (const op of unit.ops()) {
18974
+ visitExpressionsInOp(op, (expr) => {
18975
+ if (expr instanceof ContextLetReferenceExpr) {
18976
+ letUsedExternally.add(expr.target);
18977
+ }
18978
+ });
18979
+ }
18980
+ }
18981
+ for (const unit of job.units) {
18982
+ for (const op of unit.update) {
18983
+ transformExpressionsInOp(op, (expression) => expression instanceof StoreLetExpr && !letUsedExternally.has(expression.target) ? expression.value : expression, VisitorContextFlag.None);
18984
+ }
18985
+ }
18986
+ }
18987
+
18988
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/remove_illegal_let_references.mjs
18989
+ function removeIllegalLetReferences(job) {
18990
+ for (const unit of job.units) {
18991
+ for (const op of unit.update) {
18992
+ if (op.kind !== OpKind.Variable || op.variable.kind !== SemanticVariableKind.Identifier || !(op.initializer instanceof StoreLetExpr)) {
18993
+ continue;
18994
+ }
18995
+ const name = op.variable.identifier;
18996
+ let current = op;
18997
+ while (current && current.kind !== OpKind.ListEnd) {
18998
+ transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal(void 0) : expr, VisitorContextFlag.None);
18999
+ current = current.prev;
19000
+ }
19001
+ }
19002
+ }
19003
+ }
19004
+
19005
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/generate_local_let_references.mjs
19006
+ function generateLocalLetReferences(job) {
19007
+ for (const unit of job.units) {
19008
+ for (const op of unit.update) {
19009
+ if (op.kind !== OpKind.StoreLet) {
19010
+ continue;
19011
+ }
19012
+ const variable2 = {
19013
+ kind: SemanticVariableKind.Identifier,
19014
+ name: null,
19015
+ identifier: op.declaredName
19016
+ };
19017
+ OpList.replace(op, createVariableOp(job.allocateXrefId(), variable2, new StoreLetExpr(op.target, op.value, op.sourceSpan), VariableFlags.None));
19018
+ }
19019
+ }
19020
+ }
19021
+
18827
19022
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/emit.mjs
18828
19023
  var phases = [
18829
19024
  { kind: CompilationJobKind.Tmpl, fn: removeContentSelectors },
@@ -18851,11 +19046,13 @@ var phases = [
18851
19046
  { kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
18852
19047
  { kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
18853
19048
  { kind: CompilationJobKind.Tmpl, fn: generateProjectionDefs },
19049
+ { kind: CompilationJobKind.Tmpl, fn: generateLocalLetReferences },
18854
19050
  { kind: CompilationJobKind.Tmpl, fn: generateVariables },
18855
19051
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
18856
19052
  { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
18857
19053
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
18858
19054
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
19055
+ { kind: CompilationJobKind.Tmpl, fn: removeIllegalLetReferences },
18859
19056
  { kind: CompilationJobKind.Both, fn: resolveNames },
18860
19057
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
18861
19058
  { kind: CompilationJobKind.Tmpl, fn: transformTwoWayBindingSet },
@@ -18867,6 +19064,7 @@ var phases = [
18867
19064
  { kind: CompilationJobKind.Both, fn: expandSafeReads },
18868
19065
  { kind: CompilationJobKind.Both, fn: generateTemporaryVariables },
18869
19066
  { kind: CompilationJobKind.Both, fn: optimizeVariables },
19067
+ { kind: CompilationJobKind.Both, fn: optimizeStoreLet },
18870
19068
  { kind: CompilationJobKind.Tmpl, fn: allocateSlots },
18871
19069
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
18872
19070
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
@@ -19083,6 +19281,7 @@ function ingestNodes(unit, template2) {
19083
19281
  } else if (node instanceof ForLoopBlock) {
19084
19282
  ingestForBlock(unit, node);
19085
19283
  } else if (node instanceof LetDeclaration) {
19284
+ ingestLetDeclaration(unit, node);
19086
19285
  } else {
19087
19286
  throw new Error(`Unsupported template node: ${node.constructor.name}`);
19088
19287
  }
@@ -19255,7 +19454,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19255
19454
  return templateOp;
19256
19455
  }
19257
19456
  function ingestDeferBlock(unit, deferBlock) {
19258
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
19457
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
19259
19458
  let ownResolverFn = null;
19260
19459
  if (unit.job.deferMeta.mode === 0) {
19261
19460
  if (!unit.job.deferMeta.blocks.has(deferBlock)) {
@@ -19265,8 +19464,8 @@ function ingestDeferBlock(unit, deferBlock) {
19265
19464
  }
19266
19465
  const main = ingestDeferView(unit, "", deferBlock.i18n, deferBlock.children, deferBlock.sourceSpan);
19267
19466
  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);
19268
- 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);
19269
- 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);
19467
+ 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);
19468
+ 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);
19270
19469
  const deferXref = unit.job.allocateXrefId();
19271
19470
  const deferOp = createDeferOp(deferXref, main.xref, main.handle, ownResolverFn, unit.job.allDeferrableDepsFn, deferBlock.sourceSpan);
19272
19471
  deferOp.placeholderView = (_k = placeholder == null ? void 0 : placeholder.xref) != null ? _k : null;
@@ -19429,6 +19628,11 @@ function getComputedForLoopVariableExpression(variable2, indexName, countName) {
19429
19628
  throw new Error(`AssertionError: unknown @for loop variable ${variable2.value}`);
19430
19629
  }
19431
19630
  }
19631
+ function ingestLetDeclaration(unit, node) {
19632
+ const target = unit.job.allocateXrefId();
19633
+ unit.create.push(createDeclareLetOp(target, node.name, node.sourceSpan));
19634
+ unit.update.push(createStoreLetOp(target, node.name, convertAst(node.value, unit.job, node.valueSpan), node.sourceSpan));
19635
+ }
19432
19636
  function convertAst(ast, job, baseSourceSpan) {
19433
19637
  if (ast instanceof ASTWithSource) {
19434
19638
  return convertAst(ast.ast, job, baseSourceSpan);
@@ -22895,7 +23099,7 @@ function convertDirectiveFacadeToMetadata(facade) {
22895
23099
  });
22896
23100
  }
22897
23101
  function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
22898
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i;
23102
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
22899
23103
  return {
22900
23104
  name: declaration.type.name,
22901
23105
  type: wrapReference(declaration.type),
@@ -22909,11 +23113,11 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
22909
23113
  providers: declaration.providers !== void 0 ? new WrappedNodeExpr(declaration.providers) : null,
22910
23114
  exportAs: (_e2 = declaration.exportAs) != null ? _e2 : null,
22911
23115
  usesInheritance: (_f2 = declaration.usesInheritance) != null ? _f2 : false,
22912
- lifecycle: { usesOnChanges: (_g = declaration.usesOnChanges) != null ? _g : false },
23116
+ lifecycle: { usesOnChanges: (_g2 = declaration.usesOnChanges) != null ? _g2 : false },
22913
23117
  deps: null,
22914
23118
  typeArgumentCount: 0,
22915
23119
  fullInheritance: false,
22916
- isStandalone: (_h = declaration.isStandalone) != null ? _h : false,
23120
+ isStandalone: (_h2 = declaration.isStandalone) != null ? _h2 : false,
22917
23121
  isSignal: (_i = declaration.isSignal) != null ? _i : false,
22918
23122
  hostDirectives: convertHostDirectivesToMetadata(declaration)
22919
23123
  };
@@ -23215,7 +23419,7 @@ function publishFacade(global) {
23215
23419
  }
23216
23420
 
23217
23421
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
23218
- var VERSION2 = new Version("18.1.0-next.1");
23422
+ var VERSION2 = new Version("18.1.0-next.3");
23219
23423
 
23220
23424
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
23221
23425
  var _VisitorMode;