@angular/core 20.1.0-next.1 → 20.1.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 (76) hide show
  1. package/{api.d-Dwpmmn5j.d.ts → api.d.d.ts} +2 -2
  2. package/{chrome_dev_tools_performance.d-Dk_7kdX9.d.ts → chrome_dev_tools_performance.d.d.ts} +4 -4
  3. package/{discovery.d-AiW64LSq.d.ts → discovery.d.d.ts} +10 -5
  4. package/{event_dispatcher.d-BReQpZfC.d.ts → event_dispatcher.d.d.ts} +1 -1
  5. package/fesm2022/{attribute-BWp59EjE.mjs → attribute.mjs} +2 -2
  6. package/fesm2022/attribute.mjs.map +1 -0
  7. package/fesm2022/core.mjs +19 -21
  8. package/fesm2022/core.mjs.map +1 -1
  9. package/fesm2022/{debug_node-CGQXW8qF.mjs → debug_node.mjs} +245 -25
  10. package/fesm2022/debug_node.mjs.map +1 -0
  11. package/fesm2022/injector.mjs +53 -0
  12. package/fesm2022/injector.mjs.map +1 -0
  13. package/fesm2022/primitives/di.mjs +6 -37
  14. package/fesm2022/primitives/di.mjs.map +1 -1
  15. package/fesm2022/primitives/event-dispatch.mjs +2 -2
  16. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  17. package/fesm2022/primitives/signals.mjs +5 -5
  18. package/fesm2022/primitives/signals.mjs.map +1 -1
  19. package/fesm2022/{resource-CIODajJI.mjs → resource.mjs} +12 -8
  20. package/fesm2022/resource.mjs.map +1 -0
  21. package/fesm2022/{root_effect_scheduler-BvK6bnZD.mjs → root_effect_scheduler.mjs} +21 -7
  22. package/fesm2022/root_effect_scheduler.mjs.map +1 -0
  23. package/fesm2022/rxjs-interop.mjs +6 -6
  24. package/fesm2022/rxjs-interop.mjs.map +1 -1
  25. package/fesm2022/{signal-nCiHhWf6.mjs → signal.mjs} +2 -2
  26. package/fesm2022/signal.mjs.map +1 -0
  27. package/fesm2022/testing.mjs +147 -58
  28. package/fesm2022/testing.mjs.map +1 -1
  29. package/fesm2022/{untracked-DmD_2MlC.mjs → untracked.mjs} +3 -3
  30. package/fesm2022/untracked.mjs.map +1 -0
  31. package/fesm2022/{weak_ref-BaIq-pgY.mjs → weak_ref.mjs} +2 -2
  32. package/fesm2022/weak_ref.mjs.map +1 -0
  33. package/{graph.d-BcIOep_B.d.ts → graph.d.d.ts} +1 -1
  34. package/index.d.ts +101 -15
  35. package/package.json +2 -2
  36. package/primitives/di/index.d.ts +4 -2
  37. package/primitives/event-dispatch/index.d.ts +3 -3
  38. package/primitives/signals/index.d.ts +6 -6
  39. package/rxjs-interop/index.d.ts +5 -5
  40. package/schematics/bundles/{apply_import_manager-BsIRDO9W.cjs → apply_import_manager-C11Q8021.cjs} +3 -3
  41. package/schematics/bundles/{checker-CY7a8ko8.cjs → checker-BVnpy__J.cjs} +547 -308
  42. package/schematics/bundles/cleanup-unused-imports.cjs +35 -21
  43. package/schematics/bundles/{compiler_host-DNYQkH4l.cjs → compiler_host-j95cyBKm.cjs} +2 -2
  44. package/schematics/bundles/control-flow-migration.cjs +3 -3
  45. package/schematics/bundles/document-core.cjs +5 -5
  46. package/schematics/bundles/imports-CIX-JgAN.cjs +1 -1
  47. package/schematics/bundles/{index-BUgQDm-J.cjs → index-BkA2Tb_u.cjs} +32 -17
  48. package/schematics/bundles/{index-BJ3PYYwQ.cjs → index-DYpSE68_.cjs} +4 -4
  49. package/schematics/bundles/inject-flags.cjs +5 -5
  50. package/schematics/bundles/inject-migration.cjs +9 -4
  51. package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
  52. package/schematics/bundles/{migrate_ts_type_references-MBd4NBjn.cjs → migrate_ts_type_references-Covsxz7y.cjs} +27 -5
  53. package/schematics/bundles/ng_decorators-B5HCqr20.cjs +1 -1
  54. package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
  55. package/schematics/bundles/output-migration.cjs +6 -6
  56. package/schematics/bundles/{project_paths-C5Df24y1.cjs → project_paths-3GwjSb-R.cjs} +3 -3
  57. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
  58. package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
  59. package/schematics/bundles/route-lazy-loading.cjs +3 -3
  60. package/schematics/bundles/self-closing-tags-migration.cjs +4 -4
  61. package/schematics/bundles/signal-input-migration.cjs +7 -7
  62. package/schematics/bundles/signal-queries-migration.cjs +7 -7
  63. package/schematics/bundles/signals.cjs +7 -7
  64. package/schematics/bundles/standalone-migration.cjs +4 -4
  65. package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
  66. package/schematics/bundles/test-bed-get.cjs +4 -4
  67. package/{signal.d-BcmOdASA.d.ts → signal.d.d.ts} +2 -2
  68. package/testing/index.d.ts +84 -8
  69. package/{weak_ref.d-eGOEP9S1.d.ts → weak_ref.d.d.ts} +1 -1
  70. package/fesm2022/attribute-BWp59EjE.mjs.map +0 -1
  71. package/fesm2022/debug_node-CGQXW8qF.mjs.map +0 -1
  72. package/fesm2022/resource-CIODajJI.mjs.map +0 -1
  73. package/fesm2022/root_effect_scheduler-BvK6bnZD.mjs.map +0 -1
  74. package/fesm2022/signal-nCiHhWf6.mjs.map +0 -1
  75. package/fesm2022/untracked-DmD_2MlC.mjs.map +0 -1
  76. package/fesm2022/weak_ref-BaIq-pgY.mjs.map +0 -1
