@angular/core 17.0.7 → 17.0.8

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 (38) hide show
  1. package/esm2022/src/application/application_ref.mjs +4 -8
  2. package/esm2022/src/application/create_application.mjs +2 -2
  3. package/esm2022/src/change_detection/flags.mjs +16 -0
  4. package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +164 -0
  5. package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +13 -0
  6. package/esm2022/src/core.mjs +2 -2
  7. package/esm2022/src/core_private_export.mjs +4 -2
  8. package/esm2022/src/event_emitter.mjs +1 -2
  9. package/esm2022/src/pending_tasks.mjs +57 -0
  10. package/esm2022/src/platform/platform_ref.mjs +2 -2
  11. package/esm2022/src/render3/after_render_hooks.mjs +2 -2
  12. package/esm2022/src/render3/component_ref.mjs +13 -9
  13. package/esm2022/src/render3/instructions/mark_view_dirty.mjs +3 -2
  14. package/esm2022/src/render3/instructions/shared.mjs +3 -2
  15. package/esm2022/src/render3/interfaces/view.mjs +1 -1
  16. package/esm2022/src/render3/util/view_utils.mjs +18 -5
  17. package/esm2022/src/render3/view_ref.mjs +2 -1
  18. package/esm2022/src/version.mjs +6 -5
  19. package/esm2022/src/zone/ng_zone.mjs +1 -61
  20. package/esm2022/testing/src/logger.mjs +3 -3
  21. package/fesm2022/core.mjs +172 -136
  22. package/fesm2022/core.mjs.map +1 -1
  23. package/fesm2022/primitives/signals.mjs +1 -1
  24. package/fesm2022/rxjs-interop.mjs +1 -1
  25. package/fesm2022/testing.mjs +1 -1
  26. package/index.d.ts +38 -22
  27. package/package.json +1 -1
  28. package/primitives/signals/index.d.ts +1 -1
  29. package/rxjs-interop/index.d.ts +1 -1
  30. package/schematics/migrations/block-template-entities/bundle.js +268 -229
  31. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  32. package/schematics/ng-generate/control-flow-migration/bundle.js +433 -295
  33. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  34. package/schematics/ng-generate/standalone-migration/bundle.js +276 -215
  35. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  36. package/testing/index.d.ts +1 -1
  37. package/esm2022/src/change_detection/scheduling.mjs +0 -103
  38. package/esm2022/src/initial_render_pending_tasks.mjs +0 -49
@@ -1874,7 +1874,7 @@ var ConstantPool = class {
1874
1874
  }))));
1875
1875
  }
1876
1876
  }
1877
- getSharedFunctionReference(fn2, prefix) {
1877
+ getSharedFunctionReference(fn2, prefix, useUniqueName = true) {
1878
1878
  var _a2;
1879
1879
  const isArrow = fn2 instanceof ArrowFunctionExpr;
1880
1880
  for (const current of this.statements) {
@@ -1885,7 +1885,7 @@ var ConstantPool = class {
1885
1885
  return variable(current.name);
1886
1886
  }
1887
1887
  }
1888
- const name = this.uniqueName(prefix);
1888
+ const name = useUniqueName ? this.uniqueName(prefix) : prefix;
1889
1889
  this.statements.push(fn2.toDeclStmt(name, StmtModifier.Final));
1890
1890
  return variable(name);
1891
1891
  }
@@ -3506,13 +3506,17 @@ var TagContentType;
3506
3506
  TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3507
3507
  TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3508
3508
  })(TagContentType || (TagContentType = {}));
3509
- function splitNsName(elementName) {
3509
+ function splitNsName(elementName, fatal = true) {
3510
3510
  if (elementName[0] != ":") {
3511
3511
  return [null, elementName];
3512
3512
  }
3513
3513
  const colonIndex = elementName.indexOf(":", 1);
3514
3514
  if (colonIndex === -1) {
3515
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3515
+ if (fatal) {
3516
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3517
+ } else {
3518
+ return [null, elementName];
3519
+ }
3516
3520
  }
3517
3521
  return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3518
3522
  }
@@ -4019,28 +4023,6 @@ var BlockPlaceholder = class {
4019
4023
  return visitor.visitBlockPlaceholder(this, context);
4020
4024
  }
4021
4025
  };
4022
- var RecurseVisitor = class {
4023
- visitText(text2, context) {
4024
- }
4025
- visitContainer(container, context) {
4026
- container.children.forEach((child) => child.visit(this));
4027
- }
4028
- visitIcu(icu, context) {
4029
- Object.keys(icu.cases).forEach((k) => {
4030
- icu.cases[k].visit(this);
4031
- });
4032
- }
4033
- visitTagPlaceholder(ph, context) {
4034
- ph.children.forEach((child) => child.visit(this));
4035
- }
4036
- visitPlaceholder(ph, context) {
4037
- }
4038
- visitIcuPlaceholder(ph, context) {
4039
- }
4040
- visitBlockPlaceholder(ph, context) {
4041
- ph.children.forEach((child) => child.visit(this));
4042
- }
4043
- };
4044
4026
  function serializeMessage(messageNodes) {
4045
4027
  const visitor = new LocalizeMessageStringVisitor();
4046
4028
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -7108,8 +7090,9 @@ var OpKind;
7108
7090
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7109
7091
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7110
7092
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7111
- OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7112
- OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7093
+ OpKind2[OpKind2["IcuPlaceholder"] = 43] = "IcuPlaceholder";
7094
+ OpKind2[OpKind2["I18nContext"] = 44] = "I18nContext";
7095
+ OpKind2[OpKind2["I18nAttributes"] = 45] = "I18nAttributes";
7113
7096
  })(OpKind || (OpKind = {}));
7114
7097
  var ExpressionKind;
