@angular/core 16.2.0-next.1 → 16.2.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.
Files changed (35) hide show
  1. package/esm2022/rxjs-interop/src/take_until_destroyed.mjs +3 -3
  2. package/esm2022/rxjs-interop/src/to_observable.mjs +1 -1
  3. package/esm2022/rxjs-interop/src/to_signal.mjs +1 -1
  4. package/esm2022/src/di/contextual.mjs +10 -7
  5. package/esm2022/src/di/injection_token.mjs +2 -2
  6. package/esm2022/src/di/injector_compatibility.mjs +4 -3
  7. package/esm2022/src/di/interface/defs.mjs +3 -2
  8. package/esm2022/src/di/interface/injector.mjs +2 -2
  9. package/esm2022/src/di/provider_collection.mjs +2 -2
  10. package/esm2022/src/di/r3_injector.mjs +1 -1
  11. package/esm2022/src/errors.mjs +1 -1
  12. package/esm2022/src/linker/template_ref.mjs +1 -1
  13. package/esm2022/src/render3/assert.mjs +8 -3
  14. package/esm2022/src/render3/features/standalone_feature.mjs +4 -4
  15. package/esm2022/src/render3/pipe.mjs +26 -2
  16. package/esm2022/src/render3/reactivity/effect.mjs +1 -1
  17. package/esm2022/src/signals/src/graph.mjs +7 -3
  18. package/esm2022/src/util/raf.mjs +20 -5
  19. package/esm2022/src/version.mjs +1 -1
  20. package/esm2022/src/zone/ng_zone.mjs +10 -1
  21. package/esm2022/testing/src/logger.mjs +3 -3
  22. package/fesm2022/core.mjs +87 -25
  23. package/fesm2022/core.mjs.map +1 -1
  24. package/fesm2022/rxjs-interop.mjs +9 -5
  25. package/fesm2022/rxjs-interop.mjs.map +1 -1
  26. package/fesm2022/testing.mjs +59 -21
  27. package/fesm2022/testing.mjs.map +1 -1
  28. package/index.d.ts +33 -18
  29. package/package.json +1 -1
  30. package/rxjs-interop/index.d.ts +15 -12
  31. package/schematics/migrations/guard-and-resolve-interfaces/bundle.js +13 -13
  32. package/schematics/migrations/remove-module-id/bundle.js +14 -14
  33. package/schematics/ng-generate/standalone-migration/bundle.js +1218 -578
  34. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  35. package/testing/index.d.ts +1 -1
