@angular/core 16.1.0-next.1 → 16.1.0-next.2

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.1.0-next.1
2
+ * @license Angular v16.1.0-next.2
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.1.0-next.1
2
+ * @license Angular v16.1.0-next.2
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) {
@@ -5686,7 +5713,10 @@ function getOrCreateInjectable(tNode, lView, token, flags = InjectFlags.Default,
5686
5713
  if (tNode !== null) {
5687
5714
  // If the view or any of its ancestors have an embedded
5688
5715
  // view injector, we have to look it up there first.
5689
- if (lView[FLAGS] & 2048 /* LViewFlags.HasEmbeddedViewInjector */) {
5716
+ if (lView[FLAGS] & 2048 /* LViewFlags.HasEmbeddedViewInjector */ &&
5717
+ // The token must be present on the current node injector when the `Self`
5718
+ // flag is set, so the lookup on embedded view injector(s) can be skipped.
5719
+ !(flags & InjectFlags.Self)) {
5690
5720
  const embeddedInjectorValue = lookupTokenUsingEmbeddedInjector(tNode, lView, token, flags, NOT_FOUND);
5691
5721
  if (embeddedInjectorValue !== NOT_FOUND) {
5692
5722
  return embeddedInjectorValue;
@@ -10437,7 +10467,7 @@ class Version {
10437
10467
  /**
10438
10468
  * @publicApi
10439
10469
  */
10440
- const VERSION = new Version('16.1.0-next.1');
10470
+ const VERSION = new Version('16.1.0-next.2');
10441
10471
 
10442
10472
  // This default value is when checking the hierarchy for a token.
10443
10473
  //
@@ -10579,6 +10609,10 @@ function normalizeDebugBindingValue(value) {
10579
10609
  }
10580
10610
  }
10581
10611
 
10612
+ /**
10613
+ * The max length of the string representation of a value in an error message
10614
+ */
10615
+ const VALUE_STRING_LENGTH_LIMIT = 200;
10582
10616
  /** Verifies that a given type is a Standalone Component. */
10583
10617
  function assertStandaloneComponentType(type) {
10584
10618
  assertComponentDef(type);
@@ -10608,7 +10642,7 @@ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName,
10608
10642
  const hostComponentDef = getDeclarationComponentDef(lView);
10609
10643
  const componentClassName = hostComponentDef?.type?.name;
10610
10644
  const field = propName ? ` for '${propName}'` : '';
10611
- let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${oldValue}'. Current value: '${currValue}'.${componentClassName ? ` Expression location: ${componentClassName} component` : ''}`;
10645
+ let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${formatValue(oldValue)}'. Current value: '${formatValue(currValue)}'.${componentClassName ? ` Expression location: ${componentClassName} component` : ''}`;
10612
10646
  if (creationMode) {
10613
10647
  msg +=
10614
10648
  ` It seems like the view has been created after its parent and its children have been dirty checked.` +
@@ -10616,6 +10650,20 @@ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName,
10616
10650
  }
10617
10651
  throw new RuntimeError(-100 /* RuntimeErrorCode.EXPRESSION_CHANGED_AFTER_CHECKED */, msg);
10618
10652
  }
10653
+ function formatValue(value) {
10654
+ let strValue = String(value);
10655
+ // JSON.stringify will throw on circular references
10656
+ try {
10657
+ if (Array.isArray(value) || strValue === '[object Object]') {
10658
+ strValue = JSON.stringify(value);
10659
+ }
10660
+ }
10661
+ catch (error) {
10662
+ }
10663
+ return strValue.length > VALUE_STRING_LENGTH_LIMIT ?
10664
+ (strValue.substring(0, VALUE_STRING_LENGTH_LIMIT) + '…') :
10665
+ strValue;
10666
+ }
10619
10667
  function constructDetailsForInterpolation(lView, rootIndex, expressionIndex, meta, changedValue) {
10620
10668
  const [propName, prefix, ...chunks] = meta.split(INTERPOLATION_DELIMITER);
10621
10669
  let oldValue = prefix, newValue = prefix;
@@ -13953,7 +14001,7 @@ function validateMappings(bindingType, def, hostDirectiveBindings) {
13953
14001
  throw new RuntimeError(311 /* RuntimeErrorCode.HOST_DIRECTIVE_UNDEFINED_BINDING */, `Directive ${className} does not have an ${bindingType} with a public name of ${publicName}.`);
13954
14002
  }
13955
14003
  const remappedPublicName = hostDirectiveBindings[publicName];
13956
- if (bindings.hasOwnProperty(remappedPublicName) &&
14004
+ if (bindings.hasOwnProperty(remappedPublicName) && remappedPublicName !== publicName &&
13957
14005
  bindings[remappedPublicName] !== publicName) {
13958
14006
  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.`);
13959
14007
  }
@@ -13961,6 +14009,12 @@ function validateMappings(bindingType, def, hostDirectiveBindings) {
13961
14009
  }
13962
14010
  }
13963
14011
 
14012
+ // TODO(crisbeto): move input transforms runtime functionality here.
14013
+ /**
14014
+ * @codeGenApi
14015
+ */
14016
+ function ɵɵInputTransformsFeature(definition) { }
14017
+
13964
14018
  function isIterable(obj) {
13965
14019
  return obj !== null && typeof obj === 'object' && obj[Symbol.iterator] !== undefined;
13966
14020
  }
@@ -24285,6 +24339,7 @@ const angularCoreEnv = (() => ({
24285
24339
  'ɵɵProvidersFeature': ɵɵProvidersFeature,
24286
24340
  'ɵɵCopyDefinitionFeature': ɵɵCopyDefinitionFeature,
24287
24341
  'ɵɵInheritDefinitionFeature': ɵɵInheritDefinitionFeature,
24342
+ 'ɵɵInputTransformsFeature': ɵɵInputTransformsFeature,
24288
24343
  'ɵɵStandaloneFeature': ɵɵStandaloneFeature,
24289
24344
  'ɵɵnextContext': ɵɵnextContext,
24290
24345
  'ɵɵnamespaceHTML': ɵɵnamespaceHTML,
@@ -24760,16 +24815,16 @@ function computeCombinedExports(type) {
24760
24815
  if (ngModuleDef === null) {
24761
24816
  return [type];
24762
24817
  }
24763
- return [...flatten$1(maybeUnwrapFn$1(ngModuleDef.exports).map((type) => {
24764
- const ngModuleDef = getNgModuleDef(type);
24765
- if (ngModuleDef) {
24766
- verifySemanticsOfNgModuleDef(type, false);
24767
- return computeCombinedExports(type);
24768
- }
24769
- else {
24770
- return type;
24771
- }
24772
- }))];
24818
+ return flatten$1(maybeUnwrapFn$1(ngModuleDef.exports).map((type) => {
24819
+ const ngModuleDef = getNgModuleDef(type);
24820
+ if (ngModuleDef) {
24821
+ verifySemanticsOfNgModuleDef(type, false);
24822
+ return computeCombinedExports(type);
24823
+ }
24824
+ else {
24825
+ return type;
24826
+ }
24827
+ }));
24773
24828
  }
24774
24829
  /**
24775
24830
  * Some declared components may be compiled asynchronously, and thus may not have their