7115
7098
  (function(ExpressionKind2) {
@@ -7413,15 +7396,15 @@ function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
7413
7396
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7414
7397
  }
7415
7398
  function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7416
- return __spreadValues(__spreadValues({
7399
+ return __spreadValues(__spreadValues(__spreadValues({
7417
7400
  kind: OpKind.DeferWhen,
7418
7401
  target,
7419
7402
  expr,
7420
7403
  prefetch,
7421
7404
  sourceSpan
7422
- }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7405
+ }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
7423
7406
  }
7424
- function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7407
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, icuPlaceholder, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7425
7408
  return __spreadValues(__spreadValues(__spreadValues({
7426
7409
  kind: OpKind.I18nExpression,
7427
7410
  context,
@@ -7429,6 +7412,7 @@ function createI18nExpressionOp(context, target, i18nOwner, handle, expression,
7429
7412
  i18nOwner,
7430
7413
  handle,
7431
7414
  expression,
7415
+ icuPlaceholder,
7432
7416
  i18nPlaceholder,
7433
7417
  resolutionTime,
7434
7418
  usage,
@@ -8161,6 +8145,9 @@ function transformExpressionsInOp(op, transform2, flags) {
8161
8145
  if (op.placeholderConfig !== null) {
8162
8146
  op.placeholderConfig = transformExpressionsInExpression(op.placeholderConfig, transform2, flags);
8163
8147
  }
8148
+ if (op.resolverFn !== null) {
8149
+ op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform2, flags);
8150
+ }
8164
8151
  break;
8165
8152
  case OpKind.I18nMessage:
8166
8153
  for (const [placeholder, expr] of op.params) {
@@ -8197,6 +8184,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8197
8184
  case OpKind.Template:
8198
8185
  case OpKind.Text:
8199
8186
  case OpKind.I18nAttributes:
8187
+ case OpKind.IcuPlaceholder:
8200
8188
  break;
8201
8189
  default:
8202
8190
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8496,7 +8484,7 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
8496
8484
  function isElementOrContainerOp(op) {
8497
8485
  return elementContainerOpKinds.has(op.kind);
8498
8486
  }
8499
- function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan) {
8487
+ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8500
8488
  return __spreadValues(__spreadValues({
8501
8489
  kind: OpKind.ElementStart,
8502
8490
  xref,
@@ -8507,10 +8495,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8507
8495
  nonBindable: false,
8508
8496
  namespace,
8509
8497
  i18nPlaceholder,
8510
- sourceSpan
8498
+ startSourceSpan,
8499
+ wholeSourceSpan
8511
8500
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8512
8501
  }
8513
- function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8502
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8514
8503
  return __spreadValues(__spreadValues({
8515
8504
  kind: OpKind.Template,
8516
8505
  xref,
@@ -8525,11 +8514,12 @@ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace
8525
8514
  nonBindable: false,
8526
8515
  namespace,
8527
8516
  i18nPlaceholder,
8528
- sourceSpan
8517
+ startSourceSpan,
8518
+ wholeSourceSpan
8529
8519
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8530
8520
  }
8531
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8532
- return __spreadProps(__spreadValues(__spreadValues({
8521
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8522
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
8533
8523
  kind: OpKind.RepeaterCreate,
8534
8524
  attributes: null,
8535
8525
  xref: primaryView,
@@ -8548,8 +8538,9 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8548
8538
  usesComponentInstance: false,
8549
8539
  i18nPlaceholder,
8550
8540
  emptyI18nPlaceholder,
8551
- sourceSpan
8552
- }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8541
+ startSourceSpan,
8542
+ wholeSourceSpan
8543
+ }, TRAIT_CONSUMES_SLOT), NEW_OP), TRAIT_CONSUMES_VARS), {
8553
8544
  numSlotsUsed: emptyView === null ? 2 : 3
8554
8545
  });
8555
8546
  }
@@ -8572,12 +8563,13 @@ function createEnableBindingsOp(xref) {
8572
8563
  xref
8573
8564
  }, NEW_OP);
8574
8565
  }
8575
- function createTextOp(xref, initialValue, sourceSpan) {
8566
+ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
8576
8567
  return __spreadValues(__spreadValues({
8577
8568
  kind: OpKind.Text,
8578
8569
  xref,
8579
8570
  handle: new SlotHandle(),
8580
8571
  initialValue,
8572
+ icuPlaceholder,
8581
8573
  sourceSpan
8582
8574
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8583
8575
  }
@@ -8728,6 +8720,15 @@ function createIcuEndOp(xref) {
8728
8720
  xref
8729
8721
  }, NEW_OP);
8730
8722
  }
8723
+ function createIcuPlaceholderOp(xref, name, strings) {
8724
+ return __spreadValues({
8725
+ kind: OpKind.IcuPlaceholder,
8726
+ xref,
8727
+ name,
8728
+ strings,
8729
+ expressionPlaceholders: []
8730
+ }, NEW_OP);
8731
+ }
8731
8732
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8732
8733
  if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8733
8734
  throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
@@ -9075,15 +9076,9 @@ function extractAttributeOp(unit, op, elements) {
9075
9076
  if (op.expression instanceof Interpolation2) {
9076
9077
  return;
9077
9078
  }
9078
- let extractable = op.expression.isConstant();
9079
+ let extractable = op.isTextAttribute || op.expression.isConstant();
9079
9080
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9080
- extractable = isStringLiteral(op.expression);
9081
- if (op.name === "style" || op.name === "class") {
9082
- extractable && (extractable = op.isTextAttribute);
9083
- }
9084
- if (unit.job.kind === CompilationJobKind.Host) {
9085
- extractable && (extractable = op.isTextAttribute);
9086
- }
9081
+ extractable && (extractable = op.isTextAttribute);
9087
9082
  }
9088
9083
  if (extractable) {
9089
9084
  const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
@@ -9318,7 +9313,7 @@ function collectElementConsts(job) {
9318
9313
  for (const unit of job.units) {
9319
9314
  for (const op of unit.create) {
9320
9315
  if (op.kind === OpKind.ExtractedAttribute) {
9321
- const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9316
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
9322
9317
  allElementAttributes.set(op.target, attributes);
9323
9318
  attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9324
9319
  OpList.remove(op);
@@ -9353,11 +9348,6 @@ function collectElementConsts(job) {
9353
9348
  }
9354
9349
  var FLYWEIGHT_ARRAY = Object.freeze([]);
9355
9350
  var ElementAttributes = class {
9356
- constructor() {
9357
- this.known = /* @__PURE__ */ new Set();
9358
- this.byKind = /* @__PURE__ */ new Map();
9359
- this.projectAs = null;
9360
- }
9361
9351
  get attributes() {
9362
9352
  var _a2;
9363
9353
  return (_a2 = this.byKind.get(BindingKind.Attribute)) != null ? _a2 : FLYWEIGHT_ARRAY;
@@ -9382,12 +9372,28 @@ var ElementAttributes = class {
9382
9372
  var _a2;
9383
9373
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9384
9374
  }
9375
+ constructor(compatibility) {
9376
+ this.compatibility = compatibility;
9377
+ this.known = /* @__PURE__ */ new Map();
9378
+ this.byKind = /* @__PURE__ */ new Map();
9379
+ this.projectAs = null;
9380
+ }
9381
+ isKnown(kind, name, value) {
9382
+ var _a2;
9383
+ const nameToValue = (_a2 = this.known.get(kind)) != null ? _a2 : /* @__PURE__ */ new Set();
9384
+ this.known.set(kind, nameToValue);
9385
+ if (nameToValue.has(name)) {
9386
+ return true;
9387
+ }
9388
+ nameToValue.add(name);
9389
+ return false;
9390
+ }
9385
9391
  add(kind, name, value, trustedValueFn) {
9386
9392
  var _a2;
9387
- if (this.known.has(name)) {
9393
+ const allowDuplicates = this.compatibility === CompatibilityMode.TemplateDefinitionBuilder && (kind === BindingKind.Attribute || kind === BindingKind.ClassName || kind === BindingKind.StyleProperty);
9394
+ if (!allowDuplicates && this.isKnown(kind, name, value)) {
9388
9395
  return;
9389
9396
  }
9390
- this.known.add(name);
9391
9397
  if (name === "ngProjectAs") {
9392
9398
  if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
9393
9399
  throw Error("ngProjectAs must have a string literal value");
@@ -9418,7 +9424,7 @@ var ElementAttributes = class {
9418
9424
  }
9419
9425
  };
9420
9426
  function getAttributeNameLiterals(name) {
9421
- const [attributeNamespace, attributeName] = splitNsName(name);
9427
+ const [attributeNamespace, attributeName] = splitNsName(name, false);
9422
9428
  const nameLiteral = literal(attributeName);
9423
9429
  if (attributeNamespace) {
9424
9430
  return [
@@ -9485,7 +9491,7 @@ function convertI18nBindings(job) {
9485
9491
  if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9486
9492
  throw new Error(`AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`);
9487
9493
  }
9488
- ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9494
+ ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, null, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9489
9495
  }
9490
9496
  OpList.replaceWithMany(op, ops);
9491
9497
  break;
@@ -9516,7 +9522,11 @@ function createDeferDepsFns(job) {
9516
9522
  if (op.handle.slot === null) {
9517
9523
  throw new Error("AssertionError: slot must be assigned bfore extracting defer deps functions");
9518
9524
  }
9519
- op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
9525
+ op.resolverFn = job.pool.getSharedFunctionReference(
9526
+ depsFnExpr,
9527
+ `${job.componentName}_Defer_${op.handle.slot}_DepsFn`,
9528
+ false
9529
+ );
9520
9530
  }
9521
9531
  }
9522
9532
  }
@@ -9524,62 +9534,99 @@ function createDeferDepsFns(job) {
9524
9534
 
9525
9535
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.mjs
9526
9536
  function createI18nContexts(job) {
9527
- const rootContexts = /* @__PURE__ */ new Map();
9528
- let currentI18nOp = null;
9529
- let xref;
9530
- const messageToContext = /* @__PURE__ */ new Map();
9537
+ const attrContextByMessage = /* @__PURE__ */ new Map();
9538
+ for (const unit of job.units) {
9539
+ for (const op of unit.ops()) {
9540
+ switch (op.kind) {
9541
+ case OpKind.Binding:
9542
+ case OpKind.Property:
9543
+ case OpKind.Attribute:
9544
+ case OpKind.ExtractedAttribute:
9545
+ if (op.i18nMessage === null) {
9546
+ continue;
9547
+ }
9548
+ if (!attrContextByMessage.has(op.i18nMessage)) {
9549
+ const i18nContext = createI18nContextOp(I18nContextKind.Attr, job.allocateXrefId(), null, op.i18nMessage, null);
9550
+ unit.create.push(i18nContext);
9551
+ attrContextByMessage.set(op.i18nMessage, i18nContext.xref);
9552
+ }
9553
+ op.i18nContext = attrContextByMessage.get(op.i18nMessage);
9554
+ break;
9555
+ }
9556
+ }
9557
+ }
9558
+ const blockContextByI18nBlock = /* @__PURE__ */ new Map();
9531
9559
  for (const unit of job.units) {
9532
9560
  for (const op of unit.create) {
9533
9561
  switch (op.kind) {
9534
9562
  case OpKind.I18nStart:
9535
- currentI18nOp = op;
9536
9563
  if (op.xref === op.root) {
9537
- xref = job.allocateXrefId();
9538
- unit.create.push(createI18nContextOp(I18nContextKind.RootI18n, xref, op.xref, op.message, null));
9539
- op.context = xref;
9540
- rootContexts.set(op.xref, xref);
9564
+ const contextOp = createI18nContextOp(I18nContextKind.RootI18n, job.allocateXrefId(), op.xref, op.message, null);
9565
+ unit.create.push(contextOp);
9566
+ op.context = contextOp.xref;
9567
+ blockContextByI18nBlock.set(op.xref, contextOp);
9541
9568
  }
9542
9569
  break;
9570
+ }
9571
+ }
9572
+ }
9573
+ for (const unit of job.units) {
9574
+ for (const op of unit.create) {
9575
+ if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9576
+ const rootContext = blockContextByI18nBlock.get(op.root);
9577
+ if (rootContext === void 0) {
9578
+ throw Error("AssertionError: Root i18n block i18n context should have been created.");
9579
+ }
9580
+ op.context = rootContext.xref;
9581
+ blockContextByI18nBlock.set(op.xref, rootContext);
9582
+ }
9583
+ }
9584
+ }
9585
+ let currentI18nOp = null;
9586
+ for (const unit of job.units) {
9587
+ for (const op of unit.create) {
9588
+ switch (op.kind) {
9589
+ case OpKind.I18nStart:
9590
+ currentI18nOp = op;
9591
+ break;
9543
9592
  case OpKind.I18nEnd:
9544
9593
  currentI18nOp = null;
9545
9594
  break;
9546
9595
  case OpKind.IcuStart:
9547
9596
  if (currentI18nOp === null) {
9548
- throw Error("Unexpected ICU outside of an i18n block.");
9597
+ throw Error("AssertionError: Unexpected ICU outside of an i18n block.");
9549
9598
  }
9550
9599
  if (op.message.id !== currentI18nOp.message.id) {
9551
- xref = job.allocateXrefId();
9552
- unit.create.push(createI18nContextOp(I18nContextKind.Icu, xref, currentI18nOp.xref, op.message, null));
9553
- op.context = xref;
9600
+ const contextOp = createI18nContextOp(I18nContextKind.Icu, job.allocateXrefId(), currentI18nOp.xref, op.message, null);
9601
+ unit.create.push(contextOp);
9602
+ op.context = contextOp.xref;
9554
9603
  } else {
9555
9604
  op.context = currentI18nOp.context;
9605
+ blockContextByI18nBlock.get(currentI18nOp.xref).contextKind = I18nContextKind.Icu;
9556
9606
  }
9557
9607
  break;
9558
9608
  }
9559
9609
  }
9560
- for (const op of unit.ops()) {
9561
- switch (op.kind) {
9562
- case OpKind.Binding:
9563
- case OpKind.Property:
9564
- case OpKind.Attribute:
9565
- case OpKind.ExtractedAttribute:
9566
- if (!op.i18nMessage) {
9567
- continue;
9568
- }
9569
- if (!messageToContext.has(op.i18nMessage)) {
9570
- const i18nContext = job.allocateXrefId();
9571
- unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9572
- messageToContext.set(op.i18nMessage, i18nContext);
9573
- }
9574
- op.i18nContext = messageToContext.get(op.i18nMessage);
9575
- break;
9576
- }
9577
- }
9578
9610
  }
9611
+ }
9612
+
9613
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.mjs
9614
+ function deduplicateTextBindings(job) {
9615
+ const seen = /* @__PURE__ */ new Map();
9579
9616
  for (const unit of job.units) {
9580
- for (const op of unit.create) {
9581
- if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9582
- op.context = rootContexts.get(op.root);
9617
+ for (const op of unit.update.reversed()) {
9618
+ if (op.kind === OpKind.Binding && op.isTextAttribute) {
9619
+ const seenForElement = seen.get(op.target) || /* @__PURE__ */ new Set();
9620
+ if (seenForElement.has(op.name)) {
9621
+ if (job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9622
+ if (op.name === "style" || op.name === "class") {
9623
+ OpList.remove(op);
9624
+ }
9625
+ } else {
9626
+ }
9627
+ }
9628
+ seenForElement.add(op.name);
9629
+ seen.set(op.target, seenForElement);
9583
9630
  }
9584
9631
  }
9585
9632
  }
@@ -9869,12 +9916,16 @@ var LIST_START_MARKER = "[";
9869
9916
  var LIST_END_MARKER = "]";
9870
9917
  var LIST_DELIMITER = "|";
9871
9918
  function extractI18nMessages(job) {
9872
- const i18nContexts = /* @__PURE__ */ new Map();
9919
+ const i18nMessagesByContext = /* @__PURE__ */ new Map();
9873
9920
  const i18nBlocks = /* @__PURE__ */ new Map();
9921
+ const i18nContexts = /* @__PURE__ */ new Map();
9874
9922
  for (const unit of job.units) {
9875
9923
  for (const op of unit.create) {
9876
9924
  switch (op.kind) {
9877
9925
  case OpKind.I18nContext:
9926
+ const i18nMessageOp = createI18nMessage(job, op);
9927
+ unit.create.push(i18nMessageOp);
9928
+ i18nMessagesByContext.set(op.xref, i18nMessageOp);
9878
9929
  i18nContexts.set(op.xref, op);
9879
9930
  break;
9880
9931
  case OpKind.I18nStart:
@@ -9883,49 +9934,40 @@ function extractI18nMessages(job) {
9883
9934
  }
9884
9935
  }
9885
9936
  }
9886
- for (const unit of job.units) {
9887
- for (const op of unit.create) {
9888
- if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9889
- continue;
9890
- }
9891
- const i18nMessageOp = createI18nMessage(job, op);
9892
- unit.create.push(i18nMessageOp);
9893
- }
9894
- }
9895
- const i18nBlockMessages = /* @__PURE__ */ new Map();
9896
- for (const unit of job.units) {
9897
- for (const op of unit.create) {
9898
- if (op.kind === OpKind.I18nStart && op.xref === op.root) {
9899
- if (!op.context) {
9900
- throw Error("I18n start op should have its context set.");
9901
- }
9902
- const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
9903
- i18nBlockMessages.set(op.xref, i18nMessageOp);
9904
- unit.create.push(i18nMessageOp);
9905
- }
9906
- }
9907
- }
9937
+ let currentIcu = null;
9908
9938
  for (const unit of job.units) {
9909
9939
  for (const op of unit.create) {
9910
9940
  switch (op.kind) {
9911
9941
  case OpKind.IcuStart:
9912
- if (!op.context) {
9913
- throw Error("ICU op should have its context set.");
9942
+ currentIcu = op;
9943
+ OpList.remove(op);
9944
+ const icuContext = i18nContexts.get(op.context);
9945
+ if (icuContext.contextKind !== I18nContextKind.Icu) {
9946
+ continue;
9914
9947
  }
9915
- const i18nContext = i18nContexts.get(op.context);
9916
- if (i18nContext.contextKind === I18nContextKind.Icu) {
9917
- if (i18nContext.i18nBlock === null) {
9918
- throw Error("ICU context should have its i18n block set.");
9919
- }
9920
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9921
- unit.create.push(subMessage);
9922
- const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
9923
- const parentMessage = i18nBlockMessages.get(rootI18nId);
9924
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9948
+ const i18nBlock = i18nBlocks.get(icuContext.i18nBlock);
9949
+ if (i18nBlock.context === icuContext.xref) {
9950
+ continue;
9925
9951
  }
9926
- OpList.remove(op);
9952
+ const rootI18nBlock = i18nBlocks.get(i18nBlock.root);
9953
+ const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context);
9954
+ if (rootMessage === void 0) {
9955
+ throw Error("AssertionError: ICU sub-message should belong to a root message.");
9956
+ }
9957
+ const subMessage = i18nMessagesByContext.get(icuContext.xref);
9958
+ subMessage.messagePlaceholder = op.messagePlaceholder;
9959
+ rootMessage.subMessages.push(subMessage.xref);
9927
9960
  break;
9928
9961
  case OpKind.IcuEnd:
9962
+ currentIcu = null;
9963
+ OpList.remove(op);
9964
+ break;
9965
+ case OpKind.IcuPlaceholder:
9966
+ if (currentIcu === null || currentIcu.context == null) {
9967
+ throw Error("AssertionError: Unexpected ICU placeholder outside of i18n context");
9968
+ }
9969
+ const msg = i18nMessagesByContext.get(currentIcu.context);
9970
+ msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
9929
9971
  OpList.remove(op);
9930
9972
  break;
9931
9973
  }
@@ -9935,14 +9977,16 @@ function extractI18nMessages(job) {
9935
9977
  function createI18nMessage(job, context, messagePlaceholder) {
9936
9978
  let formattedParams = formatParams(context.params);
9937
9979
  const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9938
- let needsPostprocessing = formattedPostprocessingParams.size > 0;
9939
- for (const values of context.params.values()) {
9940
- if (values.length > 1) {
9941
- needsPostprocessing = true;
9942
- }
9943
- }
9980
+ let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);
9944
9981
  return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9945
9982
  }
9983
+ function formatIcuPlaceholder(op) {
9984
+ if (op.strings.length !== op.expressionPlaceholders.length + 1) {
9985
+ throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`);
9986
+ }
9987
+ const values = op.expressionPlaceholders.map(formatValue);
9988
+ return op.strings.flatMap((str, i) => [str, values[i] || ""]).join("");
9989
+ }
9946
9990
  function formatParams(params) {
9947
9991
  const formattedParams = /* @__PURE__ */ new Map();
9948
9992
  for (const [placeholder, placeholderValues] of params) {
@@ -10169,7 +10213,7 @@ var CLASS_BANG = "class!";
10169
10213
  var BANG_IMPORTANT = "!important";
10170
10214
  function parseHostStyleProperties(job) {
10171
10215
  for (const op of job.root.update) {
10172
- if (op.kind !== OpKind.Binding) {
10216
+ if (!(op.kind === OpKind.Binding && op.bindingKind === BindingKind.Property)) {
10173
10217
  continue;
10174
10218
  }
10175
10219
  if (op.name.endsWith(BANG_IMPORTANT)) {
@@ -16311,7 +16355,7 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16311
16355
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16312
16356
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16313
16357
  let transformFn = void 0;
16314
- if (messageOp.needsPostprocessing) {
16358
+ if (messageOp.needsPostprocessing || messageOp.postprocessingParams.size > 0) {
16315
16359
  const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16316
16360
  const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16317
16361
  const extraTransformFnParams = [];
@@ -16330,7 +16374,6 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16330
16374
  } else {
16331
16375
  messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16332
16376
  messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16333
- messageOp.needsPostprocessing = true;
16334
16377
  }
16335
16378
  }
16336
16379
  }
@@ -16364,12 +16407,13 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16364
16407
 
16365
16408
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16366
16409
  function convertI18nText(job) {
16367
- var _a2;
16410
+ var _a2, _b2, _c2;
16368
16411
  for (const unit of job.units) {
16369
16412
  let currentI18n = null;
16370
16413
  let currentIcu = null;
16371
16414
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
16372
16415
  const textNodeIcus = /* @__PURE__ */ new Map();
16416
+ const icuPlaceholderByText = /* @__PURE__ */ new Map();
16373
16417
  for (const op of unit.create) {
16374
16418
  switch (op.kind) {
16375
16419
  case OpKind.I18nStart:
@@ -16394,7 +16438,13 @@ function convertI18nText(job) {
16394
16438
  if (currentI18n !== null) {
16395
16439
  textNodeI18nBlocks.set(op.xref, currentI18n);
16396
16440
  textNodeIcus.set(op.xref, currentIcu);
16397
- OpList.remove(op);
16441
+ if (op.icuPlaceholder !== null) {
16442
+ const icuPlaceholderOp = createIcuPlaceholderOp(job.allocateXrefId(), op.icuPlaceholder, [op.initialValue]);
16443
+ OpList.replace(op, icuPlaceholderOp);
16444
+ icuPlaceholderByText.set(op.xref, icuPlaceholderOp);
16445
+ } else {
16446
+ OpList.remove(op);
16447
+ }
16398
16448
  }
16399
16449
  break;
16400
16450
  }
@@ -16407,14 +16457,18 @@ function convertI18nText(job) {
16407
16457
  }
16408
16458
  const i18nOp = textNodeI18nBlocks.get(op.target);
16409
16459
  const icuOp = textNodeIcus.get(op.target);
16460
+ const icuPlaceholder = icuPlaceholderByText.get(op.target);
16410
16461
  const contextId = icuOp ? icuOp.context : i18nOp.context;
16411
16462
  const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16412
16463
  const ops = [];
16413
16464
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16414
16465
  const expr = op.interpolation.expressions[i];
16415
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, op.interpolation.i18nPlaceholders[i], resolutionTime, I18nExpressionFor.I18nText, "", (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16466
+ ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, (_a2 = icuPlaceholder == null ? void 0 : icuPlaceholder.xref) != null ? _a2 : null, (_b2 = op.interpolation.i18nPlaceholders[i]) != null ? _b2 : null, resolutionTime, I18nExpressionFor.I18nText, "", (_c2 = expr.sourceSpan) != null ? _c2 : op.sourceSpan));
16416
16467
  }
16417
16468
  OpList.replaceWithMany(op, ops);
16469
+ if (icuPlaceholder !== void 0) {
16470
+ icuPlaceholder.strings = op.interpolation.strings;
16471
+ }
16418
16472
  break;
16419
16473
  }
16420
16474
  }
@@ -16828,9 +16882,21 @@ function keepLast(ops) {
16828
16882
 
16829
16883
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.mjs
16830
16884
  function parseExtractedStyles(job) {
16885
+ const elements = /* @__PURE__ */ new Map();
16886
+ for (const unit of job.units) {
16887
+ for (const op of unit.create) {
16888
+ if (isElementOrContainerOp(op)) {
16889
+ elements.set(op.xref, op);
16890
+ }
16891
+ }
16892
+ }
16831
16893
  for (const unit of job.units) {
16832
16894
  for (const op of unit.create) {
16833
16895
  if (op.kind === OpKind.ExtractedAttribute && op.bindingKind === BindingKind.Attribute && isStringLiteral(op.expression)) {
16896
+ const target = elements.get(op.target);
16897
+ if (target !== void 0 && target.kind === OpKind.Template && target.templateKind === TemplateKind.Structural) {
16898
+ continue;
16899
+ }
16834
16900
  if (op.name === "style") {
16835
16901
  const parsedStyles = parse(op.expression.value);
16836
16902
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
@@ -17624,19 +17690,19 @@ function reifyCreateOperations(unit, ops) {
17624
17690
  OpList.replace(op, text(op.handle.slot, op.initialValue, op.sourceSpan));
17625
17691
  break;
17626
17692
  case OpKind.ElementStart:
17627
- OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17693
+ OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17628
17694
  break;
17629
17695
  case OpKind.Element:
17630
- OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17696
+ OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.wholeSourceSpan));
17631
17697
  break;
17632
17698
  case OpKind.ElementEnd:
17633
17699
  OpList.replace(op, elementEnd(op.sourceSpan));
17634
17700
  break;
17635
17701
  case OpKind.ContainerStart:
17636
- OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17702
+ OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.startSourceSpan));
17637
17703
  break;
17638
17704
  case OpKind.Container:
17639
- OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17705
+ OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.wholeSourceSpan));
17640
17706
  break;
17641
17707
  case OpKind.ContainerEnd:
17642
17708
  OpList.replace(op, elementContainerEnd());
@@ -17664,7 +17730,7 @@ function reifyCreateOperations(unit, ops) {
17664
17730
  throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
17665
17731
  }
17666
17732
  const childView = unit.job.views.get(op.xref);
17667
- OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17733
+ OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17668
17734
  break;
17669
17735
  case OpKind.DisableBindings:
17670
17736
  OpList.replace(op, disableBindings2());
@@ -17679,7 +17745,7 @@ function reifyCreateOperations(unit, ops) {
17679
17745
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17680
17746
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17681
17747
  if (eventTargetResolver === void 0) {
17682
- throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17748
+ throw new Error(`Unexpected global target '${op.eventTarget}' defined for '${op.name}' event. Supported list of global targets: window,document,body.`);
17683
17749
  }
17684
17750
  OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17685
17751
  break;
@@ -17766,7 +17832,7 @@ function reifyCreateOperations(unit, ops) {
17766
17832
  emptyDecls = emptyView.decls;
17767
17833
  emptyVars = emptyView.vars;
17768
17834
  }
17769
- OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.sourceSpan));
17835
+ OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.wholeSourceSpan));
17770
17836
  break;
17771
17837
  case OpKind.Statement:
17772
17838
  break;
@@ -18273,6 +18339,7 @@ function resolveI18nExpressionPlaceholders(job) {
18273
18339
  var _a2;
18274
18340
  const subTemplateIndicies = /* @__PURE__ */ new Map();
18275
18341
  const i18nContexts = /* @__PURE__ */ new Map();
18342
+ const icuPlaceholders = /* @__PURE__ */ new Map();
18276
18343
  for (const unit of job.units) {
18277
18344
  for (const op of unit.create) {
18278
18345
  switch (op.kind) {
@@ -18282,6 +18349,9 @@ function resolveI18nExpressionPlaceholders(job) {
18282
18349
  case OpKind.I18nContext:
18283
18350
  i18nContexts.set(op.xref, op);
18284
18351
  break;
18352
+ case OpKind.IcuPlaceholder:
18353
+ icuPlaceholders.set(op.xref, op);
18354
+ break;
18285
18355
  }
18286
18356
  }
18287
18357
  }
@@ -18290,66 +18360,32 @@ function resolveI18nExpressionPlaceholders(job) {
18290
18360
  for (const unit of job.units) {
18291
18361
  for (const op of unit.update) {
18292
18362
  if (op.kind === OpKind.I18nExpression) {
18293
- const i18nContext = i18nContexts.get(op.context);
18294
18363
  const index = expressionIndices.get(referenceIndex(op)) || 0;
18295
18364
  const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
18296
- const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18297
- const values = params.get(op.i18nPlaceholder) || [];
18298
- values.push({
18365
+ const value = {
18299
18366
  value: index,
18300
18367
  subTemplateIndex,
18301
18368
  flags: I18nParamValueFlags.ExpressionIndex
18302
- });
18303
- params.set(op.i18nPlaceholder, values);
18369
+ };
18370
+ updatePlaceholder(op, value, i18nContexts, icuPlaceholders);
18304
18371
  expressionIndices.set(referenceIndex(op), index + 1);
18305
18372
  }
18306
18373
  }
18307
18374
  }
18308
18375
  }
18309
-
18310
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
18311
- function resolveI18nIcuPlaceholders(job) {
18312
- for (const unit of job.units) {
18313
- for (const op of unit.create) {
18314
- if (op.kind === OpKind.I18nContext && op.contextKind === I18nContextKind.Icu) {
18315
- for (const node of op.message.nodes) {
18316
- node.visit(new ResolveIcuPlaceholdersVisitor(op.postprocessingParams));
18317
- }
18318
- }
18319
- }
18320
- }
18321
- }
18322
- var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
18323
- constructor(params) {
18324
- super();
18325
- this.params = params;
18326
- }
18327
- visitContainerPlaceholder(placeholder) {
18328
- var _a2, _b2;
18329
- if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
18330
- this.params.set(placeholder.startName, [{
18331
- value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
18332
- subTemplateIndex: null,
18333
- flags: I18nParamValueFlags.None
18334
- }]);
18335
- }
18336
- if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
18337
- this.params.set(placeholder.closeName, [{
18338
- value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
18339
- subTemplateIndex: null,
18340
- flags: I18nParamValueFlags.None
18341
- }]);
18342
- }
18343
- }
18344
- visitTagPlaceholder(placeholder) {
18345
- super.visitTagPlaceholder(placeholder);
18346
- this.visitContainerPlaceholder(placeholder);
18376
+ function updatePlaceholder(op, value, i18nContexts, icuPlaceholders) {
18377
+ if (op.i18nPlaceholder !== null) {
18378
+ const i18nContext = i18nContexts.get(op.context);
18379
+ const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18380
+ const values = params.get(op.i18nPlaceholder) || [];
18381
+ values.push(value);
18382
+ params.set(op.i18nPlaceholder, values);
18347
18383
  }
18348
- visitBlockPlaceholder(placeholder) {
18349
- super.visitBlockPlaceholder(placeholder);
18350
- this.visitContainerPlaceholder(placeholder);
18384
+ if (op.icuPlaceholder !== null) {
18385
+ const icuPlaceholderOp = icuPlaceholders.get(op.icuPlaceholder);
18386
+ icuPlaceholderOp == null ? void 0 : icuPlaceholderOp.expressionPlaceholders.push(value);
18351
18387
  }
18352
- };
18388
+ }
18353
18389
 
18354
18390
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
18355
18391
  function resolveNames(job) {
@@ -18819,7 +18855,10 @@ function varsUsedByOp(op) {
18819
18855
  return op.interpolation.expressions.length;
18820
18856
  case OpKind.I18nExpression:
18821
18857
  case OpKind.Conditional:
18858
+ case OpKind.DeferWhen:
18822
18859
  return 1;
18860
+ case OpKind.RepeaterCreate:
18861
+ return op.emptyView ? 1 : 0;
18823
18862
  default:
18824
18863
  throw new Error(`Unhandled op: ${OpKind[op.kind]}`);
18825
18864
  }
@@ -19133,6 +19172,7 @@ var phases = [
19133
19172
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
19134
19173
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
19135
19174
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
19175
+ { kind: CompilationJobKind.Both, fn: deduplicateTextBindings },
19136
19176
  { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19137
19177
  { kind: CompilationJobKind.Both, fn: specializeBindings },
19138
19178
  { kind: CompilationJobKind.Both, fn: extractAttributes },
@@ -19171,7 +19211,6 @@ var phases = [
19171
19211
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
19172
19212
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
19173
19213
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
19174
- { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
19175
19214
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
19176
19215
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
19177
19216
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
@@ -19314,7 +19353,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19314
19353
  bindingKind = BindingKind.Animation;
19315
19354
  }
19316
19355
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19317
- ingestHostProperty(job, property2, bindingKind, false, securityContexts);
19356
+ ingestHostProperty(job, property2, bindingKind, securityContexts);
19318
19357
  }
19319
19358
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
19320
19359
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
@@ -19325,7 +19364,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19325
19364
  }
19326
19365
  return job;
19327
19366
  }
19328
- function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
19367
+ function ingestHostProperty(job, property2, bindingKind, securityContexts) {
19329
19368
  let expression;
19330
19369
  const ast = property2.expression.ast;
19331
19370
  if (ast instanceof Interpolation) {
@@ -19333,7 +19372,7 @@ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securi
19333
19372
  } else {
19334
19373
  expression = convertAst(ast, job, property2.sourceSpan);
19335
19374
  }
19336
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
19375
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, false, false, null, null, property2.sourceSpan));
19337
19376
  }
19338
19377
  function ingestHostAttribute(job, name, value, securityContexts) {
19339
19378
  const attrBinding = createBindingOp(
@@ -19347,14 +19386,13 @@ function ingestHostAttribute(job, name, value, securityContexts) {
19347
19386
  false,
19348
19387
  null,
19349
19388
  null,
19350
- null
19389
+ value.sourceSpan
19351
19390
  );
19352
19391
  job.root.update.push(attrBinding);
19353
19392
  }
19354
19393
  function ingestHostEvent(job, event) {
19355
19394
  const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19356
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
19357
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
19395
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
19358
19396
  job.root.create.push(eventBinding);
19359
19397
  }
19360
19398
  function ingestNodes(unit, template2) {
@@ -19366,9 +19404,9 @@ function ingestNodes(unit, template2) {
19366
19404
  } else if (node instanceof Content) {
19367
19405
  ingestContent(unit, node);
19368
19406
  } else if (node instanceof Text) {
19369
- ingestText(unit, node);
19407
+ ingestText(unit, node, null);
19370
19408
  } else if (node instanceof BoundText) {
19371
- ingestBoundText(unit, node);
19409
+ ingestBoundText(unit, node, null);
19372
19410
  } else if (node instanceof IfBlock) {
19373
19411
  ingestIfBlock(unit, node);
19374
19412
  } else if (node instanceof SwitchBlock) {
@@ -19391,7 +19429,7 @@ function ingestElement(unit, element2) {
19391
19429
  }
19392
19430
  const id = unit.job.allocateXrefId();
19393
19431
  const [namespaceKey, elementName] = splitNsName(element2.name);
19394
- const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
19432
+ const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan, element2.sourceSpan);
19395
19433
  unit.create.push(startOp);
19396
19434
  ingestElementBindings(unit, startOp, element2);
19397
19435
  ingestReferences(startOp, element2);
@@ -19421,7 +19459,7 @@ function ingestTemplate(unit, tmpl) {
19421
19459
  const namespace = namespaceForKey(namespacePrefix);
19422
19460
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
19423
19461
  const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19424
- const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19462
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan, tmpl.sourceSpan);
19425
19463
  unit.create.push(templateOp);
19426
19464
  ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19427
19465
  ingestReferences(templateOp, tmpl);
@@ -19447,10 +19485,10 @@ function ingestContent(unit, content) {
19447
19485
  }
19448
19486
  unit.create.push(op);
19449
19487
  }
19450
- function ingestText(unit, text2) {
19451
- unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
19488
+ function ingestText(unit, text2, icuPlaceholder) {
19489
+ unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, icuPlaceholder, text2.sourceSpan));
19452
19490
  }
19453
- function ingestBoundText(unit, text2, i18nPlaceholders) {
19491
+ function ingestBoundText(unit, text2, icuPlaceholder) {
19454
19492
  var _a2;
19455
19493
  let value = text2.value;
19456
19494
  if (value instanceof ASTWithSource) {
@@ -19462,14 +19500,12 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19462
19500
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
19463
19501
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
19464
19502
  }
19465
- if (i18nPlaceholders === void 0) {
19466
- i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19467
- }
19503
+ const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19468
19504
  if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
19469
19505
  throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
19470
19506
  }
19471
19507
  const textXref = unit.job.allocateXrefId();
19472
- unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19508
+ unit.create.push(createTextOp(textXref, "", icuPlaceholder, text2.sourceSpan));
19473
19509
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19474
19510
  unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19475
19511
  }
@@ -19495,7 +19531,7 @@ function ingestIfBlock(unit, ifBlock) {
19495
19531
  }
19496
19532
  ifCaseI18nMeta = ifCase.i18n;
19497
19533
  }
19498
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19534
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.startSourceSpan, ifCase.sourceSpan);
19499
19535
  unit.create.push(templateOp);
19500
19536
  if (firstXref === null) {
19501
19537
  firstXref = cView.xref;
@@ -19523,7 +19559,7 @@ function ingestSwitchBlock(unit, switchBlock) {
19523
19559
  }
19524
19560
  switchCaseI18nMeta = switchCase.i18n;
19525
19561
  }
19526
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19562
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.startSourceSpan, switchCase.sourceSpan);
19527
19563
  unit.create.push(templateOp);
19528
19564
  if (firstXref === null) {
19529
19565
  firstXref = cView.xref;
@@ -19546,7 +19582,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19546
19582
  }
19547
19583
  const secondaryView = unit.job.allocateView(unit.xref);
19548
19584
  ingestNodes(secondaryView, children);
19549
- const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19585
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan, sourceSpan);
19550
19586
  unit.create.push(templateOp);
19551
19587
  return templateOp;
19552
19588
  }
@@ -19620,6 +19656,9 @@ function ingestDeferBlock(unit, deferBlock) {
19620
19656
  deferOnOps.push(deferOnOp);
19621
19657
  }
19622
19658
  if (triggers.when !== void 0) {
19659
+ if (triggers.when.value instanceof Interpolation) {
19660
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
19661
+ }
19623
19662
  const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
19624
19663
  deferWhenOps.push(deferOnOp);
19625
19664
  }
@@ -19639,9 +19678,9 @@ function ingestIcu(unit, icu) {
19639
19678
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19640
19679
  for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19641
19680
  if (text2 instanceof BoundText) {
19642
- ingestBoundText(unit, text2, [placeholder]);
19681
+ ingestBoundText(unit, text2, placeholder);
19643
19682
  } else {
19644
- ingestText(unit, text2);
19683
+ ingestText(unit, text2, placeholder);
19645
19684
  }
19646
19685
  }
19647
19686
  unit.create.push(createIcuEndOp(xref));
@@ -19693,7 +19732,7 @@ function ingestForBlock(unit, forBlock) {
19693
19732
  const i18nPlaceholder = forBlock.i18n;
19694
19733
  const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19695
19734
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19696
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19735
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.startSourceSpan, forBlock.sourceSpan);
19697
19736
  unit.create.push(repeaterCreate2);
19698
19737
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19699
19738
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19781,13 +19820,13 @@ function convertAst(ast, job, baseSourceSpan) {
19781
19820
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19782
19821
  }
19783
19822
  }
19784
- function convertAstWithInterpolation(job, value, i18nMeta) {
19823
+ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
19785
19824
  var _a2, _b2;
19786
19825
  let expression;
19787
19826
  if (value instanceof Interpolation) {
19788
- expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19827
+ expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, sourceSpan != null ? sourceSpan : null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19789
19828
  } else if (value instanceof AST) {
19790
- expression = convertAst(value, job, null);
19829
+ expression = convertAst(value, job, sourceSpan != null ? sourceSpan : null);
19791
19830
  } else {
19792
19831
  expression = literal(value);
19793
19832
  }
@@ -23465,12 +23504,15 @@ var BindingScope = class {
23465
23504
  }
23466
23505
  };
23467
23506
  var TrackByBindingScope = class extends BindingScope {
23468
- constructor(parentScope, globalAliases) {
23507
+ constructor(parentScope, globalOverrides) {
23469
23508
  super(parentScope.bindingLevel + 1, parentScope);
23470
- this.globalAliases = globalAliases;
23509
+ this.globalOverrides = globalOverrides;
23471
23510
  this.componentAccessCount = 0;
23472
23511
  }
23473
23512
  get(name) {
23513
+ if (this.globalOverrides.hasOwnProperty(name)) {
23514
+ return variable(this.globalOverrides[name]);
23515
+ }
23474
23516
  let current = this.parent;
23475
23517
  while (current) {
23476
23518
  if (current.hasLocal(name)) {
@@ -23478,9 +23520,6 @@ var TrackByBindingScope = class extends BindingScope {
23478
23520
  }
23479
23521
  current = current.parent;
23480
23522
  }
23481
- if (this.globalAliases[name]) {
23482
- return variable(this.globalAliases[name]);
23483
- }
23484
23523
  this.componentAccessCount++;
23485
23524
  return variable("this").prop(name);
23486
23525
  }
@@ -25482,7 +25521,7 @@ function publishFacade(global) {
25482
25521
  }
25483
25522
 
25484
25523
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
25485
- var VERSION2 = new Version("17.0.7");
25524
+ var VERSION2 = new Version("17.0.8");
25486
25525
 
25487
25526
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
25488
25527
  var _VisitorMode;