@angular/compiler 14.0.0-next.2 → 14.0.0-next.5

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-next.2
2
+ * @license Angular v14.0.0-next.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -4872,6 +4872,65 @@ const IMPLICIT_REFERENCE = '$implicit';
4872
4872
  const NON_BINDABLE_ATTR = 'ngNonBindable';
4873
4873
  /** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */
4874
4874
  const RESTORED_VIEW_CONTEXT_NAME = 'restoredCtx';
4875
+ /** Instructions that support chaining. */
4876
+ const CHAINABLE_INSTRUCTIONS = new Set([
4877
+ Identifiers.element,
4878
+ Identifiers.elementStart,
4879
+ Identifiers.elementEnd,
4880
+ Identifiers.elementContainer,
4881
+ Identifiers.elementContainerStart,
4882
+ Identifiers.elementContainerEnd,
4883
+ Identifiers.i18nExp,
4884
+ Identifiers.listener,
4885
+ Identifiers.classProp,
4886
+ Identifiers.syntheticHostListener,
4887
+ Identifiers.hostProperty,
4888
+ Identifiers.syntheticHostProperty,
4889
+ Identifiers.property,
4890
+ Identifiers.propertyInterpolate1,
4891
+ Identifiers.propertyInterpolate2,
4892
+ Identifiers.propertyInterpolate3,
4893
+ Identifiers.propertyInterpolate4,
4894
+ Identifiers.propertyInterpolate5,
4895
+ Identifiers.propertyInterpolate6,
4896
+ Identifiers.propertyInterpolate7,
4897
+ Identifiers.propertyInterpolate8,
4898
+ Identifiers.propertyInterpolateV,
4899
+ Identifiers.attribute,
4900
+ Identifiers.attributeInterpolate1,
4901
+ Identifiers.attributeInterpolate2,
4902
+ Identifiers.attributeInterpolate3,
4903
+ Identifiers.attributeInterpolate4,
4904
+ Identifiers.attributeInterpolate5,
4905
+ Identifiers.attributeInterpolate6,
4906
+ Identifiers.attributeInterpolate7,
4907
+ Identifiers.attributeInterpolate8,
4908
+ Identifiers.attributeInterpolateV,
4909
+ Identifiers.styleProp,
4910
+ Identifiers.stylePropInterpolate1,
4911
+ Identifiers.stylePropInterpolate2,
4912
+ Identifiers.stylePropInterpolate3,
4913
+ Identifiers.stylePropInterpolate4,
4914
+ Identifiers.stylePropInterpolate5,
4915
+ Identifiers.stylePropInterpolate6,
4916
+ Identifiers.stylePropInterpolate7,
4917
+ Identifiers.stylePropInterpolate8,
4918
+ Identifiers.stylePropInterpolateV,
4919
+ Identifiers.textInterpolate,
4920
+ Identifiers.textInterpolate1,
4921
+ Identifiers.textInterpolate2,
4922
+ Identifiers.textInterpolate3,
4923
+ Identifiers.textInterpolate4,
4924
+ Identifiers.textInterpolate5,
4925
+ Identifiers.textInterpolate6,
4926
+ Identifiers.textInterpolate7,
4927
+ Identifiers.textInterpolate8,
4928
+ Identifiers.textInterpolateV,
4929
+ ]);
4930
+ /** Generates a call to a single instruction. */
4931
+ function invokeInstruction(span, reference, params) {
4932
+ return importExpr(reference, null, span).callFn(params, span);
4933
+ }
4875
4934
  /**
4876
4935
  * Creates an allocator for a temporary variable.
4877
4936
  *
@@ -5013,20 +5072,6 @@ function getAttrsForDirectiveMatching(elOrTpl) {
5013
5072
  }
5014
5073
  return attributesMap;
5015
5074
  }
5016
- /** Returns a call expression to a chained instruction, e.g. `property(params[0])(params[1])`. */
5017
- function chainedInstruction(reference, calls, span) {
5018
- let expression = importExpr(reference, null, span);
5019
- if (calls.length > 0) {
5020
- for (let i = 0; i < calls.length; i++) {
5021
- expression = expression.callFn(calls[i], span);
5022
- }
5023
- }
5024
- else {
5025
- // Add a blank invocation, in case the `calls` array is empty.
5026
- expression = expression.callFn([], span);
5027
- }
5028
- return expression;
5029
- }
5030
5075
  /**
5031
5076
  * Gets the number of arguments expected to be passed to a generated instruction in the case of
5032
5077
  * interpolation instructions.
@@ -5044,6 +5089,40 @@ function getInterpolationArgsLength(interpolation) {
5044
5089
  return expressions.length + strings.length;
5045
5090
  }
5046
5091
  }
5092
+ /**
5093
+ * Generates the final instruction call statements based on the passed in configuration.
5094
+ * Will try to chain instructions as much as possible, if chaining is supported.
5095
+ */
5096
+ function getInstructionStatements(instructions) {
5097
+ const statements = [];
5098
+ let pendingExpression = null;
5099
+ let pendingExpressionType = null;
5100
+ for (const current of instructions) {
5101
+ const resolvedParams = (typeof current.paramsOrFn === 'function' ? current.paramsOrFn() : current.paramsOrFn) ??
5102
+ [];
5103
+ const params = Array.isArray(resolvedParams) ? resolvedParams : [resolvedParams];
5104
+ // If the current instruction is the same as the previous one
5105
+ // and it can be chained, add another call to the chain.
5106
+ if (pendingExpressionType === current.reference &&
5107
+ CHAINABLE_INSTRUCTIONS.has(pendingExpressionType)) {
5108
+ // We'll always have a pending expression when there's a pending expression type.
5109
+ pendingExpression = pendingExpression.callFn(params, pendingExpression.sourceSpan);
5110
+ }
5111
+ else {
5112
+ if (pendingExpression !== null) {
5113
+ statements.push(pendingExpression.toStmt());
5114
+ }
5115
+ pendingExpression = invokeInstruction(current.span, current.reference, params);
5116
+ pendingExpressionType = current.reference;
5117
+ }
5118
+ }
5119
+ // Since the current instruction adds the previous one to the statements,
5120
+ // we may be left with the final one at the end that is still pending.
5121
+ if (pendingExpression !== null) {
5122
+ statements.push(pendingExpression.toStmt());
5123
+ }
5124
+ return statements;
5125
+ }
5047
5126
 