package/fesm2022/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.2.0-next.1
2
+ * @license Angular v16.2.0-next.2
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -358,7 +358,8 @@ function assertOneOf(value, ...validValues) {
358
358
  * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
359
359
  * provided in the `'root'` injector, which will be the application-level injector in most apps.
360
360
  * * `factory` gives the zero argument function which will create an instance of the injectable.
361
- * The factory can call `inject` to access the `Injector` and request injection of dependencies.
361
+ * The factory can call [`inject`](api/core/inject) to access the `Injector` and request injection
362
+ * of dependencies.
362
363
  *
363
364
  * @codeGenApi
364
365
  * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
@@ -456,7 +457,7 @@ const NG_INJECTOR_DEF = getClosureSafeProperty({ ngInjectorDef: getClosureSafePr
456
457
  * Injection flags for DI.
457
458
  *
458
459
  * @publicApi
459
- * @deprecated use an options object for `inject` instead.
460
+ * @deprecated use an options object for [`inject`](api/core/inject) instead.
460
461
  */
461
462
  var InjectFlags;
462
463
  (function (InjectFlags) {
@@ -672,13 +673,14 @@ Please check that 1) the type for the parameter at index ${index} is correct and
672
673
  }
673
674
  /**
674
675
  * Injects a token from the currently active injector.
675
- * `inject` is only supported during instantiation of a dependency by the DI system. It can be used
676
- * during:
676
+ * `inject` is only supported in a [injection context](/guide/dependency-injection-context). It can
677
+ * be used during:
677
678
  * - Construction (via the `constructor`) of a class being instantiated by the DI system, such
678
679
  * as an `@Injectable` or `@Component`.
679
680
  * - In the initializer for fields of such classes.
680
681
  * - In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
681
682
  * - In the `factory` function specified for an `InjectionToken`.
683
+ * - In a stackframe of a function call in a DI context
682
684
  *
683
685
  * @param token A token that represents a dependency that should be injected.
684
686
  * @param flags Optional flags that control how injection is executed.
@@ -2086,8 +2088,13 @@ function assertTNodeForLView(tNode, lView) {
2086
2088
  }
2087
2089
  function assertTNodeForTView(tNode, tView) {
2088
2090
  assertTNode(tNode);
2089
- tNode.hasOwnProperty('tView_') &&
2090
- assertEqual(tNode.tView_, tView, 'This TNode does not belong to this TView.');
2091
+ const tData = tView.data;
2092
+ for (let i = HEADER_OFFSET; i < tData.length; i++) {
2093
+ if (tData[i] === tNode) {
2094
+ return;
2095
+ }
2096
+ }
2097
+ throwError('This TNode does not belong to this TView.');
2091
2098
  }
2092
2099
  function assertTNode(tNode) {
2093
2100
  assertDefined(tNode, 'TNode must be defined');
@@ -2348,7 +2355,9 @@ class ReactiveNode {
2348
2355
  consumerPollProducersForChange() {
2349
2356
  for (const [producerId, edge] of this.producers) {
2350
2357
  const producer = edge.producerNode.deref();
2351
- if (producer === undefined || edge.atTrackingVersion !== this.trackingVersion) {
2358
+ // On Safari < 16.1 deref can return null, we need to check for null also.
2359
+ // See https://github.com/WebKit/WebKit/commit/44c15ba58912faab38b534fef909dd9e13e095e0
2360
+ if (producer == null || edge.atTrackingVersion !== this.trackingVersion) {
2352
2361
  // This dependency edge is stale, so remove it.
2353
2362
  this.producers.delete(producerId);
2354
2363
  producer?.consumers.delete(this.id);
@@ -2373,7 +2382,9 @@ class ReactiveNode {
2373
2382
  try {
2374
2383
  for (const [consumerId, edge] of this.consumers) {
2375
2384
  const consumer = edge.consumerNode.deref();
2376
- if (consumer === undefined || consumer.trackingVersion !== edge.atTrackingVersion) {
2385
+ // On Safari < 16.1 deref can return null, we need to check for null also.
2386
+ // See https://github.com/WebKit/WebKit/commit/44c15ba58912faab38b534fef909dd9e13e095e0
2387
+ if (consumer == null || consumer.trackingVersion !== edge.atTrackingVersion) {
2377
2388
  this.consumers.delete(consumerId);
2378
2389
  consumer?.producers.delete(this.id);
2379
2390
  continue;
@@ -8669,7 +8680,7 @@ function getSanitizer() {
8669
8680
  * (possibly by creating) a default value of the parameterized type `T`. This sets up the
8670
8681
  * `InjectionToken` using this factory as a provider as if it was defined explicitly in the
8671
8682
  * application's root injector. If the factory function, which takes zero arguments, needs to inject
8672
- * dependencies, it can do so using the `inject` function.
8683
+ * dependencies, it can do so using the [`inject`](api/core/inject) function.
8673
8684
  * As you can see in the Tree-shakable InjectionToken example below.
8674
8685
  *
8675
8686
  * Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
@@ -8767,7 +8778,7 @@ class NullInjector {
8767
8778
 
8768
8779
  /**
8769
8780
  * Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
8770
- * referenced in `@Component in a component injector.
8781
+ * referenced in `@Component` in a component injector.
8771
8782
  */
8772
8783
  function makeEnvironmentProviders(providers) {
8773
8784
  return {
@@ -10089,7 +10100,7 @@ class Version {
10089
10100
  /**
10090
10101
  * @publicApi
10091
10102
  */
10092
- const VERSION = new Version('16.2.0-next.1');
10103
+ const VERSION = new Version('16.2.0-next.2');
10093
10104
 
10094
10105
  // This default value is when checking the hierarchy for a token.
10095
10106
  //
@@ -10513,13 +10524,15 @@ function selectIndexInternal(tView, lView, index, checkNoChangesMode) {
10513
10524
  }
10514
10525
 
10515
10526
  /**
10516
- * Runs the given function in the context of the given `Injector`.
10527
+ * Runs the given function in the [context](guide/dependency-injection-context) of the given
10528
+ * `Injector`.
10517
10529
  *
10518
- * Within the function's stack frame, `inject` can be used to inject dependencies from the given
10519
- * `Injector`. Note that `inject` is only usable synchronously, and cannot be used in any
10520
- * asynchronous callbacks or after any `await` points.
10530
+ * Within the function's stack frame, [`inject`](api/core/inject) can be used to inject dependencies
10531
+ * from the given `Injector`. Note that `inject` is only usable synchronously, and cannot be used in
10532
+ * any asynchronous callbacks or after any `await` points.
10521
10533
  *
10522
- * @param injector the injector which will satisfy calls to `inject` while `fn` is executing
10534
+ * @param injector the injector which will satisfy calls to [`inject`](api/core/inject) while `fn`
10535
+ * is executing
10523
10536
  * @param fn the closure to be run in the context of `injector`
10524
10537
  * @returns the return value of the function, if any
10525
10538
  * @publicApi
@@ -10539,7 +10552,8 @@ function runInInjectionContext(injector, fn) {
10539
10552
  }
10540
10553
  }
10541
10554
  /**
10542
- * Asserts that the current stack frame is within an injection context and has access to `inject`.
10555
+ * Asserts that the current stack frame is within an [injection
10556
+ * context](guide/dependency-injection-context) and has access to `inject`.
10543
10557
  *
10544
10558
  * @param debugFn a reference to the function making the assertion (used for the error message).
10545
10559
  *
@@ -21740,14 +21754,14 @@ class StandaloneService {
21740
21754
  if (!componentDef.standalone) {
21741
21755
  return null;
21742
21756
  }
21743
- if (!this.cachedInjectors.has(componentDef.id)) {
21757
+ if (!this.cachedInjectors.has(componentDef)) {
21744
21758
  const providers = internalImportProvidersFrom(false, componentDef.type);
21745
21759
  const standaloneInjector = providers.length > 0 ?
21746
21760
  createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
21747
21761
  null;
21748
- this.cachedInjectors.set(componentDef.id, standaloneInjector);
21762
+ this.cachedInjectors.set(componentDef, standaloneInjector);
21749
21763
  }
21750
- return this.cachedInjectors.get(componentDef.id);
21764
+ return this.cachedInjectors.get(componentDef);
21751
21765
  }
21752
21766
  ngOnDestroy() {
21753
21767
  try {
@@ -22596,6 +22610,13 @@ function ɵɵpipe(index, pipeName) {
22596
22610
  */
22597
22611
  function getPipeDef(name, registry) {
22598
22612
  if (registry) {
22613
+ if (ngDevMode) {
22614
+ const pipes = registry.filter(pipe => pipe.name === name);
22615
+ // TODO: Throw an error in the next major
22616
+ if (pipes.length > 1) {
22617
+ console.warn(formatRuntimeError(313 /* RuntimeErrorCode.MULTIPLE_MATCHING_PIPES */, getMultipleMatchingPipesMessage(name)));
22618
+ }
22619
+ }
22599
22620
  for (let i = registry.length - 1; i >= 0; i--) {
22600
22621
  const pipeDef = registry[i];
22601
22622
  if (name === pipeDef.name) {
@@ -22607,6 +22628,23 @@ function getPipeDef(name, registry) {
22607
22628
  throw new RuntimeError(-302 /* RuntimeErrorCode.PIPE_NOT_FOUND */, getPipeNotFoundErrorMessage(name));
22608
22629
  }
22609
22630
  }
22631
+ /**
22632
+ * Generates a helpful error message for the user when multiple pipes match the name.
22633
+ *
22634
+ * @param name Name of the pipe
22635
+ * @returns The error message
22636
+ */
22637
+ function getMultipleMatchingPipesMessage(name) {
22638
+ const lView = getLView();
22639
+ const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
22640
+ const context = declarationLView[CONTEXT];
22641
+ const hostIsStandalone = isHostComponentStandalone(lView);
22642
+ const componentInfoMessage = context ? ` in the '${context.constructor.name}' component` : '';
22643
+ const verifyMessage = `check ${hostIsStandalone ? '\'@Component.imports\' of this component' :
22644
+ 'the imports of this module'}`;
22645
+ const errorMessage = `Multiple pipes match the name \`${name}\`${componentInfoMessage}. ${verifyMessage}`;
22646
+ return errorMessage;
22647
+ }
22610
22648
  /**
22611
22649
  * Generates a helpful error message for the user when a pipe is not found.
22612
22650
  *
@@ -25913,11 +25951,26 @@ function noop(...args) {
25913
25951
  }
25914
25952
 
25915
25953
  function getNativeRequestAnimationFrame() {
25916
- let nativeRequestAnimationFrame = _global['requestAnimationFrame'];
25917
- let nativeCancelAnimationFrame = _global['cancelAnimationFrame'];
25954
+ // Note: the `getNativeRequestAnimationFrame` is used in the `NgZone` class, but we cannot use the
25955
+ // `inject` function. The `NgZone` instance may be created manually, and thus the injection
25956
+ // context will be unavailable. This might be enough to check whether `requestAnimationFrame` is
25957
+ // available because otherwise, we'll fall back to `setTimeout`.
25958
+ const isBrowser = typeof _global['requestAnimationFrame'] === 'function';
25959
+ // Note: `requestAnimationFrame` is unavailable when the code runs in the Node.js environment. We
25960
+ // use `setTimeout` because no changes are required other than checking if the current platform is
25961
+ // the browser. `setTimeout` is a well-established API that is available in both environments.
25962
+ // `requestAnimationFrame` is used in the browser to coalesce event tasks since event tasks are
25963
+ // usually executed within the same rendering frame (but this is more implementation details of
25964
+ // browsers).
25965
+ let nativeRequestAnimationFrame = _global[isBrowser ? 'requestAnimationFrame' : 'setTimeout'];
25966
+ let nativeCancelAnimationFrame = _global[isBrowser ? 'cancelAnimationFrame' : 'clearTimeout'];
25918
25967
  if (typeof Zone !== 'undefined' && nativeRequestAnimationFrame && nativeCancelAnimationFrame) {
25919
- // use unpatched version of requestAnimationFrame(native delegate) if possible
25920
- // to avoid another Change detection
25968
+ // Note: zone.js sets original implementations on patched APIs behind the
25969
+ // `__zone_symbol__OriginalDelegate` key (see `attachOriginToPatched`). Given the following
25970
+ // example: `window.requestAnimationFrame.__zone_symbol__OriginalDelegate`; this would return an
25971
+ // unpatched implementation of the `requestAnimationFrame`, which isn't intercepted by the
25972
+ // Angular zone. We use the unpatched implementation to avoid another change detection when
25973
+ // coalescing tasks.
25921
25974
  const unpatchedRequestAnimationFrame = nativeRequestAnimationFrame[Zone.__symbol__('OriginalDelegate')];
25922
25975
  if (unpatchedRequestAnimationFrame) {
25923
25976
  nativeRequestAnimationFrame = unpatchedRequestAnimationFrame;
@@ -26083,15 +26136,24 @@ class NgZone {
26083
26136
  self.nativeRequestAnimationFrame = getNativeRequestAnimationFrame().nativeRequestAnimationFrame;
26084
26137
  forkInnerZoneWithAngularBehavior(self);
26085
26138
  }
26139
+ /**
26140
+ This method checks whether the method call happens within an Angular Zone instance.
26141
+ */
26086
26142
  static isInAngularZone() {
26087
26143
  // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
26088
26144
  return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
26089
26145
  }
26146
+ /**
26147
+ Assures that the method is called within the Angular Zone, otherwise throws an error.
26148
+ */
26090
26149
  static assertInAngularZone() {
26091
26150
  if (!NgZone.isInAngularZone()) {
26092
26151
  throw new RuntimeError(909 /* RuntimeErrorCode.UNEXPECTED_ZONE_STATE */, ngDevMode && 'Expected to be in Angular Zone, but it is not!');
26093
26152
  }
26094
26153
  }
26154
+ /**
26155
+ Assures that the method is called outside of the Angular Zone, otherwise throws an error.
26156
+ */
26095
26157
  static assertNotInAngularZone() {
26096
26158
  if (NgZone.isInAngularZone()) {
26097
26159
  throw new RuntimeError(909 /* RuntimeErrorCode.UNEXPECTED_ZONE_STATE */, ngDevMode && 'Expected to not be in Angular Zone, but it is!');