@angular/core 18.0.0-rc.2 → 18.0.0

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/primitives/event-dispatch/src/action_resolver.mjs +5 -1
  2. package/esm2022/primitives/event-dispatch/src/attribute.mjs +4 -15
  3. package/esm2022/primitives/event-dispatch/src/cache.mjs +2 -35
  4. package/esm2022/primitives/event-dispatch/src/dispatcher.mjs +15 -28
  5. package/esm2022/primitives/event-dispatch/src/event_info.mjs +16 -1
  6. package/esm2022/primitives/event-dispatch/src/property.mjs +1 -7
  7. package/esm2022/src/change_detection/scheduling/exhaustive_check_no_changes.mjs +5 -5
  8. package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +8 -2
  9. package/esm2022/src/errors.mjs +1 -1
  10. package/esm2022/src/hydration/event_replay.mjs +11 -6
  11. package/esm2022/src/render3/component_ref.mjs +1 -1
  12. package/esm2022/src/render3/instructions/change_detection.mjs +17 -6
  13. package/esm2022/src/version.mjs +1 -1
  14. package/esm2022/testing/src/logger.mjs +3 -3
  15. package/event-dispatch-contract.min.js +1 -1
  16. package/fesm2022/core.mjs +38 -16
  17. package/fesm2022/core.mjs.map +1 -1
  18. package/fesm2022/primitives/event-dispatch.mjs +38 -82
  19. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  20. package/fesm2022/primitives/signals.mjs +1 -1
  21. package/fesm2022/rxjs-interop.mjs +1 -1
  22. package/fesm2022/testing.mjs +1 -1
  23. package/index.d.ts +4 -3
  24. package/package.json +1 -1
  25. package/primitives/event-dispatch/index.d.ts +16 -4
  26. package/primitives/signals/index.d.ts +1 -1
  27. package/rxjs-interop/index.d.ts +1 -1
  28. package/schematics/migrations/invalid-two-way-bindings/bundle.js +5 -1
  29. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +3 -3
  30. package/schematics/ng-generate/control-flow-migration/bundle.js +5 -1
  31. package/schematics/ng-generate/control-flow-migration/bundle.js.map +3 -3
  32. package/schematics/ng-generate/standalone-migration/bundle.js +38 -19
  33. package/schematics/ng-generate/standalone-migration/bundle.js.map +3 -3
  34. package/testing/index.d.ts +1 -1
  35. package/esm2022/primitives/event-dispatch/src/legacy_dispatcher.mjs +0 -259