5048
5127
  /**
5049
5128
  * @license
@@ -16950,9 +17029,9 @@ class TemplateDefinitionBuilder {
16950
17029
  this.i18nEnd(null, selfClosingI18nInstruction);
16951
17030
  }
16952
17031
  // Generate all the creation mode instructions (e.g. resolve bindings in listeners)
16953
- const creationStatements = this._creationCodeFns.map((fn) => fn());
17032
+ const creationStatements = getInstructionStatements(this._creationCodeFns);
16954
17033
  // Generate all the update mode instructions (e.g. resolve property or text bindings)
16955
- const updateStatements = this._updateCodeFns.map((fn) => fn());
17034
+ const updateStatements = getInstructionStatements(this._updateCodeFns);
16956
17035
  // Variable declaration must occur after binding resolution so we can generate context
16957
17036
  // instructions that build on each other.
16958
17037
  // e.g. const b = nextContext().$implicit(); const b = nextContext();
@@ -17105,7 +17184,7 @@ class TemplateDefinitionBuilder {
17105
17184
  if (Object.keys(icuMapping).length) {
17106
17185
  args.push(mapLiteral(icuMapping, true));
17107
17186
  }
17108
- return instruction(null, Identifiers.i18nPostprocess, args);
17187
+ return invokeInstruction(null, Identifiers.i18nPostprocess, args);
17109
17188
  };
17110
17189
  }
17111
17190
  this.i18nTranslate(meta, params, context.ref, transformFn);
@@ -17140,14 +17219,12 @@ class TemplateDefinitionBuilder {
17140
17219
  // setup accumulated bindings
17141
17220
  const { index, bindings } = this.i18n;
17142
17221
  if (bindings.size) {
17143
- const chainBindings = [];
17144
- bindings.forEach(binding => {
17145
- chainBindings.push({ sourceSpan: span, value: () => this.convertPropertyBinding(binding) });
17146
- });
17147
- // for i18n block, advance to the most recent element index (by taking the current number of
17148
- // elements and subtracting one) before invoking `i18nExp` instructions, to make sure the
17149
- // necessary lifecycle hooks of components/directives are properly flushed.
17150
- this.updateInstructionChainWithAdvance(this.getConstCount() - 1, Identifiers.i18nExp, chainBindings);
17222
+ for (const binding of bindings) {
17223
+ // for i18n block, advance to the most recent element index (by taking the current number of
17224
+ // elements and subtracting one) before invoking `i18nExp` instructions, to make sure the
17225
+ // necessary lifecycle hooks of components/directives are properly flushed.
17226
+ this.updateInstructionWithAdvance(this.getConstCount() - 1, span, Identifiers.i18nExp, () => this.convertPropertyBinding(binding));
17227
+ }
17151
17228
  this.updateInstruction(span, Identifiers.i18nApply, [literal(index)]);
17152
17229
  }
17153
17230
  if (!selfClosing) {
@@ -17158,7 +17235,6 @@ class TemplateDefinitionBuilder {
17158
17235
  i18nAttributesInstruction(nodeIndex, attrs, sourceSpan) {
17159
17236
  let hasBindings = false;
17160
17237
  const i18nAttrArgs = [];
17161
- const bindings = [];
17162
17238
  attrs.forEach(attr => {
17163
17239
  const message = attr.i18n;
17164
17240
  const converted = attr.value.visit(this._valueConverter);
@@ -17169,16 +17245,10 @@ class TemplateDefinitionBuilder {
17169
17245
  i18nAttrArgs.push(literal(attr.name), this.i18nTranslate(message, params));
17170
17246
  converted.expressions.forEach(expression => {
17171
17247
  hasBindings = true;
17172
- bindings.push({
17173
- sourceSpan,
17174
- value: () => this.convertPropertyBinding(expression),
17175
- });
17248
+ this.updateInstructionWithAdvance(nodeIndex, sourceSpan, Identifiers.i18nExp, () => this.convertPropertyBinding(expression));
17176
17249
  });
17177
17250
  }
17178
17251
  });
17179
- if (bindings.length > 0) {
17180
- this.updateInstructionChainWithAdvance(nodeIndex, Identifiers.i18nExp, bindings);
17181
- }
17182
17252
  if (i18nAttrArgs.length > 0) {
17183
17253
  const index = literal(this.allocateDataSlot());
17184
17254
  const constIndex = this.addToConsts(literalArr(i18nAttrArgs));
@@ -17306,11 +17376,9 @@ class TemplateDefinitionBuilder {
17306
17376
  }
17307
17377
  // Generate Listeners (outputs)
17308
17378
  if (element.outputs.length > 0) {
17309
- const listeners = element.outputs.map((outputAst) => ({
17310
- sourceSpan: outputAst.sourceSpan,
17311
- params: this.prepareListenerParameter(element.name, outputAst, elementIndex)
17312
- }));
17313
- this.creationInstructionChain(Identifiers.listener, listeners);
17379
+ for (const outputAst of element.outputs) {
17380
+ this.creationInstruction(outputAst.sourceSpan, Identifiers.listener, this.prepareListenerParameter(element.name, outputAst, elementIndex));
17381
+ }
17314
17382
  }
17315
17383
  // Note: it's important to keep i18n/i18nStart instructions after i18nAttributes and
17316
17384
  // listeners, to make sure i18nAttributes instruction targets current element at runtime.
@@ -17351,9 +17419,8 @@ class TemplateDefinitionBuilder {
17351
17419
  const hasValue = value instanceof LiteralPrimitive ? !!value.value : true;
17352
17420
  this.allocateBindingSlots(value);
17353
17421
  propertyBindings.push({
17354
- name: prepareSyntheticPropertyName(input.name),
17355
- sourceSpan: input.sourceSpan,
17356
- value: () => hasValue ? this.convertPropertyBinding(value) : emptyValueBindInstruction
17422
+ span: input.sourceSpan,
17423
+ paramsOrFn: getBindingFunctionParams(() => hasValue ? this.convertPropertyBinding(value) : emptyValueBindInstruction, prepareSyntheticPropertyName(input.name))
17357
17424
  });
17358
17425
  }
17359
17426
  else {
@@ -17390,10 +17457,8 @@ class TemplateDefinitionBuilder {
17390
17457
  // [prop]="value"
17391
17458
  // Collect all the properties so that we can chain into a single function at the end.
17392
17459
  propertyBindings.push({
17393
- name: attrName,
17394
- sourceSpan: input.sourceSpan,
17395
- value: () => this.convertPropertyBinding(value),
17396
- params
17460
+ span: input.sourceSpan,
17461
+ paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(value), attrName, params)
17397
17462
  });
17398
17463
  }
17399
17464
  }
@@ -17407,10 +17472,8 @@ class TemplateDefinitionBuilder {
17407
17472
  // [attr.name]="value" or attr.name="{{value}}"
17408
17473
  // Collect the attribute bindings so that they can be chained at the end.
17409
17474
  attributeBindings.push({
17410
- name: attrName,
17411
- sourceSpan: input.sourceSpan,
17412
- value: () => this.convertPropertyBinding(boundValue),
17413
- params
17475
+ span: input.sourceSpan,
17476
+ paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(boundValue), attrName, params)
17414
17477
  });
17415
17478
  }
17416
17479
  }
@@ -17426,11 +17489,11 @@ class TemplateDefinitionBuilder {
17426
17489
  }
17427
17490
  }
17428
17491
  });
17429
- if (propertyBindings.length > 0) {
17430
- this.updateInstructionChainWithAdvance(elementIndex, Identifiers.property, propertyBindings);
17492
+ for (const propertyBinding of propertyBindings) {
17493
+ this.updateInstructionWithAdvance(elementIndex, propertyBinding.span, Identifiers.property, propertyBinding.paramsOrFn);
17431
17494
  }
17432
- if (attributeBindings.length > 0) {
17433
- this.updateInstructionChainWithAdvance(elementIndex, Identifiers.attribute, attributeBindings);
17495
+ for (const attributeBinding of attributeBindings) {
17496
+ this.updateInstructionWithAdvance(elementIndex, attributeBinding.span, Identifiers.attribute, attributeBinding.paramsOrFn);
17434
17497
  }
17435
17498
  // Traverse element child nodes
17436
17499
  visitAll$1(this, element.children);
@@ -17509,12 +17572,8 @@ class TemplateDefinitionBuilder {
17509
17572
  this.templatePropertyBindings(templateIndex, inputs);
17510
17573
  }
17511
17574
  // Generate listeners for directive output
17512
- if (template.outputs.length > 0) {
17513
- const listeners = template.outputs.map((outputAst) => ({
17514
- sourceSpan: outputAst.sourceSpan,
17515
- params: this.prepareListenerParameter('ng_template', outputAst, templateIndex)
17516
- }));
17517
- this.creationInstructionChain(Identifiers.listener, listeners);
17575
+ for (const outputAst of template.outputs) {
17576
+ this.creationInstruction(outputAst.sourceSpan, Identifiers.listener, this.prepareListenerParameter('ng_template', outputAst, templateIndex));
17518
17577
  }
17519
17578
  }
17520
17579
  }
@@ -17569,7 +17628,7 @@ class TemplateDefinitionBuilder {
17569
17628
  const transformFn = (raw) => {
17570
17629
  const params = { ...vars, ...placeholders };
17571
17630
  const formatted = i18nFormatPlaceholderNames(params, /* useCamelCase */ false);