@@ -1,19 +1,19 @@
1
1
  /**
2
- * @license Angular v20.1.0-next.1
2
+ * @license Angular v20.1.0-next.3
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { NgZone, Injectable, DeferBlockState, triggerResourceLoading, renderDeferBlockState, getDeferBlocks, DeferBlockBehavior, NoopNgZone, ApplicationRef, getDebugNode, RendererFactory2, Directive, Component, Pipe, NgModule, ReflectionCapabilities, depsTracker, isComponentDefPendingResolution, resolveComponentResources, NgModuleRef, ApplicationInitStatus, LOCALE_ID, DEFAULT_LOCALE_ID, setLocaleId, ComponentFactory, getAsyncClassMetadataFn, compileComponent, compileDirective, compilePipe, patchComponentDefWithScope, compileNgModuleDefs, clearResolutionOfComponentResourcesQueue, restoreComponentResolutionQueue, internalProvideZoneChangeDetection, ChangeDetectionSchedulerImpl, COMPILER_OPTIONS, generateStandaloneInDeclarationsError, transitiveScopesFor, Compiler, DEFER_BLOCK_CONFIG, NgModuleFactory, ModuleWithComponentFactories, resetCompiledComponents, ɵsetUnknownElementStrictMode as _setUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode as _setUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode as _getUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode as _getUnknownPropertyStrictMode, flushModuleScopingQueueAsMuchAsPossible, setAllowDuplicateNgModuleIdsForTest } from './debug_node-CGQXW8qF.mjs';
8
+ import { NgZone, Injectable, DeferBlockState, triggerResourceLoading, renderDeferBlockState, getDeferBlocks, DeferBlockBehavior, NoopNgZone, ApplicationRef, getDebugNode, RendererFactory2, Directive, Component, Pipe, NgModule, ReflectionCapabilities, depsTracker, isComponentDefPendingResolution, resolveComponentResources, NgModuleRef, ApplicationInitStatus, LOCALE_ID, DEFAULT_LOCALE_ID, setLocaleId, ComponentFactory, getAsyncClassMetadataFn, compileComponent, compileDirective, compilePipe, patchComponentDefWithScope, compileNgModuleDefs, clearResolutionOfComponentResourcesQueue, restoreComponentResolutionQueue, internalProvideZoneChangeDetection, ChangeDetectionSchedulerImpl, COMPILER_OPTIONS, generateStandaloneInDeclarationsError, transitiveScopesFor, Compiler, DEFER_BLOCK_CONFIG, NgModuleFactory, ModuleWithComponentFactories, resetCompiledComponents, ɵsetUnknownElementStrictMode as _setUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode as _setUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode as _getUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode as _getUnknownPropertyStrictMode, flushModuleScopingQueueAsMuchAsPossible, setAllowDuplicateNgModuleIdsForTest } from './debug_node.mjs';
9
9
  import { Subscription } from 'rxjs';
10
- import { inject as inject$1, EnvironmentInjector, ErrorHandler, CONTAINER_HEADER_OFFSET, InjectionToken, PendingTasksInternal, ZONELESS_ENABLED, ChangeDetectionScheduler, EffectScheduler, stringify, getInjectableDef, resolveForwardRef, NG_COMP_DEF, NG_DIR_DEF, NG_PIPE_DEF, NG_INJ_DEF, NG_MOD_DEF, ENVIRONMENT_INITIALIZER, Injector, isEnvironmentProviders, INTERNAL_APPLICATION_ERROR_HANDLER, runInInjectionContext } from './root_effect_scheduler-BvK6bnZD.mjs';
10
+ import { inject as inject$1, EnvironmentInjector, ErrorHandler, CONTAINER_HEADER_OFFSET, InjectionToken, PendingTasksInternal, ZONELESS_ENABLED, ChangeDetectionScheduler, EffectScheduler, stringify, getInjectableDef, resolveForwardRef, NG_COMP_DEF, NG_DIR_DEF, NG_PIPE_DEF, NG_INJ_DEF, NG_MOD_DEF, ENVIRONMENT_INITIALIZER, Injector, isEnvironmentProviders, INTERNAL_APPLICATION_ERROR_HANDLER, runInInjectionContext } from './root_effect_scheduler.mjs';
11
11
  import { ResourceLoader } from '@angular/compiler';
12
- import './signal-nCiHhWf6.mjs';
12
+ import './signal.mjs';
13
13
  import '@angular/core/primitives/signals';
14
14
  import 'rxjs/operators';
15
- import './attribute-BWp59EjE.mjs';
16
- import './primitives/di.mjs';
15
+ import './attribute.mjs';
16
+ import './injector.mjs';
17
17
  import '@angular/core/primitives/di';
18
18
 
19
19
  /**
@@ -1834,8 +1834,8 @@ class TestBedImpl {
1834
1834
  static runInInjectionContext(fn) {
1835
1835
  return TestBedImpl.INSTANCE.runInInjectionContext(fn);
1836
1836
  }
1837
- static createComponent(component) {
1838
- return TestBedImpl.INSTANCE.createComponent(component);
1837
+ static createComponent(component, options) {
1838
+ return TestBedImpl.INSTANCE.createComponent(component, options);
1839
1839
  }
1840
1840
  static resetTestingModule() {
1841
1841
  return TestBedImpl.INSTANCE.resetTestingModule();
@@ -2029,7 +2029,7 @@ class TestBedImpl {
2029
2029
  overrideTemplate(component, template) {
2030
2030
  return this.overrideComponent(component, { set: { template, templateUrl: null } });
2031
2031
  }
2032
- createComponent(type) {
2032
+ createComponent(type, options) {
2033
2033
  const testComponentRenderer = this.inject(TestComponentRenderer);
2034
2034
  const rootElId = `root${_nextRootElementId++}`;
2035
2035
  testComponentRenderer.insertRootElement(rootElId);
@@ -2043,7 +2043,7 @@ class TestBedImpl {
2043
2043
  }
2044
2044
  const componentFactory = new ComponentFactory(componentDef);
2045
2045
  const initComponent = () => {
2046
- const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this.testModuleRef);
2046
+ const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this.testModuleRef, undefined, options?.bindings);
2047
2047
  return this.runInInjectionContext(() => new ComponentFixture(componentRef));
2048
2048
  };
2049
2049
  const noNgZone = this.inject(ComponentFixtureNoNgZone, false);
@@ -2458,8 +2458,9 @@ class FakeNavigation {
2458
2458
  const hashChange = isHashChange(fromUrl, toUrl);
2459
2459
  const destination = new FakeNavigationDestination({
2460
2460
  url: toUrl.toString(),
2461
- sameDocument: true,
2461
+ sameDocument: true, // history.pushState/replaceState are always same-document
2462
2462
  historyState: data,
2463
+ state: undefined, // No Navigation API state directly from history.pushState
2463
2464
  });
2464
2465
  const result = new InternalNavigationResult(this);
2465
2466
  const intercepted = this.userAgentNavigate(destination, result, {
@@ -2652,6 +2653,16 @@ class FakeNavigation {
2652
2653
  isDisposed() {
2653
2654
  return this.disposed;
2654
2655
  }
2656
+ abortOngoingNavigation(eventToAbort, reason) {
2657
+ if (this.navigateEvent !== eventToAbort) {
2658
+ return;
2659
+ }
2660
+ if (this.navigateEvent.abortController.signal.aborted) {
2661
+ return;
2662
+ }
2663
+ const abortReason = reason ?? new DOMException('Navigation aborted', 'AbortError');
2664
+ this.navigateEvent.cancel(abortReason);
2665
+ }
2655
2666
  /**
2656
2667
  * Implementation for all navigations and traversals.
2657
2668
  * @returns true if the event was intercepted, otherwise false
@@ -2661,21 +2672,24 @@ class FakeNavigation {
2661
2672
  // entry.
2662
2673
  this.canSetInitialEntry = false;
2663
2674
  if (this.navigateEvent) {
2664
- this.navigateEvent.cancel(new DOMException('Navigation was aborted', 'AbortError'));
2665
- this.navigateEvent = null;
2675
+ this.abortOngoingNavigation(this.navigateEvent, new DOMException('Navigation superseded by a new navigation.', 'AbortError'));
2666
2676
  }
2667
- return dispatchNavigateEvent({
2677
+ // TODO(atscott): Disposing doesn't really do much because new requests are still processed
2678
+ // if (this.disposed) {
2679
+ // return false;
2680
+ // }
2681
+ const dispatchResultIsTrueIfNoInterception = dispatchNavigateEvent({
2668
2682
  navigationType: options.navigationType,
2669
2683
  cancelable: options.cancelable,
2670
2684
  canIntercept: options.canIntercept,
2671
2685
  userInitiated: options.userInitiated,
2672
2686
  hashChange: options.hashChange,
2673
- signal: result.signal,
2674
2687
  destination,
2675
2688
  info: options.info,
2676
2689
  sameDocument: destination.sameDocument,
2677
2690
  result,
2678
2691
  });
2692
+ return !dispatchResultIsTrueIfNoInterception;
2679
2693
  }
2680
2694
  /**
2681
2695
  * Implementation for a push or replace navigation.
@@ -2733,7 +2747,9 @@ class FakeNavigation {
2733
2747
  }
2734
2748
  if (navigationType === 'push' || navigationType === 'replace') {
2735
2749
  const index = this.currentEntryIndex;
2736
- const key = navigationType === 'push' ? String(this.nextKey++) : this.currentEntry.key;
2750
+ const key = navigationType === 'push'
2751
+ ? String(this.nextKey++)
2752
+ : (oldCurrentNHE?.key ?? String(this.nextKey++));
2737
2753
  const newNHE = new FakeNavigationHistoryEntry(this.eventTarget, destination.url, {
2738
2754
  id: String(this.nextId++),
2739
2755
  key,
@@ -2867,19 +2883,21 @@ class FakeNavigationHistoryEntry {
2867
2883
  *
2868
2884
  * https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigate-event-firing
2869
2885
  */
