@angular/core 16.0.2 → 16.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.0.2
2
+ * @license Angular v16.0.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.0.2
2
+ * @license Angular v16.0.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -656,9 +656,36 @@ const __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafe
656
656
  * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
657
657
  * a query is not yet defined.
658
658
  *
659
+ * `forwardRef` is also used to break circularities in standalone components imports.
660
+ *
659
661
  * @usageNotes
660
- * ### Example
662
+ * ### Circular dependency example
661
663
  * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
664
+ *
665
+ * ### Circular standalone reference import example
666
+ * ```ts
667
+ * @Component({
668
+ * standalone: true,
669
+ * imports: [ChildComponent],
670
+ * selector: 'app-parent',
671
+ * template: `<app-child [hideParent]="hideParent"></app-child>`,
672
+ * })
673
+ * export class ParentComponent {
674
+ * @Input() hideParent: boolean;
675
+ * }
676
+ *
677
+ *
678
+ * @Component({
679
+ * standalone: true,
680
+ * imports: [CommonModule, forwardRef(() => ParentComponent)],
681
+ * selector: 'app-child',
682
+ * template: `<app-parent *ngIf="!hideParent"></app-parent>`,
683
+ * })
684
+ * export class ChildComponent {
685
+ * @Input() hideParent: boolean;
686
+ * }
687
+ * ```
688
+ *
662
689
  * @publicApi
663
690
  */
664
691
  function forwardRef(forwardRefFn) {
@@ -5683,7 +5710,10 @@ function getOrCreateInjectable(tNode, lView, token, flags = InjectFlags.Default,
5683
5710
  if (tNode !== null) {
5684
5711
  // If the view or any of its ancestors have an embedded
5685
5712
  // view injector, we have to look it up there first.
5686
- if (lView[FLAGS] & 2048 /* LViewFlags.HasEmbeddedViewInjector */) {
5713
+ if (lView[FLAGS] & 2048 /* LViewFlags.HasEmbeddedViewInjector */ &&
5714
+ // The token must be present on the current node injector when the `Self`
5715
+ // flag is set, so the lookup on embedded view injector(s) can be skipped.
5716
+ !(flags & InjectFlags.Self)) {
5687
5717
  const embeddedInjectorValue = lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, NOT_FOUND);
5688
5718
  if (embeddedInjectorValue !== NOT_FOUND) {
5689
5719
  return embeddedInjectorValue;
@@ -10434,7 +10464,7 @@ class Version {
10434
10464
  /**
10435
10465
  * @publicApi
10436
10466
  */
10437
- const VERSION = new Version('16.0.2');
10467
+ const VERSION = new Version('16.0.3');
10438
10468
 
10439
10469
  // This default value is when checking the hierarchy for a token.
10440
10470
  //
@@ -10576,6 +10606,10 @@ function normalizeDebugBindingValue(value) {
10576
10606
  }
10577
10607
  }
10578
10608
 
10609
+ /**
10610
+ * The max length of the string representation of a value in an error message
10611
+ */
10612
+ const VALUE_STRING_LENGTH_LIMIT = 200;
10579
10613
  /** Verifies that a given type is a Standalone Component. */
10580
10614
  function assertStandaloneComponentType(type) {
10581
10615
  assertComponentDef(type);
@@ -10605,7 +10639,7 @@ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName,
10605
10639
  const hostComponentDef = getDeclarationComponentDef(lView);
10606
10640
  const componentClassName = hostComponentDef?.type?.name;
10607
10641
  const field = propName ? ` for '${propName}'` : '';
10608
- let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${oldValue}'. Current value: '${currValue}'.${componentClassName ? ` Expression location: ${componentClassName} component` : ''}`;
10642
+ let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${formatValue(oldValue)}'. Current value: '${formatValue(currValue)}'.${componentClassName ? ` Expression location: ${componentClassName} component` : ''}`;
10609
10643
  if (creationMode) {
10610
10644
  msg +=
10611
10645
  ` It seems like the view has been created after its parent and its children have been dirty checked.` +
@@ -10613,6 +10647,20 @@ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName,
10613
10647
  }
10614
10648
  throw new RuntimeError(-100 /* RuntimeErrorCode.EXPRESSION_CHANGED_AFTER_CHECKED */, msg);
10615
10649
  }
10650
+ function formatValue(value) {
10651
+ let strValue = String(value);
10652
+ // JSON.stringify will throw on circular references
10653
+ try {
10654
+ if (Array.isArray(value) || strValue === '[object Object]') {
10655
+ strValue = JSON.stringify(value);
10656
+ }
10657
+ }
10658
+ catch (error) {
10659
+ }
10660
+ return strValue.length > VALUE_STRING_LENGTH_LIMIT ?
10661
+ (strValue.substring(0, VALUE_STRING_LENGTH_LIMIT) + '…') :
10662
+ strValue;
10663
+ }
10616
10664
  function constructDetailsForInterpolation(lView, rootIndex, expressionIndex, meta, changedValue) {
10617
10665
  const [propName, prefix, ...chunks] = meta.split(INTERPOLATION_DELIMITER);
10618
10666
  let oldValue = prefix, newValue = prefix;
@@ -13948,7 +13996,7 @@ function validateMappings(bindingType, def, hostDirectiveBindings) {
13948
13996
  throw new RuntimeError(311 /* RuntimeErrorCode.HOST_DIRECTIVE_UNDEFINED_BINDING */, `Directive ${className} does not have an ${bindingType} with a public name of ${publicName}.`);
13949
13997
  }
13950
13998
  const remappedPublicName = hostDirectiveBindings[publicName];
13951
- if (bindings.hasOwnProperty(remappedPublicName) &&
13999
+ if (bindings.hasOwnProperty(remappedPublicName) && remappedPublicName !== publicName &&
13952
14000
  bindings[remappedPublicName] !== publicName) {
13953
14001
  throw new RuntimeError(312 /* RuntimeErrorCode.HOST_DIRECTIVE_CONFLICTING_ALIAS */, `Cannot alias ${bindingType} ${publicName} of host directive ${className} to ${remappedPublicName}, because it already has a different ${bindingType} with the same public name.`);
13954
14002
  }
@@ -24752,16 +24800,16 @@ function computeCombinedExports(type) {
24752
24800
  if (ngModuleDef === null) {
24753
24801
  return [type];
24754
24802
  }
24755
- return [...flatten$1(maybeUnwrapFn$1(ngModuleDef.exports).map((type) => {
24756
- const ngModuleDef = getNgModuleDef(type);
24757
- if (ngModuleDef) {
24758
- verifySemanticsOfNgModuleDef(type, false);
24759
- return computeCombinedExports(type);
24760
- }
24761
- else {
24762
- return type;
24763
- }
24764
- }))];
24803
+ return flatten$1(maybeUnwrapFn$1(ngModuleDef.exports).map((type) => {
24804
+ const ngModuleDef = getNgModuleDef(type);
24805
+ if (ngModuleDef) {
24806
+ verifySemanticsOfNgModuleDef(type, false);
24807
+ return computeCombinedExports(type);
24808
+ }
24809
+ else {
24810
+ return type;
24811
+ }
24812
+ }));
24765
24813
  }
24766
24814
  /**
24767
24815
  * Some declared components may be compiled asynchronously, and thus may not have their