@angular/core 19.0.0-next.9 → 19.0.0-rc.1

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 (42) hide show
  1. package/fesm2022/core.mjs +21183 -19410
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +71 -47
  4. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  5. package/fesm2022/primitives/signals.mjs +8 -6
  6. package/fesm2022/primitives/signals.mjs.map +1 -1
  7. package/fesm2022/rxjs-interop.mjs +90 -10
  8. package/fesm2022/rxjs-interop.mjs.map +1 -1
  9. package/fesm2022/testing.mjs +174 -113
  10. package/fesm2022/testing.mjs.map +1 -1
  11. package/index.d.ts +524 -92
  12. package/package.json +1 -1
  13. package/primitives/event-dispatch/index.d.ts +7 -4
  14. package/primitives/signals/index.d.ts +3 -1
  15. package/rxjs-interop/index.d.ts +35 -4
  16. package/schematics/bundles/{checker-3b2ea20f.js → checker-9ca42e51.js} +2303 -1006
  17. package/schematics/bundles/combine_units-a16385aa.js +1634 -0
  18. package/schematics/bundles/{compiler_host-b4ba5a28.js → compiler_host-31afa4ed.js} +8 -5
  19. package/schematics/bundles/control-flow-migration.js +3 -3
  20. package/schematics/bundles/explicit-standalone-flag.js +29 -9
  21. package/schematics/bundles/imports-4ac08251.js +1 -1
  22. package/schematics/bundles/inject-migration.js +222 -54
  23. package/schematics/bundles/leading_space-d190b83b.js +1 -1
  24. package/schematics/bundles/migrate_ts_type_references-b2a28742.js +1463 -0
  25. package/schematics/bundles/nodes-0e7d45ca.js +1 -1
  26. package/schematics/bundles/output-migration.js +575 -0
  27. package/schematics/bundles/pending-tasks.js +3 -3
  28. package/schematics/bundles/{program-6534a30a.js → program-71beec0b.js} +1385 -460
  29. package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
  30. package/schematics/bundles/provide-initializer.js +179 -0
  31. package/schematics/bundles/route-lazy-loading.js +9 -4
  32. package/schematics/bundles/signal-input-migration.js +183 -311
  33. package/schematics/bundles/signal-queries-migration.js +404 -146
  34. package/schematics/bundles/signals.js +54 -0
  35. package/schematics/bundles/standalone-migration.js +29 -12
  36. package/schematics/collection.json +11 -0
  37. package/schematics/migrations.json +7 -1
  38. package/schematics/ng-generate/output-migration/schema.json +19 -0
  39. package/schematics/ng-generate/signal-queries-migration/schema.json +11 -0
  40. package/schematics/ng-generate/signals/schema.json +65 -0
  41. package/testing/index.d.ts +1 -1
  42. package/schematics/bundles/group_replacements-e1b5cbf8.js +0 -31571
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0-next.9
2
+ * @license Angular v19.0.0-rc.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -51,6 +51,8 @@ function waitForAsync(fn) {
51
51
  * @publicApi
52
52
  */
53
53
  class DeferBlockFixture {
54
+ block;
55
+ componentFixture;
54
56
  /** @nodoc */
55
57
  constructor(block, componentFixture) {
56
58
  this.block = block;
@@ -150,11 +152,9 @@ const ComponentFixtureNoNgZone = new InjectionToken('ComponentFixtureNoNgZone');
150
152
 
151
153
  const RETHROW_APPLICATION_ERRORS_DEFAULT = true;
152
154
  class TestBedApplicationErrorHandler {
153
- constructor() {
154
- this.zone = inject$1(NgZone);
155
- this.userErrorHandler = inject$1(ErrorHandler);
156
- this.whenStableRejectFunctions = new Set();
157
- }
155
+ zone = inject$1(NgZone);
156
+ userErrorHandler = inject$1(ErrorHandler);
157
+ whenStableRejectFunctions = new Set();
158
158
  handleError(e) {
159
159
  try {
160
160
  this.zone.runOutsideAngular(() => this.userErrorHandler.handleError(e));
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
175
175
  throw e;
176
176
  }
177
177
  }
178
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.9", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
179
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-next.9", ngImport: i0, type: TestBedApplicationErrorHandler }); }
178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.1", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
179
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.1", ngImport: i0, type: TestBedApplicationErrorHandler });
180
180
  }
181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.9", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.1", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
182
182
  type: Injectable
183
183
  }] });