2870
- function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, signal, destination, info, sameDocument, result, }) {
2886
+ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, destination, info, sameDocument, result, }) {
2871
2887
  const { navigation } = result;
2888
+ const eventAbortController = new AbortController();
2872
2889
  const event = new Event('navigate', { bubbles: false, cancelable });
2873
- event.focusResetBehavior = null;
2874
- event.scrollBehavior = null;
2875
- event.interceptionState = 'none';
2890
+ event.navigationType = navigationType;
2891
+ event.destination = destination;
2876
2892
  event.canIntercept = canIntercept;
2877
2893
  event.userInitiated = userInitiated;
2878
2894
  event.hashChange = hashChange;
2879
- event.navigationType = navigationType;
2880
- event.signal = signal;
2881
- event.destination = destination;
2895
+ event.signal = eventAbortController.signal;
2896
+ event.abortController = eventAbortController;
2882
2897
  event.info = info;
2898
+ event.focusResetBehavior = null;
2899
+ event.scrollBehavior = null;
2900
+ event.interceptionState = 'none';
2883
2901
  event.downloadRequest = null;
2884
2902
  event.formData = null;
2885
2903
  event.result = result;
@@ -2921,7 +2939,7 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2921
2939
  processScrollBehavior(event);
2922
2940
  };
2923
2941
  // https://whatpr.org/html/10919/nav-history-apis.html#dom-navigationprecommitcontroller-redirect