17572
- return instruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
17631
+ return invokeInstruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
17573
17632
  };
17574
17633
  // in case the whole i18n message is a single ICU - we do not need to
17575
17634
  // create a separate top-level translation, we can use the root ref instead
@@ -17611,32 +17670,33 @@ class TemplateDefinitionBuilder {
17611
17670
  }
17612
17671
  templatePropertyBindings(templateIndex, attrs) {
17613
17672
  const propertyBindings = [];
17614
- attrs.forEach(input => {
17615
- if (input instanceof BoundAttribute) {
17616
- const value = input.value.visit(this._valueConverter);
17617
- if (value !== undefined) {
17618
- this.allocateBindingSlots(value);
17619
- if (value instanceof Interpolation) {
17620
- // Params typically contain attribute namespace and value sanitizer, which is applicable
17621
- // for regular HTML elements, but not applicable for <ng-template> (since props act as
17622
- // inputs to directives), so keep params array empty.
17623
- const params = [];
17624
- // prop="{{value}}" case
17625
- this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value), templateIndex, input.name, input, value, params);
17626
- }
17627
- else {
17628
- // [prop]="value" case
17629
- propertyBindings.push({
17630
- name: input.name,
17631
- sourceSpan: input.sourceSpan,
17632
- value: () => this.convertPropertyBinding(value)
17633
- });
17634
- }
17635
- }
17673
+ for (const input of attrs) {
17674
+ if (!(input instanceof BoundAttribute)) {
17675
+ continue;
17676
+ }
17677
+ const value = input.value.visit(this._valueConverter);
17678
+ if (value === undefined) {
17679
+ continue;
17680
+ }
17681
+ this.allocateBindingSlots(value);
17682
+ if (value instanceof Interpolation) {
17683
+ // Params typically contain attribute namespace and value sanitizer, which is applicable
17684
+ // for regular HTML elements, but not applicable for <ng-template> (since props act as
17685
+ // inputs to directives), so keep params array empty.
17686
+ const params = [];
17687
+ // prop="{{value}}" case
17688
+ this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value), templateIndex, input.name, input, value, params);
17689
+ }
17690
+ else {
17691
+ // [prop]="value" case
17692
+ propertyBindings.push({
17693
+ span: input.sourceSpan,
17694
+ paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(value), input.name)
17695
+ });
17636
17696
  }
