@angular/core 16.2.0-next.1 → 16.2.0-next.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.
Files changed (39) 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/deps_tracker/api.mjs +1 -1
  15. package/esm2022/src/render3/deps_tracker/deps_tracker.mjs +216 -12
  16. package/esm2022/src/render3/features/standalone_feature.mjs +4 -4
  17. package/esm2022/src/render3/jit/directive.mjs +2 -2
  18. package/esm2022/src/render3/jit/util.mjs +11 -2
  19. package/esm2022/src/render3/pipe.mjs +26 -2
  20. package/esm2022/src/render3/reactivity/effect.mjs +1 -1
  21. package/esm2022/src/signals/src/graph.mjs +7 -3
  22. package/esm2022/src/util/global.mjs +2 -10
  23. package/esm2022/src/util/raf.mjs +20 -5
  24. package/esm2022/src/version.mjs +1 -1
  25. package/esm2022/src/zone/ng_zone.mjs +10 -1
  26. package/esm2022/testing/src/logger.mjs +3 -3
  27. package/esm2022/testing/src/test_hooks.mjs +3 -8
  28. package/fesm2022/core.mjs +97 -34
  29. package/fesm2022/core.mjs.map +1 -1
  30. package/fesm2022/rxjs-interop.mjs +10 -14
  31. package/fesm2022/rxjs-interop.mjs.map +1 -1
  32. package/fesm2022/testing.mjs +85 -51
  33. package/fesm2022/testing.mjs.map +1 -1
  34. package/index.d.ts +35 -19
  35. package/package.json +1 -1
  36. package/rxjs-interop/index.d.ts +15 -12
  37. package/schematics/ng-generate/standalone-migration/bundle.js +1861 -410
  38. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  39. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.2.0-next.1
2
+ * @license Angular v16.2.0-next.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -520,15 +520,7 @@ function componentDefResolved(type) {
520
520
  componentDefPendingResolution.delete(type);
521
521
  }
522
522
 
523
- // Always use __globalThis if available, which is the spec-defined global variable across all
524
- // environments, then fallback to __global first, because in Node tests both __global and
525
- // __window may be defined and _global should be __global in that case. Note: Typeof/Instanceof
526
- // checks are considered side-effects in Terser. We explicitly mark this as side-effect free:
527
- // https://github.com/terser/terser/issues/250.
528
- const _global$1 = ( /* @__PURE__ */(() => (typeof globalThis !== 'undefined' && globalThis) ||
529
- (typeof global !== 'undefined' && global) || (typeof window !== 'undefined' && window) ||
530
- (typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
531
- self instanceof WorkerGlobalScope && self))());
523
+ const _global = globalThis;
532
524
 
533
525
  var FactoryTarget;
534
526
  (function (FactoryTarget) {
@@ -553,7 +545,7 @@ var ViewEncapsulation$1;
553
545
  })(ViewEncapsulation$1 || (ViewEncapsulation$1 = {}));
554
546
 