package/fesm2022/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-rc.2
2
+ * @license Angular v18.0.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -12927,6 +12927,12 @@ function detectChangesInViewWhileDirty(lView, mode) {
12927
12927
  try {
12928
12928
  setIsRefreshingViews(true);
12929
12929
  detectChangesInView(lView, mode);
12930
+ // We don't need or want to do any looping when in exhaustive checkNoChanges because we
12931
+ // already traverse all the views and nothing should change so we shouldn't have to do
12932
+ // another pass to pick up new changes.
12933
+ if (ngDevMode && isExhaustiveCheckNoChanges()) {
12934
+ return;
12935
+ }
12930
12936
  let retries = 0;
12931
12937
  // If after running change detection, this view still needs to be refreshed or there are
12932
12938
  // descendants views that need to be refreshed due to re-dirtying during the change detection
@@ -12975,6 +12981,7 @@ function refreshView(tView, lView, templateFn, context) {
12975
12981
  // Check no changes mode is a dev only mode used to verify that bindings have not changed
12976
12982
  // since they were assigned. We do not want to execute lifecycle hooks in that mode.
12977
12983
  const isInCheckNoChangesPass = ngDevMode && isInCheckNoChangesMode();
12984
+ const isInExhaustiveCheckNoChangesPass = ngDevMode && isExhaustiveCheckNoChanges();
12978
12985
  !isInCheckNoChangesPass && lView[ENVIRONMENT].inlineEffectRunner?.flush();
12979
12986
  // Start component reactive context
12980
12987
  // - We might already be in a reactive context if this is an embedded view of the host.
@@ -13010,10 +13017,14 @@ function refreshView(tView, lView, templateFn, context) {
13010
13017
  incrementInitPhaseFlags(lView, 0 /* InitPhaseState.OnInitHooksToBeRun */);
13011
13018
  }
13012
13019
  }
13013
- // First mark transplanted views that are declared in this lView as needing a refresh at their
13014
- // insertion points. This is needed to avoid the situation where the template is defined in this
13015
- // `LView` but its declaration appears after the insertion component.
13016
- markTransplantedViewsForRefresh(lView);
13020
+ // We do not need to mark transplanted views for refresh when doing exhaustive checks
13021
+ // because all views will be reached anyways during the traversal.
13022
+ if (!isInExhaustiveCheckNoChangesPass) {
13023
+ // First mark transplanted views that are declared in this lView as needing a refresh at their
13024
+ // insertion points. This is needed to avoid the situation where the template is defined in this
13025
+ // `LView` but its declaration appears after the insertion component.
13026
+ markTransplantedViewsForRefresh(lView);
13027
+ }
13017
13028
  detectChangesInEmbeddedViews(lView, 0 /* ChangeDetectionMode.Global */);
13018
13029
  // Content query results must be refreshed before content hooks are called.
13019
13030
  if (tView.contentQueries !== null) {
@@ -16889,7 +16900,7 @@ function createRootComponent(componentView, rootComponentDef, rootDirectives, ho
16889
16900
  function setRootNodeAttributes(hostRenderer, componentDef, hostRNode, rootSelectorOrNode) {
16890
16901
  if (rootSelectorOrNode) {
16891
16902
  // The placeholder will be replaced with the actual version at build time.
16892
- setUpAttributes(hostRenderer, hostRNode, ['ng-version', '18.0.0-rc.2']);
16903
+ setUpAttributes(hostRenderer, hostRNode, ['ng-version', '18.0.0']);
16893
16904
  }
16894
16905
  else {
16895
16906
  // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
@@ -30801,7 +30812,7 @@ class Version {
30801
30812
  /**
30802
30813
  * @publicApi
30803
30814
  */
30804
- const VERSION = new Version('18.0.0-rc.2');
30815
+ const VERSION = new Version('18.0.0');
30805
30816
 
30806
30817
  class Console {
30807
30818
  log(message) {
@@ -33049,6 +33060,12 @@ class ChangeDetectionSchedulerImpl {
33049
33060
  */
33050
33061
  function provideExperimentalZonelessChangeDetection() {
33051
33062
  performanceMarkFeature('NgZoneless');
33063
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && typeof Zone !== 'undefined' && Zone) {
33064
+ const message = formatRuntimeError(914 /* RuntimeErrorCode.UNEXPECTED_ZONEJS_PRESENT_IN_ZONELESS_MODE */, `The application is using zoneless change detection, but is still loading Zone.js.` +
33065
+ `Consider removing Zone.js to get the full benefits of zoneless. ` +
33066
+ `In applcations using the Angular CLI, Zone.js is typically included in the "polyfills" section of the angular.json file.`);
33067
+ console.warn(message);
33068
+ }
33052
33069
  return makeEnvironmentProviders([
33053
33070
  { provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl },
33054
33071
  { provide: NgZone, useClass: NoopNgZone },
@@ -33707,9 +33724,9 @@ function runPlatformInitializers(injector) {
33707
33724
  *
33708
33725
  * @param options Used to configure when the check will execute.
33709
33726
  * - `interval` will periodically run exhaustive `checkNoChanges` on application views
33710
- * - `useNgZoneOnStable` will us ZoneJS to determine when change detection might have run
33727
+ * - `useNgZoneOnStable` will use ZoneJS to determine when change detection might have run
33711
33728
  * in an application using ZoneJS to drive change detection. When the `NgZone.onStable` would
33712
- * have emit, all views attached to the `ApplicationRef` are checked for changes.
33729
+ * have emitted, all views attached to the `ApplicationRef` are checked for changes.
33713
33730
  * - 'exhaustive' means that all views attached to `ApplicationRef` and all the descendants of those views will be
33714
33731
  * checked for changes (excluding those subtrees which are detached via `ChangeDetectorRef.detach()`).
33715
33732
  * This is useful because the check that runs after regular change detection does not work for components using `ChangeDetectionStrategy.OnPush`.
@@ -33743,7 +33760,7 @@ function provideExperimentalCheckNoChangesForDebug(options) {
33743
33760
  useValue: () => {
33744
33761
  if (options?.useNgZoneOnStable &&
33745
33762
  !(inject(NgZone) instanceof DebugNgZoneForCheckNoChanges)) {
33746
- throw new Error('`provideCheckNoChangesForDebug` with `useNgZoneOnStable` must be after any other provider for `NgZone`.');
33763
+ throw new Error('`provideExperimentalCheckNoChangesForDebug` with `useNgZoneOnStable` must be after any other provider for `NgZone`.');
33747
33764
  }
33748
33765
  },
33749
33766
  },
@@ -33756,7 +33773,7 @@ function provideExperimentalCheckNoChangesForDebug(options) {
33756
33773
  class DebugNgZoneForCheckNoChanges extends NgZone {
33757
33774
  constructor(checkNoChangesMode) {
33758
33775
  const zonelessEnabled = inject(ZONELESS_ENABLED);
33759
- // Use coalsecing to ensure we aren't ever running this check synchronously
33776
+ // Use coalescing to ensure we aren't ever running this check synchronously
33760
33777
  super({
33761
33778
  shouldCoalesceEventChangeDetection: true,
33762
33779
  shouldCoalesceRunChangeDetection: zonelessEnabled,
@@ -36536,6 +36553,10 @@ function getJsactionData(container) {
36536
36553
  return container._ejsa;
36537
36554
  }
36538
36555
  const JSACTION_ATTRIBUTE = 'jsaction';
36556
+ /**
36557
+ * Associates a DOM element with `jsaction` attribute to a map that contains info about all event
36558
+ * types (event names) and corresponding listeners.
36559
+ */
36539
36560
  const jsactionMap = new Map();
36540
36561
  /**
36541
36562
  * Returns a set of providers required to setup support for event replay.
@@ -36552,16 +36573,17 @@ function withEventReplay() {
36552
36573
  useValue: () => {
36553
36574
  setDisableEventReplayImpl((rEl, eventName, listenerFn) => {
36554
36575
  if (rEl.hasAttribute(JSACTION_ATTRIBUTE)) {
36555
- const el = unwrapRNode(rEl);
36576
+ const el = rEl;
36556
36577
  // We don't immediately remove the attribute here because
36557
36578
  // we need it for replay that happens after hydration.
36558
36579
  if (!jsactionMap.has(el)) {
36559
36580
  jsactionMap.set(el, new Map());
36560
36581
  }
36561
- if (!jsactionMap.get(el).has(eventName)) {
36562
- jsactionMap.get(el).set(eventName, []);
36582
+ const eventMap = jsactionMap.get(el);
36583
+ if (!eventMap.has(eventName)) {
36584
+ eventMap.set(eventName, []);
36563
36585
  }
36564
- jsactionMap.get(el).get(eventName).push(listenerFn);
36586
+ eventMap.get(eventName).push(listenerFn);
36565
36587
  }
36566
36588
  });
36567
36589
  },
@@ -36671,7 +36693,7 @@ function setJSActionAttribute(tNode, rNode, nativeElementToEvents) {
36671
36693
  }
36672
36694
  }
36673
36695
  function handleEvent(event) {
36674
- const nativeElement = unwrapRNode(event.getAction().element);
36696
+ const nativeElement = event.getAction().element;
36675
36697
  const handlerFns = jsactionMap.get(nativeElement)?.get(event.getEventType());
36676
36698
  if (!handlerFns) {
36677
36699
  return;