184
184
 
@@ -188,34 +188,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.9",
188
188
  * @publicApi
189
189
  */
190
190
  class ComponentFixture {
191
+ componentRef;
192
+ /**
193
+ * The DebugElement associated with the root element of this component.
194
+ */
195
+ debugElement;
196
+ /**
197
+ * The instance of the root component class.
198
+ */
199
+ componentInstance;
200
+ /**
201
+ * The native element at the root of the component.
202
+ */
203
+ nativeElement;
204
+ /**
205
+ * The ElementRef for the element at the root of the component.
206
+ */
207
+ elementRef;
208
+ /**
209
+ * The ChangeDetectorRef for the component
210
+ */
211
+ changeDetectorRef;
212
+ _renderer;
213
+ _isDestroyed = false;
214
+ /** @internal */
215
+ _noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
216
+ /** @internal */
217
+ _ngZone = this._noZoneOptionIsSet ? new ɵNoopNgZone() : inject$1(NgZone);
218
+ // Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
219
+ // This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
220
+ // This is a crazy way of doing things but hey, it's the world we live in.
221
+ // The zoneless scheduler should instead do this more imperatively by attaching
222
+ // the `ComponentRef` to `ApplicationRef` and calling `appRef.tick` as the `detectChanges`
223
+ // behavior.
224
+ /** @internal */
225
+ _appRef = inject$1(ApplicationRef);
226
+ _testAppRef = this._appRef;
227
+ pendingTasks = inject$1(ɵPendingTasks);
228
+ appErrorHandler = inject$1(TestBedApplicationErrorHandler);
229
+ zonelessEnabled = inject$1(ɵZONELESS_ENABLED);
230
+ scheduler = inject$1(ɵChangeDetectionScheduler);
231
+ rootEffectScheduler = inject$1(ɵEffectScheduler);
232
+ microtaskEffectScheduler = inject$1(ɵMicrotaskEffectScheduler);
233
+ autoDetectDefault = this.zonelessEnabled ? true : false;
234
+ autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? this.autoDetectDefault;
235
+ subscriptions = new Subscription();
236
+ // TODO(atscott): Remove this from public API
237
+ ngZone = this._noZoneOptionIsSet ? null : this._ngZone;
191
238
  /** @nodoc */
192
239
  constructor(componentRef) {
193
240
  this.componentRef = componentRef;
194
- this._isDestroyed = false;
195
- /** @internal */
196
- this._noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
197
- /** @internal */
198
- this._ngZone = this._noZoneOptionIsSet ? new ɵNoopNgZone() : inject$1(NgZone);
199
- // Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
200
- // This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
201
- // This is a crazy way of doing things but hey, it's the world we live in.
202
- // The zoneless scheduler should instead do this more imperatively by attaching
203
- // the `ComponentRef` to `ApplicationRef` and calling `appRef.tick` as the `detectChanges`
204
- // behavior.
205
- /** @internal */
206
- this._appRef = inject$1(ApplicationRef);
207
- this._testAppRef = this._appRef;
208
- this.pendingTasks = inject$1(ɵPendingTasks);
209
- this.appErrorHandler = inject$1(TestBedApplicationErrorHandler);
210
- this.zonelessEnabled = inject$1(ɵZONELESS_ENABLED);
211
- this.scheduler = inject$1(ɵChangeDetectionScheduler);
212
- this.rootEffectScheduler = inject$1(ɵEffectScheduler);
213
- this.microtaskEffectScheduler = inject$1(ɵMicrotaskEffectScheduler);
214
- this.autoDetectDefault = this.zonelessEnabled ? true : false;
215
- this.autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? this.autoDetectDefault;
216
- this.subscriptions = new Subscription();
217
- // TODO(atscott): Remove this from public API
218
- this.ngZone = this._noZoneOptionIsSet ? null : this._ngZone;
219
241
  this.changeDetectorRef = componentRef.changeDetectorRef;
220
242
  this.elementRef = componentRef.location;
221
243
  this.debugElement = getDebugNode(this.elementRef.nativeElement);
@@ -537,9 +559,7 @@ function flushMicrotasks() {
537
559
 
538
560
  let _nextReferenceId = 0;
539
561
  class MetadataOverrider {
540
- constructor() {
541
- this._references = new Map();
542
- }
562
+ _references = new Map();
543
563
  /**
544
564
  * Creates a new instance for the given metadata class
545
565
  * based on an old instance and overrides.
@@ -661,10 +681,8 @@ const reflection = new ɵReflectionCapabilities();
661
681
  * Allows to override ivy metadata for tests (via the `TestBed`).
662
682
  */
663
683
  class OverrideResolver {
664
- constructor() {
665
- this.overrides = new Map();
666
- this.resolved = new Map();
667
- }
684
+ overrides = new Map();
685
+ resolved = new Map();
668
686
  addOverride(type, override) {
669
687
  const overrides = this.overrides.get(type) || [];
670
688
  overrides.push(override);
@@ -747,67 +765,70 @@ function assertNoStandaloneComponents(types, resolver, location) {
747
765
  types.forEach((type) => {
748
766
  if (!ɵgetAsyncClassMetadataFn(type)) {
749
767
  const component = resolver.resolve(type);
750
- if (component && component.standalone) {
768
+ if (component && (component.standalone == null || component.standalone)) {
751
769
  throw new Error(ɵgenerateStandaloneInDeclarationsError(type, location));
752
770
  }
753
771
  }
754
772
  });
755
773
  }
756
774
  class TestBedCompiler {
775
+ platform;
776
+ additionalModuleTypes;
777
+ originalComponentResolutionQueue = null;
778
+ // Testing module configuration
779
+ declarations = [];
780
+ imports = [];
781
+ providers = [];
782
+ schemas = [];
783
+ // Queues of components/directives/pipes that should be recompiled.
784
+ pendingComponents = new Set();
785
+ pendingDirectives = new Set();
786
+ pendingPipes = new Set();
787
+ // Set of components with async metadata, i.e. components with `@defer` blocks
788
+ // in their templates.
789
+ componentsWithAsyncMetadata = new Set();
790
+ // Keep track of all components and directives, so we can patch Providers onto defs later.
791
+ seenComponents = new Set();
792
+ seenDirectives = new Set();
793
+ // Keep track of overridden modules, so that we can collect all affected ones in the module tree.
794
+ overriddenModules = new Set();
795
+ // Store resolved styles for Components that have template overrides present and `styleUrls`
796
+ // defined at the same time.
797
+ existingComponentStyles = new Map();
798
+ resolvers = initResolvers();
799
+ // Map of component type to an NgModule that declares it.
800
+ //
801
+ // There are a couple special cases:
802
+ // - for standalone components, the module scope value is `null`
803
+ // - when a component is declared in `TestBed.configureTestingModule()` call or
804
+ // a component's template is overridden via `TestBed.overrideTemplateUsingTestingModule()`.
805
+ // we use a special value from the `TestingModuleOverride` enum.
806
+ componentToModuleScope = new Map();
807
+ // Map that keeps initial version of component/directive/pipe defs in case
808
+ // we compile a Type again, thus overriding respective static fields. This is
809
+ // required to make sure we restore defs to their initial states between test runs.
810
+ // Note: one class may have multiple defs (for example: ɵmod and ɵinj in case of an
811
+ // NgModule), store all of them in a map.
812
+ initialNgDefs = new Map();
813
+ // Array that keeps cleanup operations for initial versions of component/directive/pipe/module
814
+ // defs in case TestBed makes changes to the originals.
815
+ defCleanupOps = [];
816
+ _injector = null;
817
+ compilerProviders = null;
818
+ providerOverrides = [];
819
+ rootProviderOverrides = [];
820
+ // Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that
821
+ // module's provider list.
822
+ providerOverridesByModule = new Map();
823
+ providerOverridesByToken = new Map();
824
+ scopesWithOverriddenProviders = new Set();
825
+ testModuleType;
826
+ testModuleRef = null;
827
+ deferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
828
+ rethrowApplicationTickErrors = RETHROW_APPLICATION_ERRORS_DEFAULT;
757
829
  constructor(platform, additionalModuleTypes) {
758
830
  this.platform = platform;
759
831
  this.additionalModuleTypes = additionalModuleTypes;
760
- this.originalComponentResolutionQueue = null;
761
- // Testing module configuration
762
- this.declarations = [];
763
- this.imports = [];
764
- this.providers = [];
765
- this.schemas = [];
766
- // Queues of components/directives/pipes that should be recompiled.
767
- this.pendingComponents = new Set();
768
- this.pendingDirectives = new Set();
769
- this.pendingPipes = new Set();
770
- // Set of components with async metadata, i.e. components with `@defer` blocks
771
- // in their templates.
772
- this.componentsWithAsyncMetadata = new Set();
773
- // Keep track of all components and directives, so we can patch Providers onto defs later.
774
- this.seenComponents = new Set();
775
- this.seenDirectives = new Set();
776
- // Keep track of overridden modules, so that we can collect all affected ones in the module tree.
777
- this.overriddenModules = new Set();
778
- // Store resolved styles for Components that have template overrides present and `styleUrls`
779
- // defined at the same time.
780
- this.existingComponentStyles = new Map();
781
- this.resolvers = initResolvers();
782
- // Map of component type to an NgModule that declares it.
783
- //
784
- // There are a couple special cases:
785
- // - for standalone components, the module scope value is `null`
786
- // - when a component is declared in `TestBed.configureTestingModule()` call or
787
- // a component's template is overridden via `TestBed.overrideTemplateUsingTestingModule()`.
788
- // we use a special value from the `TestingModuleOverride` enum.
789
- this.componentToModuleScope = new Map();
790
- // Map that keeps initial version of component/directive/pipe defs in case
791
- // we compile a Type again, thus overriding respective static fields. This is
792
- // required to make sure we restore defs to their initial states between test runs.
793
- // Note: one class may have multiple defs (for example: ɵmod and ɵinj in case of an
794
- // NgModule), store all of them in a map.
795
- this.initialNgDefs = new Map();
796
- // Array that keeps cleanup operations for initial versions of component/directive/pipe/module
797
- // defs in case TestBed makes changes to the originals.
798
- this.defCleanupOps = [];
799
- this._injector = null;
800
- this.compilerProviders = null;
801
- this.providerOverrides = [];
802
- this.rootProviderOverrides = [];
803
- // Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that
804
- // module's provider list.
805
- this.providerOverridesByModule = new Map();
806
- this.providerOverridesByToken = new Map();
807
- this.scopesWithOverriddenProviders = new Set();
808
- this.testModuleRef = null;
809
- this.deferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
810
- this.rethrowApplicationTickErrors = RETHROW_APPLICATION_ERRORS_DEFAULT;
811
832
  class DynamicTestModule {
812
833
  }
813
834
  this.testModuleType = DynamicTestModule;
@@ -1634,6 +1655,7 @@ function invalidTypeError(name, expectedType) {
1634
1655
  return new Error(`${name} class doesn't have @${expectedType} decorator or is missing metadata.`);
1635
1656
  }
1636
1657
  class R3TestCompiler {
1658
+ testBed;
1637
1659
  constructor(testBed) {
1638
1660
  this.testBed = testBed;
1639
1661
  }
@@ -1681,29 +1703,55 @@ function getTestBed() {
1681
1703
  * TestBed is the primary api for writing unit tests for Angular applications and libraries.
1682
1704
  */
1683
1705
  class TestBedImpl {
1684
- constructor() {
1685
- /**
1686
- * Defer block behavior option that specifies whether defer blocks will be triggered manually
1687
- * or set to play through.
1688
- */
1689
- this._instanceDeferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
1690
- // Properties
1691
- this.platform = null;
1692
- this.ngModule = null;
1693
- this._compiler = null;
1694
- this._testModuleRef = null;
1695
- this._activeFixtures = [];
1696
- /**
1697
- * Internal-only flag to indicate whether a module
1698
- * scoping queue has been checked and flushed already.
1699
- * @nodoc
1700
- */
1701
- this.globalCompilationChecked = false;
1702
- }
1703
- static { this._INSTANCE = null; }
1706
+ static _INSTANCE = null;
1704
1707
  static get INSTANCE() {
1705
1708
  return (TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl());
1706
1709
  }
1710
+ /**
1711
+ * Teardown options that have been configured at the environment level.
1712
+ * Used as a fallback if no instance-level options have been provided.
1713
+ */
1714
+ static _environmentTeardownOptions;
1715
+ /**
1716
+ * "Error on unknown elements" option that has been configured at the environment level.
1717
+ * Used as a fallback if no instance-level option has been provided.
1718
+ */
1719
+ static _environmentErrorOnUnknownElementsOption;
1720
+ /**
1721
+ * "Error on unknown properties" option that has been configured at the environment level.
1722
+ * Used as a fallback if no instance-level option has been provided.
1723
+ */
1724
+ static _environmentErrorOnUnknownPropertiesOption;
1725
+ /**
1726
+ * Teardown options that have been configured at the `TestBed` instance level.
1727
+ * These options take precedence over the environment-level ones.
1728
+ */
1729
+ _instanceTeardownOptions;
1730
+ /**
1731
+ * Defer block behavior option that specifies whether defer blocks will be triggered manually
1732
+ * or set to play through.
1733
+ */
1734
+ _instanceDeferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
1735
+ /**
1736
+ * "Error on unknown elements" option that has been configured at the `TestBed` instance level.
1737
+ * This option takes precedence over the environment-level one.
1738
+ */
1739
+ _instanceErrorOnUnknownElementsOption;
1740
+ /**
1741
+ * "Error on unknown properties" option that has been configured at the `TestBed` instance level.
1742
+ * This option takes precedence over the environment-level one.
1743
+ */
1744
+ _instanceErrorOnUnknownPropertiesOption;
1745
+ /**
1746
+ * Stores the previous "Error on unknown elements" option value,
1747
+ * allowing to restore it in the reset testing module logic.
1748
+ */
1749
+ _previousErrorOnUnknownElementsOption;
1750
+ /**
1751
+ * Stores the previous "Error on unknown properties" option value,
1752
+ * allowing to restore it in the reset testing module logic.
1753
+ */
1754
+ _previousErrorOnUnknownPropertiesOption;
1707
1755
  /**
1708
1756
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
1709
1757
  * angular module. These are common to every test in the suite.
@@ -1808,6 +1856,18 @@ class TestBedImpl {
1808
1856
  static flushEffects() {
1809
1857
  return TestBedImpl.INSTANCE.flushEffects();
1810
1858
  }
1859
+ // Properties
1860
+ platform = null;
1861
+ ngModule = null;
1862
+ _compiler = null;
1863
+ _testModuleRef = null;
1864
+ _activeFixtures = [];
1865
+ /**
1866
+ * Internal-only flag to indicate whether a module
1867
+ * scoping queue has been checked and flushed already.
1868
+ * @nodoc
1869
+ */
1870
+ globalCompilationChecked = false;
1811
1871
  /**
1812
1872
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
1813
1873
  * angular module. These are common to every test in the suite.
@@ -2174,6 +2234,7 @@ function inject(tokens, fn) {
2174
2234
  * @publicApi
2175
2235
  */
2176
2236
  class InjectSetupWrapper {
2237
+ _moduleDef;
2177
2238
  constructor(_moduleDef) {
2178
2239
  this._moduleDef = _moduleDef;
2179
2240
  }