2924
- function redirect(url) {
2942
+ function redirect(url, options = {}) {
2925
2943
  if (event.interceptionState === 'none') {
2926
2944
  throw new Error('cannot redirect when event is not intercepted');
2927
2945
  }
@@ -2931,8 +2949,17 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2931
2949
  if (event.navigationType !== 'push' && event.navigationType !== 'replace') {
2932
2950
  throw new DOMException(`cannot redirect when navigationType is not 'push' or 'replace`, 'InvalidStateError');
2933
2951
  }
2934
- const toUrl = new URL(url, navigation.currentEntry.url);
2935
- event.destination.url = toUrl.href;
2952
+ const destinationUrl = new URL(url, navigation.currentEntry.url);
2953
+ if (options.history === 'push' || options.history === 'replace') {
2954
+ event.navigationType = options.history;
2955
+ }
2956
+ if (options.hasOwnProperty('state')) {
2957
+ event.destination.state = options.state;
2958
+ }
2959
+ event.destination.url = destinationUrl.href;
2960
+ if (options.hasOwnProperty('info')) {
2961
+ event.info = options.info;
2962
+ }
2936
2963
  }
2937
2964
  // https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
2938
2965
  // "Let commit be the following steps:"
@@ -2940,12 +2967,9 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2940
2967
  if (result.signal.aborted) {
2941
2968
  return;
2942
2969
  }
2943
- if (event.interceptionState !== 'none') {
2970
+ navigation.transition?.committedResolve();
2971
+ if (event.interceptionState === 'intercepted') {
2944
2972
  event.interceptionState = 'committed';
2945
- if (!navigation.currentEntry) {
2946
- throw new Error('from history entry should not be null');
2947
- }
2948
- navigation.transition = new InternalNavigationTransition(navigation.currentEntry, navigationType);
2949
2973
  switch (event.navigationType) {
2950
2974
  case 'push':
2951
2975
  case 'replace': {
@@ -2974,19 +2998,27 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2974
2998
  return;
2975
2999
  }
2976
3000
  if (event !== navigation.navigateEvent) {
2977
- throw new Error("Navigation's ongoing event not equal to resolved event");
3001
+ if (!result.signal.aborted && result.committedTo) {
3002
+ result.finishedReject(new DOMException('Navigation superseded before handler completion', 'AbortError'));
3003
+ }
3004
+ return;
2978
3005
  }
2979
3006
  navigation.navigateEvent = null;
2980
3007
  finishNavigationEvent(event, true);
2981
- const navigatesuccessEvent = new Event('navigatesuccess', { bubbles: false, cancelable });
3008
+ const navigatesuccessEvent = new Event('navigatesuccess', {
3009
+ bubbles: false,
3010
+ cancelable: false,
3011
+ });
2982
3012
  navigation.eventTarget.dispatchEvent(navigatesuccessEvent);
2983
3013
  result.finishedResolve();
2984
- if (navigation.transition !== null) {
2985
- navigation.transition.finishedResolve();
2986
- }
3014
+ navigation.transition?.finishedResolve();
2987
3015
  navigation.transition = null;
2988
3016
  })
2989
- .catch((reason) => event.cancel(reason));
3017
+ .catch((reason) => {
3018
+ if (!event.abortController.signal.aborted) {
3019
+ event.cancel(reason);
3020
+ }
3021
+ });
2990
3022
  }
2991
3023
  // Internal only.
2992
3024
  // https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
@@ -2995,37 +3027,84 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2995
3027
  if (result.signal.aborted) {
2996
3028
  return;
2997
3029
  }
2998
- if (event !== navigation.navigateEvent) {
2999
- throw new Error("Navigation's ongoing event not equal to resolved event");
3030
+ this.abortController.abort(reason);
3031
+ const isCurrentGlobalNavigationEvent = this === navigation.navigateEvent;
3032
+ if (isCurrentGlobalNavigationEvent) {
3033
+ navigation.navigateEvent = null;
3000
3034
  }
3001
- navigation.navigateEvent = null;
3002
- if (event.interceptionState !== 'intercepted') {
3003
- finishNavigationEvent(event, false);
3035
+ if (this.interceptionState !== 'intercepted' && this.interceptionState !== 'finished') {
3036
+ finishNavigationEvent(this, false);
3004
3037
  }
3005
- const navigateerrorEvent = new Event('navigateerror', { bubbles: false, cancelable });
3038
+ else if (this.interceptionState === 'intercepted') {
3039
+ this.interceptionState = 'finished';
3040
+ }
3041
+ const navigateerrorEvent = new Event('navigateerror', {
3042
+ bubbles: false,
3043
+ cancelable,
3044
+ });
3045
+ navigateerrorEvent.error = reason;
3006
3046
  navigation.eventTarget.dispatchEvent(navigateerrorEvent);
3007
- result.finishedReject(reason);
3008
- if (navigation.transition !== null) {
3009
- navigation.transition.finishedReject(reason);
3047
+ if (result.committedTo === null && !result.signal.aborted) {
3048
+ result.committedReject(reason);
3010
3049
  }
3050
+ result.finishedReject(reason);
3051
+ const transition = navigation.transition;
3052
+ transition?.committedReject(reason);
3053
+ transition?.finishedReject(reason);
3011
3054
  navigation.transition = null;
3012
3055
  };
3013
3056
  function dispatch() {
3014
3057
  navigation.navigateEvent = event;
3015
- navigation.eventTarget.dispatchEvent(event);
3016
- if (precommitHandlers.length === 0) {
3017
- commit();
3058
+ const dispatchResult = navigation.eventTarget.dispatchEvent(event);
3059
+ if (event.interceptionState === 'intercepted') {
3060
+ if (!navigation.currentEntry) {
3061
+ event.cancel(new DOMException('Cannot create transition without a currentEntry for intercepted navigation.', 'InvalidStateError'));
3062
+ return;
3063
+ }
3064
+ const transition = new InternalNavigationTransition(navigation.currentEntry, navigationType);
3065
+ navigation.transition = transition;
3066
+ // Mark transition.finished as handled (Spec Step 33.4)
3067
+ transition.finished.catch(() => { });
3068
+ transition.committed.catch(() => { });
3069
+ }
3070
+ if (!dispatchResult && event.cancelable) {
3071
+ if (!event.abortController.signal.aborted) {
3072
+ event.cancel(new DOMException('Navigation prevented by event.preventDefault()', 'AbortError'));
3073
+ }
3018
3074
  }
3019
3075
  else {
3020
- const precommitController = { redirect };
3021
- const precommitPromisesList = precommitHandlers.map((handler) => handler(precommitController));
3022
- Promise.all(precommitPromisesList)
3023
- .then(() => commit())
3024
- .catch((reason) => event.cancel(reason));
3076
+ if (precommitHandlers.length === 0) {
3077
+ commit();
3078
+ }
3079
+ else {
3080
+ const precommitController = { redirect };
3081
+ const precommitPromisesList = precommitHandlers.map((handler) => {
3082
+ let p;
3083
+ try {
3084
+ p = handler(precommitController);
3085
+ }
3086
+ catch (e) {
3087
+ p = Promise.reject(e);
3088
+ }
3089
+ p.catch(() => { });
3090
+ return p;
3091
+ });
3092
+ Promise.all(precommitPromisesList)
3093
+ .then(() => commit())
3094
+ .catch((reason) => {
3095
+ if (event.abortController.signal.aborted) {
3096
+ return;
3097
+ }
3098
+ if (navigation.transition) {
3099
+ navigation.transition.committedReject(reason);
3100
+ }
3101
+ event.cancel(reason);
3102
+ });
3103
+ }
3025
3104
  }
3026
3105
  }
3027
3106
  dispatch();
3028
- return event.interceptionState !== 'none';
3107
+ return event.interceptionState === 'none';
3029
3108
  }
3030
3109
  /** https://whatpr.org/html/10919/nav-history-apis.html#navigateevent-finish */
3031
3110
  function finishNavigationEvent(event, didFulfill) {
@@ -3036,7 +3115,6 @@ function finishNavigationEvent(event, didFulfill) {
3036
3115
  if (didFulfill === true) {
3037
3116
  throw new Error('didFulfill should be false');
3038
3117
  }
3039
- // assert precommit handlers is not empty
3040
3118
  event.interceptionState = 'finished';
3041
3119
  return;
3042
3120
  }
@@ -3054,7 +3132,10 @@ function potentiallyResetFocus(event) {
3054
3132
  if (event.interceptionState !== 'committed' && event.interceptionState !== 'scrolled') {
3055
3133
  throw new Error('cannot reset focus if navigation event is not committed or scrolled');
3056
3134
  }
3057
- // TODO(atscott): The rest of the steps
3135
+ if (event.focusResetBehavior === 'manual') {
3136
+ return;
3137
+ }
3138
+ // TODO(atscott): the rest of the steps
3058
3139
  }
3059
3140
  function potentiallyResetScroll(event) {
3060
3141
  if (event.interceptionState !== 'committed' && event.interceptionState !== 'scrolled') {
@@ -3145,8 +3226,11 @@ class InternalNavigationTransition {
3145
3226
  from;
3146
3227
  navigationType;
3147
3228
  finished;
3229
+ committed;
3148
3230
  finishedResolve;
3149
3231
  finishedReject;
3232
+ committedResolve;
3233
+ committedReject;
3150
3234
  constructor(from, navigationType) {
3151
3235
  this.from = from;
3152
3236
  this.navigationType = navigationType;
@@ -3154,8 +3238,13 @@ class InternalNavigationTransition {
3154
3238
  this.finishedReject = reject;
3155
3239
  this.finishedResolve = resolve;
3156
3240
  });
3241
+ this.committed = new Promise((resolve, reject) => {
3242
+ this.committedReject = reject;
3243
+ this.committedResolve = resolve;
3244
+ });
3157
3245
  // All rejections are handled.
3158
3246
  this.finished.catch(() => { });
3247
+ this.committed.catch(() => { });
3159
3248
  }
3160
3249
  }
3161
3250
  /**
@@ -3184,7 +3273,7 @@ class InternalNavigationResult {
3184
3273
  };
3185
3274
  this.committedReject = reject;
3186
3275
  });
3187
- this.finished = new Promise(async (resolve, reject) => {
3276
+ this.finished = new Promise((resolve, reject) => {
3188
3277
  this.finishedResolve = () => {
3189
3278
  if (this.committedTo === null) {
3190
3279
  throw new Error('NavigateEvent should have been committed before resolving finished promise.');