555
547
  function getCompilerFacade(request) {
556
- const globalNg = _global$1['ng'];
548
+ const globalNg = _global['ng'];
557
549
  if (globalNg && globalNg.ɵcompilerFacade) {
558
550
  return globalNg.ɵcompilerFacade;
559
551
  }
@@ -726,7 +718,8 @@ function isForwardRef(fn) {
726
718
  * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
727
719
  * provided in the `'root'` injector, which will be the application-level injector in most apps.
728
720
  * * `factory` gives the zero argument function which will create an instance of the injectable.
729
- * The factory can call `inject` to access the `Injector` and request injection of dependencies.
721
+ * The factory can call [`inject`](api/core/inject) to access the `Injector` and request injection
722
+ * of dependencies.
730
723
  *
731
724
  * @codeGenApi
732
725
  * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
@@ -1428,7 +1421,7 @@ function isDelegateCtor(typeStr) {
1428
1421
  }
1429
1422
  class ReflectionCapabilities {
1430
1423
  constructor(reflect) {
1431
- this._reflect = reflect || _global$1['Reflect'];
1424
+ this._reflect = reflect || _global['Reflect'];
1432
1425
  }
1433
1426
  factory(t) {
1434
1427
  return (...args) => new t(...args);
@@ -1655,7 +1648,7 @@ function ngDevModeResetPerfCounters() {
1655
1648
  };
1656
1649
  // Make sure to refer to ngDevMode as ['ngDevMode'] for closure.
1657
1650
  const allowNgDevModeTrue = locationString.indexOf('ngDevMode=false') === -1;
1658
- _global$1['ngDevMode'] = allowNgDevModeTrue && newCounters;
1651
+ _global['ngDevMode'] = allowNgDevModeTrue && newCounters;
1659
1652
  return newCounters;
1660
1653
  }
1661
1654
  /**
@@ -1761,7 +1754,7 @@ function throwProviderNotFoundError(token, injectorName) {
1761
1754
  * Injection flags for DI.
1762
1755
  *
1763
1756
  * @publicApi
1764
- * @deprecated use an options object for `inject` instead.
1757
+ * @deprecated use an options object for [`inject`](api/core/inject) instead.
1765
1758
  */
1766
1759
  var InjectFlags;
1767
1760
  (function (InjectFlags) {
@@ -1895,13 +1888,14 @@ Please check that 1) the type for the parameter at index ${index} is correct and
1895
1888
  }
1896
1889
  /**
1897
1890
  * Injects a token from the currently active injector.
1898
- * `inject` is only supported during instantiation of a dependency by the DI system. It can be used
1899
- * during:
1891
+ * `inject` is only supported in a [injection context](/guide/dependency-injection-context). It can
1892
+ * be used during:
1900
1893
  * - Construction (via the `constructor`) of a class being instantiated by the DI system, such
1901
1894
  * as an `@Injectable` or `@Component`.
1902
1895
  * - In the initializer for fields of such classes.
1903
1896
  * - In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
1904
1897
  * - In the `factory` function specified for an `InjectionToken`.
1898
+ * - In a stackframe of a function call in a DI context
1905
1899
  *
1906
1900
  * @param token A token that represents a dependency that should be injected.
1907
1901
  * @param flags Optional flags that control how injection is executed.
@@ -3347,8 +3341,13 @@ function assertTNodeForLView(tNode, lView) {
3347
3341
  }
3348
3342
  function assertTNodeForTView(tNode, tView) {
3349
3343
  assertTNode(tNode);
3350
- tNode.hasOwnProperty('tView_') &&
3351
- assertEqual(tNode.tView_, tView, 'This TNode does not belong to this TView.');
3344
+ const tData = tView.data;
3345
+ for (let i = HEADER_OFFSET; i < tData.length; i++) {
3346
+ if (tData[i] === tNode) {
3347
+ return;
3348
+ }
3349
+ }
3350
+ throwError('This TNode does not belong to this TView.');
3352
3351
  }
3353
3352
  function assertTNode(tNode) {
3354
3353
  assertDefined(tNode, 'TNode must be defined');
@@ -3512,7 +3511,7 @@ class LeakyRef {
3512
3511
  // `WeakRef` is not always defined in every TS environment where Angular is compiled. Instead,
3513
3512
  // read it off of the global context if available.
3514
3513
  // tslint:disable-next-line: no-toplevel-property-access
3515
- let WeakRefImpl = _global$1['WeakRef'] ?? LeakyRef;
3514
+ let WeakRefImpl = _global['WeakRef'] ?? LeakyRef;
3516
3515
  function newWeakRef(value) {
3517
3516
  if (typeof ngDevMode !== 'undefined' && ngDevMode && WeakRefImpl === undefined) {
3518
3517
  throw new Error(`Angular requires a browser which supports the 'WeakRef' API`);
@@ -3609,7 +3608,9 @@ class ReactiveNode {
3609
3608
  consumerPollProducersForChange() {
3610
3609
  for (const [producerId, edge] of this.producers) {
3611
3610
  const producer = edge.producerNode.deref();
3612
- if (producer === undefined || edge.atTrackingVersion !== this.trackingVersion) {
3611
+ // On Safari < 16.1 deref can return null, we need to check for null also.
3612
+ // See https://github.com/WebKit/WebKit/commit/44c15ba58912faab38b534fef909dd9e13e095e0
3613
+ if (producer == null || edge.atTrackingVersion !== this.trackingVersion) {
3613
3614
  // This dependency edge is stale, so remove it.
3614
3615
  this.producers.delete(producerId);
3615
3616
  producer?.consumers.delete(this.id);
@@ -3634,7 +3635,9 @@ class ReactiveNode {
3634
3635
  try {
3635
3636
  for (const [consumerId, edge] of this.consumers) {
3636
3637
  const consumer = edge.consumerNode.deref();
3637
- if (consumer === undefined || consumer.trackingVersion !== edge.atTrackingVersion) {
3638
+ // On Safari < 16.1 deref can return null, we need to check for null also.
3639
+ // See https://github.com/WebKit/WebKit/commit/44c15ba58912faab38b534fef909dd9e13e095e0
3640
+ if (consumer == null || consumer.trackingVersion !== edge.atTrackingVersion) {
3638
3641
  this.consumers.delete(consumerId);
3639
3642
  consumer?.producers.delete(this.id);
3640
3643
  continue;
@@ -8080,9 +8083,9 @@ let policy$1;
8080
8083
  function getPolicy$1() {
8081
8084
  if (policy$1 === undefined) {
8082
8085
  policy$1 = null;
8083
- if (_global$1.trustedTypes) {
8086
+ if (_global.trustedTypes) {
8084
8087
  try {
8085
- policy$1 = _global$1.trustedTypes.createPolicy('angular', {
8088
+ policy$1 = _global.trustedTypes.createPolicy('angular', {
8086
8089
  createHTML: (s) => s,
8087
8090
  createScript: (s) => s,
8088
8091
  createScriptURL: (s) => s,
@@ -8145,7 +8148,7 @@ function newTrustedFunctionForDev(...args) {
8145
8148
  if (typeof ngDevMode === 'undefined') {
8146
8149
  throw new Error('newTrustedFunctionForDev should never be called in production');
8147
8150
  }
8148
- if (!_global$1.trustedTypes) {
8151
+ if (!_global.trustedTypes) {
8149
8152
  // In environments that don't support Trusted Types, fall back to the most
8150
8153
  // straightforward implementation:
8151
8154
  return new Function(...args);
@@ -8162,7 +8165,7 @@ function newTrustedFunctionForDev(...args) {
8162
8165
  // Using eval directly confuses the compiler and prevents this module from
8163
8166
  // being stripped out of JS binaries even if not used. The global['eval']
8164
8167
  // indirection fixes that.
8165
- const fn = _global$1['eval'](trustedScriptFromString(body));
8168
+ const fn = _global['eval'](trustedScriptFromString(body));
8166
8169
  if (fn.bind === undefined) {
8167
8170
  // Workaround for a browser bug that only exists in Chrome 83, where passing
8168
8171
  // a TrustedScript to eval just returns the TrustedScript back without
@@ -8175,7 +8178,7 @@ function newTrustedFunctionForDev(...args) {
8175
8178
  // 1. Stringifying the resulting function should return its source code
8176
8179
  fn.toString = () => body;
8177
8180
  // 2. When calling the resulting function, `this` should refer to `global`
8178
- return fn.bind(_global$1);
8181
+ return fn.bind(_global);
8179
8182
  // When Trusted Types support in Function constructors is widely available,
8180
8183
  // the implementation of this function can be simplified to:
8181
8184
  // return new Function(...args.map(a => trustedScriptFromString(a)));
@@ -8287,9 +8290,9 @@ let policy;
8287
8290
  function getPolicy() {
8288
8291
  if (policy === undefined) {
8289
8292
  policy = null;
8290
- if (_global$1.trustedTypes) {
8293
+ if (_global.trustedTypes) {
8291
8294
  try {
8292
- policy = _global$1.trustedTypes
8295
+ policy = _global.trustedTypes
8293
8296
  .createPolicy('angular#unsafe-bypass', {
8294
8297
  createHTML: (s) => s,
8295
8298
  createScript: (s) => s,
@@ -9062,7 +9065,7 @@ function getSanitizer() {
9062
9065
  * (possibly by creating) a default value of the parameterized type `T`. This sets up the
9063
9066
  * `InjectionToken` using this factory as a provider as if it was defined explicitly in the
9064
9067
  * application's root injector. If the factory function, which takes zero arguments, needs to inject
9065
- * dependencies, it can do so using the `inject` function.
9068
+ * dependencies, it can do so using the [`inject`](api/core/inject) function.
9066
9069
  * As you can see in the Tree-shakable InjectionToken example below.
9067
9070
  *
9068
9071
  * Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
@@ -9160,7 +9163,7 @@ class NullInjector {
9160
9163
 
9161
9164
  /**
9162
9165
  * Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
9163
- * referenced in `@Component in a component injector.
9166
+ * referenced in `@Component` in a component injector.
9164
9167
  */
9165
9168
  function makeEnvironmentProviders(providers) {
9166
9169
  return {
@@ -10482,7 +10485,7 @@ class Version {
10482
10485
  /**
10483
10486
  * @publicApi
10484
10487
  */
10485
- const VERSION = new Version('16.2.0-next.1');
10488
+ const VERSION = new Version('16.2.0-next.3');
10486
10489
 
10487
10490
  // This default value is when checking the hierarchy for a token.
10488
10491
  //
@@ -10858,13 +10861,15 @@ function selectIndexInternal(tView, lView, index, checkNoChangesMode) {
10858
10861
  }
10859
10862
 
10860
10863
  /**
10861
- * Runs the given function in the context of the given `Injector`.
10864
+ * Runs the given function in the [context](guide/dependency-injection-context) of the given
10865
+ * `Injector`.
10862
10866
  *
10863
- * Within the function's stack frame, `inject` can be used to inject dependencies from the given
10864
- * `Injector`. Note that `inject` is only usable synchronously, and cannot be used in any
10865
- * asynchronous callbacks or after any `await` points.
10867
+ * Within the function's stack frame, [`inject`](api/core/inject) can be used to inject dependencies
10868
+ * from the given `Injector`. Note that `inject` is only usable synchronously, and cannot be used in
10869
+ * any asynchronous callbacks or after any `await` points.
10866
10870
  *
10867
- * @param injector the injector which will satisfy calls to `inject` while `fn` is executing
10871
+ * @param injector the injector which will satisfy calls to [`inject`](api/core/inject) while `fn`
10872
+ * is executing
10868
10873
  * @param fn the closure to be run in the context of `injector`
10869
10874
  * @returns the return value of the function, if any
10870
10875
  * @publicApi
@@ -10884,7 +10889,8 @@ function runInInjectionContext(injector, fn) {
10884
10889
  }
10885
10890
  }
10886
10891
  /**
10887
- * Asserts that the current stack frame is within an injection context and has access to `inject`.
10892
+ * Asserts that the current stack frame is within an [injection
10893
+ * context](guide/dependency-injection-context) and has access to `inject`.
10888
10894
  *
10889
10895
  * @param debugFn a reference to the function making the assertion (used for the error message).
10890
10896
  *
@@ -19608,7 +19614,7 @@ if (typeof ngI18nClosureMode === 'undefined') {
19608
19614
  // NOTE: we need to have it in IIFE so that the tree-shaker is happy.
19609
19615
  (function () {
19610
19616
  // tslint:disable-next-line:no-toplevel-property-access
19611
- _global$1['ngI18nClosureMode'] =
19617
+ _global['ngI18nClosureMode'] =
19612
19618
  // TODO(FW-1250): validate that this actually, you know, works.
19613
19619
  // tslint:disable-next-line:no-toplevel-property-access
19614
19620
  typeof goog !== 'undefined' && typeof goog.getMsg === 'function';
@@ -19702,8 +19708,8 @@ function getLocalePluralCase(locale) {
19702
19708
  */
19703
19709
  function getLocaleData(normalizedLocale) {
19704
19710
  if (!(normalizedLocale in LOCALE_DATA)) {
19705
- LOCALE_DATA[normalizedLocale] = _global$1.ng && _global$1.ng.common && _global$1.ng.common.locales &&
19706
- _global$1.ng.common.locales[normalizedLocale];
19711
+ LOCALE_DATA[normalizedLocale] = _global.ng && _global.ng.common && _global.ng.common.locales &&
19712
+ _global.ng.common.locales[normalizedLocale];
19707
19713
  }
19708
19714
  return LOCALE_DATA[normalizedLocale];
19709
19715
  }
@@ -22085,14 +22091,14 @@ class StandaloneService {
22085
22091
  if (!componentDef.standalone) {
22086
22092
  return null;
22087
22093
  }
22088
- if (!this.cachedInjectors.has(componentDef.id)) {
22094
+ if (!this.cachedInjectors.has(componentDef)) {
22089
22095
  const providers = internalImportProvidersFrom(false, componentDef.type);
22090
22096
  const standaloneInjector = providers.length > 0 ?
22091
22097
  createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22092
22098
  null;
22093
- this.cachedInjectors.set(componentDef.id, standaloneInjector);
22099
+ this.cachedInjectors.set(componentDef, standaloneInjector);
22094
22100
  }
22095
- return this.cachedInjectors.get(componentDef.id);
22101
+ return this.cachedInjectors.get(componentDef);
22096
22102
  }
22097
22103
  ngOnDestroy() {
22098
22104
  try {
@@ -22941,6 +22947,13 @@ function ɵɵpipe(index, pipeName) {
22941
22947
  */
22942
22948
  function getPipeDef(name, registry) {
22943
22949
  if (registry) {
22950
+ if (ngDevMode) {
22951
+ const pipes = registry.filter(pipe => pipe.name === name);
22952
+ // TODO: Throw an error in the next major
22953
+ if (pipes.length > 1) {
22954
+ console.warn(formatRuntimeError(313 /* RuntimeErrorCode.MULTIPLE_MATCHING_PIPES */, getMultipleMatchingPipesMessage(name)));
22955
+ }
22956
+ }
22944
22957
  for (let i = registry.length - 1; i >= 0; i--) {
22945
22958
  const pipeDef = registry[i];
22946
22959
  if (name === pipeDef.name) {
@@ -22952,6 +22965,23 @@ function getPipeDef(name, registry) {
22952
22965
  throw new RuntimeError(-302 /* RuntimeErrorCode.PIPE_NOT_FOUND */, getPipeNotFoundErrorMessage(name));
22953
22966
  }
22954
22967
  }
22968
+ /**
22969
+ * Generates a helpful error message for the user when multiple pipes match the name.
22970
+ *
22971
+ * @param name Name of the pipe
22972
+ * @returns The error message
22973
+ */
22974
+ function getMultipleMatchingPipesMessage(name) {
22975
+ const lView = getLView();
22976
+ const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
22977
+ const context = declarationLView[CONTEXT];
22978
+ const hostIsStandalone = isHostComponentStandalone(lView);
22979
+ const componentInfoMessage = context ? ` in the '${context.constructor.name}' component` : '';
22980
+ const verifyMessage = `check ${hostIsStandalone ? '\'@Component.imports\' of this component' :
22981
+ 'the imports of this module'}`;
22982
+ const errorMessage = `Multiple pipes match the name \`${name}\`${componentInfoMessage}. ${verifyMessage}`;
22983
+ return errorMessage;
22984
+ }
22955
22985
  /**
22956
22986
  * Generates a helpful error message for the user when a pipe is not found.
22957
22987
  *
@@ -24531,6 +24561,15 @@ function isModuleWithProviders$1(value) {
24531
24561
  function isNgModule$1(value) {
24532
24562
  return !!getNgModuleDef(value);
24533
24563
  }
24564
+ function isPipe(value) {
24565
+ return !!getPipeDef$1(value);
24566
+ }
24567
+ function isDirective(value) {
24568
+ return !!getDirectiveDef(value);
24569
+ }
24570
+ function isComponent(value) {
24571
+ return !!getComponentDef$1(value);
24572
+ }
24534
24573
 
24535
24574
  const moduleQueue = [];
24536
24575
  /**
@@ -26587,17 +26626,12 @@ function withModule(moduleDef, fn) {
26587
26626
  * with Jasmine, Mocha, or a similar framework which exports a beforeEach function and
26588
26627
  * allows tests to be asynchronous by either returning a promise or using a 'done' parameter.
26589
26628
  */
26590
- const _global = (typeof window === 'undefined' ? global : window);
26591
26629
  // Reset the test providers and the fake async zone before each test.
26592
- if (_global.beforeEach) {
26593
- _global.beforeEach(getCleanupHook(false));
26594
- }
26630
+ beforeEach(getCleanupHook(false));
26595
26631
  // We provide both a `beforeEach` and `afterEach`, because the updated behavior for
26596
26632
  // tearing down the module is supposed to run after the test so that we can associate
26597
26633
  // teardown errors with the correct test.
26598
- if (_global.afterEach) {
26599
- _global.afterEach(getCleanupHook(true));
26600
- }
26634
+ afterEach(getCleanupHook(true));
26601
26635
  function getCleanupHook(expectedTeardownValue) {
26602
26636
  return () => {
26603
26637
  const testBed = TestBedImpl.INSTANCE;