17637
- });
17638
- if (propertyBindings.length > 0) {
17639
- this.updateInstructionChainWithAdvance(templateIndex, Identifiers.property, propertyBindings);
17697
+ }
17698
+ for (const propertyBinding of propertyBindings) {
17699
+ this.updateInstructionWithAdvance(templateIndex, propertyBinding.span, Identifiers.property, propertyBinding.paramsOrFn);
17640
17700
  }
17641
17701
  }
17642
17702
  // Bindings must only be resolved after all local refs have been visited, so all
@@ -17644,39 +17704,23 @@ class TemplateDefinitionBuilder {
17644
17704
  // Otherwise, we wouldn't be able to support local refs that are defined after their
17645
17705
  // bindings. e.g. {{ foo }} <div #foo></div>
17646
17706
  instructionFn(fns, span, reference, paramsOrFn, prepend = false) {
17647
- fns[prepend ? 'unshift' : 'push'](() => {
17648
- const params = Array.isArray(paramsOrFn) ? paramsOrFn : paramsOrFn();
17649
- return instruction(span, reference, params).toStmt();
17650
- });
17707
+ fns[prepend ? 'unshift' : 'push']({ span, reference, paramsOrFn });
17651
17708
  }
17652
17709
  processStylingUpdateInstruction(elementIndex, instruction) {
17653
17710
  let allocateBindingSlots = 0;
17654
17711
  if (instruction) {
17655
- const calls = [];
17656
- instruction.calls.forEach(call => {
17712
+ for (const call of instruction.calls) {
17657
17713
  allocateBindingSlots += call.allocateBindingSlots;
17658
- calls.push({
17659
- sourceSpan: call.sourceSpan,
17660
- value: () => {
17661
- return call.params(value => (call.supportsInterpolation && value instanceof Interpolation) ?
17662
- this.getUpdateInstructionArguments(value) :
17663
- this.convertPropertyBinding(value));
17664
- }
17665
- });
17666
- });
17667
- this.updateInstructionChainWithAdvance(elementIndex, instruction.reference, calls);
17714
+ this.updateInstructionWithAdvance(elementIndex, call.sourceSpan, instruction.reference, () => call.params(value => (call.supportsInterpolation && value instanceof Interpolation) ?
17715
+ this.getUpdateInstructionArguments(value) :
17716
+ this.convertPropertyBinding(value)));
17717
+ }
17668
17718
  }
17669
17719
  return allocateBindingSlots;
17670
17720
  }
17671
17721
  creationInstruction(span, reference, paramsOrFn, prepend) {
17672
17722
  this.instructionFn(this._creationCodeFns, span, reference, paramsOrFn || [], prepend);
17673
17723
  }
17674
- creationInstructionChain(reference, calls) {
17675
- const span = calls.length ? calls[0].sourceSpan : null;
17676
- this._creationCodeFns.push(() => {
17677
- return chainedInstruction(reference, calls.map(call => call.params()), span).toStmt();
17678
- });
17679
- }
17680
17724
  updateInstructionWithAdvance(nodeIndex, span, reference, paramsOrFn) {
17681
17725
  this.addAdvanceInstructionIfNecessary(nodeIndex, span);
17682
17726
  this.updateInstruction(span, reference, paramsOrFn);
@@ -17684,28 +17728,6 @@ class TemplateDefinitionBuilder {
17684
17728
  updateInstruction(span, reference, paramsOrFn) {
17685
17729
  this.instructionFn(this._updateCodeFns, span, reference, paramsOrFn || []);
17686
17730
  }
17687
- updateInstructionChain(reference, bindings) {
17688
- const span = bindings.length ? bindings[0].sourceSpan : null;
17689
- this._updateCodeFns.push(() => {
17690
- const calls = bindings.map(property => {
17691
- const value = property.value();
17692
- const fnParams = Array.isArray(value) ? value : [value];
17693
- if (property.params) {
17694
- fnParams.push(...property.params);
17695
- }
17696
- if (property.name) {
17697
- // We want the property name to always be the first function parameter.
17698
- fnParams.unshift(literal(property.name));
17699
- }
17700
- return fnParams;
17701
- });
17702
- return chainedInstruction(reference, calls, span).toStmt();
17703
- });
17704
- }
17705
- updateInstructionChainWithAdvance(nodeIndex, reference, bindings) {
17706
- this.addAdvanceInstructionIfNecessary(nodeIndex, bindings.length ? bindings[0].sourceSpan : null);
17707
- this.updateInstructionChain(reference, bindings);
17708
- }
17709
17731
  addAdvanceInstructionIfNecessary(nodeIndex, span) {
17710
17732
  if (nodeIndex !== this._currentIndex) {
17711
17733
  const delta = nodeIndex - this._currentIndex;
@@ -17991,9 +18013,6 @@ function pureFunctionCallInfo(args) {
17991
18013
  isVarLength: !identifier,
17992
18014
  };
17993
18015
  }
17994
- function instruction(span, reference, params) {
17995
- return importExpr(reference, null, span).callFn(params, span);
17996
- }
17997
18016
  // e.g. x(2);
17998
18017
  function generateNextContextExpr(relativeLevelDiff) {
17999
18018
  return importExpr(Identifiers.nextContext)
@@ -18198,7 +18217,7 @@ class BindingScope {
18198
18217
  restoreViewStatement() {
18199
18218
  const statements = [];
18200
18219
  if (this.restoreViewVariable) {
18201
- const restoreCall = instruction(null, Identifiers.restoreView, [this.restoreViewVariable]);
18220
+ const restoreCall = invokeInstruction(null, Identifiers.restoreView, [this.restoreViewVariable]);
18202
18221
  // Either `const restoredCtx = restoreView($state$);` or `restoreView($state$);`
18203
18222
  // depending on whether it is being used.
18204
18223
  statements.push(this.usesRestoredViewContext ?
@@ -18210,7 +18229,9 @@ class BindingScope {
18210
18229
  viewSnapshotStatements() {
18211
18230
  // const $state$ = getCurrentView();
18212
18231
  return this.restoreViewVariable ?
18213
- [this.restoreViewVariable.set(instruction(null, Identifiers.getCurrentView, [])).toConstDecl()] :
18232
+ [
18233
+ this.restoreViewVariable.set(invokeInstruction(null, Identifiers.getCurrentView, [])).toConstDecl()
18234
+ ] :
18214
18235
  [];
18215
18236
  }
18216
18237
  isListenerScope() {
@@ -18483,6 +18504,20 @@ function isTextNode(node) {
18483
18504
  function hasTextChildrenOnly(children) {
18484
18505
  return children.every(isTextNode);
18485
18506
  }
18507
+ function getBindingFunctionParams(deferredParams, name, eagerParams) {
18508
+ return () => {
18509
+ const value = deferredParams();
18510
+ const fnParams = Array.isArray(value) ? value : [value];
18511
+ if (eagerParams) {
18512
+ fnParams.push(...eagerParams);
18513
+ }
18514
+ if (name) {
18515
+ // We want the property name to always be the first function parameter.
18516
+ fnParams.unshift(literal(name));
18517
+ }
18518
+ return fnParams;
18519
+ };
18520
+ }
18486
18521
  /** Name of the global variable that is used to determine if we use Closure translations or not */
18487
18522
  const NG_I18N_CLOSURE_MODE = 'ngI18nClosureMode';
18488
18523
  /**
@@ -18864,14 +18899,14 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
18864
18899
  if (classAttr !== undefined) {
18865
18900
  styleBuilder.registerClassAttr(classAttr);
18866
18901
  }
18867
- const createStatements = [];
18868
- const updateStatements = [];
18902
+ const createInstructions = [];
18903
+ const updateInstructions = [];
18904
+ const updateVariables = [];
18869
18905
  const hostBindingSourceSpan = typeSourceSpan;
18870
18906
  // Calculate host event bindings
18871
18907
  const eventBindings = bindingParser.createDirectiveHostEventAsts(hostBindingsMetadata.listeners, hostBindingSourceSpan);
18872
18908
  if (eventBindings && eventBindings.length) {
18873
- const listeners = createHostListeners(eventBindings, name);
18874
- createStatements.push(...listeners);
18909
+ createInstructions.push(...createHostListeners(eventBindings, name));
18875
18910
  }
18876
18911
  // Calculate the host property bindings
18877
18912
  const bindings = bindingParser.createBoundHostProperties(hostBindingsMetadata.properties, hostBindingSourceSpan);
@@ -18907,7 +18942,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
18907
18942
  const propertyBindings = [];
18908
18943
  const attributeBindings = [];
18909
18944
  const syntheticHostBindings = [];
18910
- allOtherBindings.forEach((binding) => {
18945
+ for (const binding of allOtherBindings) {
18911
18946
  // resolve literal arrays and literal objects
18912
18947
  const value = binding.expression.visit(getValueConverter());
18913
18948
  const bindingExpr = bindingFn(bindingContext, value);
@@ -18933,7 +18968,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
18933
18968
  if (sanitizerFn) {
18934
18969
  instructionParams.push(sanitizerFn);
18935
18970
  }
18936
- updateStatements.push(...bindingExpr.stmts);
18971
+ updateVariables.push(...bindingExpr.stmts);
18937
18972
  if (instruction === Identifiers.hostProperty) {
18938
18973
  propertyBindings.push(instructionParams);
18939
18974
  }
@@ -18944,17 +18979,17 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
18944
18979
  syntheticHostBindings.push(instructionParams);
18945
18980
  }
18946
18981
  else {
18947
- updateStatements.push(importExpr(instruction).callFn(instructionParams).toStmt());
18982
+ updateInstructions.push({ reference: instruction, paramsOrFn: instructionParams, span: null });
18948
18983
  }
18949
- });
18950
- if (propertyBindings.length > 0) {
18951
- updateStatements.push(chainedInstruction(Identifiers.hostProperty, propertyBindings).toStmt());
18952
18984
  }
18953
- if (attributeBindings.length > 0) {
18954
- updateStatements.push(chainedInstruction(Identifiers.attribute, attributeBindings).toStmt());
18985
+ for (const bindingParams of propertyBindings) {
18986
+ updateInstructions.push({ reference: Identifiers.hostProperty, paramsOrFn: bindingParams, span: null });
18987
+ }
18988
+ for (const bindingParams of attributeBindings) {
18989
+ updateInstructions.push({ reference: Identifiers.attribute, paramsOrFn: bindingParams, span: null });
18955
18990
  }
18956
- if (syntheticHostBindings.length > 0) {
18957
- updateStatements.push(chainedInstruction(Identifiers.syntheticHostProperty, syntheticHostBindings).toStmt());
18991
+ for (const bindingParams of syntheticHostBindings) {
18992
+ updateInstructions.push({ reference: Identifiers.syntheticHostProperty, paramsOrFn: bindingParams, span: null });
18958
18993
  }
18959
18994
  // since we're dealing with directives/components and both have hostBinding
18960
18995
  // functions, we need to generate a special hostAttrs instruction that deals
@@ -18970,30 +19005,30 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
18970
19005
  // the update block of a component/directive templateFn/hostBindingsFn so that the bindings
18971
19006
  // are evaluated and updated for the element.
18972
19007
  styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach(instruction => {
18973
- if (instruction.calls.length > 0) {
18974
- const calls = [];
18975
- instruction.calls.forEach(call => {
18976
- // we subtract a value of `1` here because the binding slot was already allocated
18977
- // at the top of this method when all the input bindings were counted.
18978
- totalHostVarsCount +=
18979
- Math.max(call.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
18980
- calls.push(convertStylingCall(call, bindingContext, bindingFn));
19008
+ for (const call of instruction.calls) {
19009
+ // we subtract a value of `1` here because the binding slot was already allocated
19010
+ // at the top of this method when all the input bindings were counted.
19011
+ totalHostVarsCount +=
19012
+ Math.max(call.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
19013
+ updateInstructions.push({
19014
+ reference: instruction.reference,
19015
+ paramsOrFn: convertStylingCall(call, bindingContext, bindingFn),
19016
+ span: null
18981
19017
  });
18982
- updateStatements.push(chainedInstruction(instruction.reference, calls).toStmt());
18983
19018
  }
18984
19019
  });
18985
19020
  }
18986
19021
  if (totalHostVarsCount) {
18987
19022
  definitionMap.set('hostVars', literal(totalHostVarsCount));
18988
19023
  }
18989
- if (createStatements.length > 0 || updateStatements.length > 0) {
19024
+ if (createInstructions.length > 0 || updateInstructions.length > 0) {
18990
19025
  const hostBindingsFnName = name ? `${name}_HostBindings` : null;
18991
19026
  const statements = [];
18992
- if (createStatements.length > 0) {
18993
- statements.push(renderFlagCheckIfStmt(1 /* Create */, createStatements));
19027
+ if (createInstructions.length > 0) {
19028
+ statements.push(renderFlagCheckIfStmt(1 /* Create */, getInstructionStatements(createInstructions)));
18994
19029
  }
18995
- if (updateStatements.length > 0) {
18996
- statements.push(renderFlagCheckIfStmt(2 /* Update */, updateStatements));
19030
+ if (updateInstructions.length > 0) {
19031
+ statements.push(renderFlagCheckIfStmt(2 /* Update */, updateVariables.concat(getInstructionStatements(updateInstructions))));
18997
19032
  }
18998
19033
  return fn([new FnParam(RENDER_FLAGS, NUMBER_TYPE), new FnParam(CONTEXT_NAME, null)], statements, INFERRED_TYPE, null, hostBindingsFnName);
18999
19034
  }
@@ -19029,10 +19064,10 @@ function getBindingNameAndInstruction(binding) {
19029
19064
  return { bindingName, instruction, isAttribute: !!attrMatches };
19030
19065
  }
19031
19066
  function createHostListeners(eventBindings, name) {
19032
- const listeners = [];
19033
- const syntheticListeners = [];
19067
+ const listenerParams = [];
19068
+ const syntheticListenerParams = [];
19034
19069
  const instructions = [];
19035
- eventBindings.forEach(binding => {
19070
+ for (const binding of eventBindings) {
19036
19071
  let bindingName = binding.name && sanitizeIdentifier(binding.name);
19037
19072
  const bindingFnName = binding.type === 1 /* Animation */ ?
19038
19073
  prepareSyntheticListenerFunctionName(bindingName, binding.targetOrPhase) :
@@ -19040,17 +19075,17 @@ function createHostListeners(eventBindings, name) {
19040
19075
  const handlerName = name && bindingName ? `${name}_${bindingFnName}_HostBindingHandler` : null;
19041
19076
  const params = prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding), handlerName);
19042
19077
  if (binding.type == 1 /* Animation */) {
19043
- syntheticListeners.push(params);
19078
+ syntheticListenerParams.push(params);
19044
19079
  }
19045
19080
  else {
19046
- listeners.push(params);
19081
+ listenerParams.push(params);
19047
19082
  }
19048
- });
19049
- if (syntheticListeners.length > 0) {
19050
- instructions.push(chainedInstruction(Identifiers.syntheticHostListener, syntheticListeners).toStmt());
19051
19083
  }
19052
- if (listeners.length > 0) {
19053
- instructions.push(chainedInstruction(Identifiers.listener, listeners).toStmt());
19084
+ for (const params of syntheticListenerParams) {
19085
+ instructions.push({ reference: Identifiers.syntheticHostListener, paramsOrFn: params, span: null });
19086
+ }
19087
+ for (const params of listenerParams) {
19088
+ instructions.push({ reference: Identifiers.listener, paramsOrFn: params, span: null });
19054
19089
  }
19055
19090
  return instructions;
19056
19091
  }
@@ -19641,7 +19676,7 @@ function publishFacade(global) {
19641
19676
  * Use of this source code is governed by an MIT-style license that can be
19642
19677
  * found in the LICENSE file at https://angular.io/license
19643
19678
  */
19644
- const VERSION = new Version('14.0.0-next.2');
19679
+ const VERSION = new Version('14.0.0-next.5');
19645
19680
 
19646
19681
  /**
19647
19682
  * @license
@@ -21682,7 +21717,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
21682
21717
  function compileDeclareClassMetadata(metadata) {
21683
21718
  const definitionMap = new DefinitionMap();
21684
21719
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
21685
- definitionMap.set('version', literal('14.0.0-next.2'));
21720
+ definitionMap.set('version', literal('14.0.0-next.5'));
21686
21721
  definitionMap.set('ngImport', importExpr(Identifiers.core));
21687
21722
  definitionMap.set('type', metadata.type);
21688
21723
  definitionMap.set('decorators', metadata.decorators);
@@ -21799,7 +21834,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
21799
21834
  function createDirectiveDefinitionMap(meta) {
21800
21835
  const definitionMap = new DefinitionMap();
21801
21836
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
21802
- definitionMap.set('version', literal('14.0.0-next.2'));
21837
+ definitionMap.set('version', literal('14.0.0-next.5'));
21803
21838
  // e.g. `type: MyDirective`
21804
21839
  definitionMap.set('type', meta.internalType);
21805
21840
  // e.g. `selector: 'some-dir'`
@@ -22020,7 +22055,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
22020
22055
  function compileDeclareFactoryFunction(meta) {
22021
22056
  const definitionMap = new DefinitionMap();
22022
22057
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
22023
- definitionMap.set('version', literal('14.0.0-next.2'));
22058
+ definitionMap.set('version', literal('14.0.0-next.5'));
22024
22059
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22025
22060
  definitionMap.set('type', meta.internalType);
22026
22061
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -22062,7 +22097,7 @@ function compileDeclareInjectableFromMetadata(meta) {
22062
22097
  function createInjectableDefinitionMap(meta) {
22063
22098
  const definitionMap = new DefinitionMap();
22064
22099
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
22065
- definitionMap.set('version', literal('14.0.0-next.2'));
22100
+ definitionMap.set('version', literal('14.0.0-next.5'));
22066
22101
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22067
22102
  definitionMap.set('type', meta.internalType);
22068
22103
  // Only generate providedIn property if it has a non-null value
@@ -22120,7 +22155,7 @@ function compileDeclareInjectorFromMetadata(meta) {
22120
22155
  function createInjectorDefinitionMap(meta) {
22121
22156
  const definitionMap = new DefinitionMap();
22122
22157
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
22123
- definitionMap.set('version', literal('14.0.0-next.2'));
22158
+ definitionMap.set('version', literal('14.0.0-next.5'));
22124
22159
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22125
22160
  definitionMap.set('type', meta.internalType);
22126
22161
  definitionMap.set('providers', meta.providers);
@@ -22157,7 +22192,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
22157
22192
  function createNgModuleDefinitionMap(meta) {
22158
22193
  const definitionMap = new DefinitionMap();
22159
22194
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
22160
- definitionMap.set('version', literal('14.0.0-next.2'));
22195
+ definitionMap.set('version', literal('14.0.0-next.5'));
22161
22196
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22162
22197
  definitionMap.set('type', meta.internalType);
22163
22198
  // We only generate the keys in the metadata if the arrays contain values.
@@ -22215,7 +22250,7 @@ function compileDeclarePipeFromMetadata(meta) {
22215
22250
  function createPipeDefinitionMap(meta) {
22216
22251
  const definitionMap = new DefinitionMap();
22217
22252
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
22218
- definitionMap.set('version', literal('14.0.0-next.2'));
22253
+ definitionMap.set('version', literal('14.0.0-next.5'));
22219
22254
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22220
22255
  // e.g. `type: MyPipe`
22221
22256
  definitionMap.set('type', meta.internalType);