@angular/core 20.0.6 → 20.1.0-next.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 (74) hide show
  1. package/{api.d.d.ts → api.d-Dwpmmn5j.d.ts} +2 -2
  2. package/{chrome_dev_tools_performance.d.d.ts → chrome_dev_tools_performance.d-Dk_7kdX9.d.ts} +7 -3
  3. package/{discovery.d.d.ts → discovery.d-AiW64LSq.d.ts} +5 -6
  4. package/{event_dispatcher.d.d.ts → event_dispatcher.d-BReQpZfC.d.ts} +1 -1
  5. package/fesm2022/{attribute.mjs → attribute-BWp59EjE.mjs} +2 -2
  6. package/fesm2022/attribute-BWp59EjE.mjs.map +1 -0
  7. package/fesm2022/core.mjs +22 -28
  8. package/fesm2022/core.mjs.map +1 -1
  9. package/fesm2022/{debug_node.mjs → debug_node-CGQXW8qF.mjs} +1479 -1466
  10. package/fesm2022/debug_node-CGQXW8qF.mjs.map +1 -0
  11. package/fesm2022/primitives/di.mjs +1 -1
  12. package/fesm2022/primitives/di.mjs.map +1 -1
  13. package/fesm2022/primitives/event-dispatch.mjs +2 -2
  14. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  15. package/fesm2022/primitives/signals.mjs +5 -5
  16. package/fesm2022/primitives/signals.mjs.map +1 -1
  17. package/fesm2022/{resource.mjs → resource-CIODajJI.mjs} +8 -12
  18. package/fesm2022/resource-CIODajJI.mjs.map +1 -0
  19. package/fesm2022/{root_effect_scheduler.mjs → root_effect_scheduler-BvK6bnZD.mjs} +20 -27
  20. package/fesm2022/root_effect_scheduler-BvK6bnZD.mjs.map +1 -0
  21. package/fesm2022/rxjs-interop.mjs +5 -5
  22. package/fesm2022/rxjs-interop.mjs.map +1 -1
  23. package/fesm2022/{signal.mjs → signal-nCiHhWf6.mjs} +2 -2
  24. package/fesm2022/signal-nCiHhWf6.mjs.map +1 -0
  25. package/fesm2022/testing.mjs +72 -171
  26. package/fesm2022/testing.mjs.map +1 -1
  27. package/fesm2022/{untracked.mjs → untracked-DmD_2MlC.mjs} +3 -3
  28. package/fesm2022/untracked-DmD_2MlC.mjs.map +1 -0
  29. package/fesm2022/{weak_ref.mjs → weak_ref-BaIq-pgY.mjs} +2 -2
  30. package/fesm2022/weak_ref-BaIq-pgY.mjs.map +1 -0
  31. package/{graph.d.d.ts → graph.d-BcIOep_B.d.ts} +1 -1
  32. package/index.d.ts +23 -16
  33. package/package.json +2 -2
  34. package/primitives/di/index.d.ts +1 -1
  35. package/primitives/event-dispatch/index.d.ts +3 -3
  36. package/primitives/signals/index.d.ts +6 -6
  37. package/rxjs-interop/index.d.ts +5 -5
  38. package/schematics/bundles/{apply_import_manager-mlmcgZ0v.cjs → apply_import_manager-BsIRDO9W.cjs} +3 -3
  39. package/schematics/bundles/{checker-a0VNmSrQ.cjs → checker-CY7a8ko8.cjs} +771 -642
  40. package/schematics/bundles/cleanup-unused-imports.cjs +21 -35
  41. package/schematics/bundles/{compiler_host-CwrMDc6k.cjs → compiler_host-DNYQkH4l.cjs} +2 -2
  42. package/schematics/bundles/control-flow-migration.cjs +3 -3
  43. package/schematics/bundles/document-core.cjs +5 -5
  44. package/schematics/bundles/imports-CIX-JgAN.cjs +1 -1
  45. package/schematics/bundles/{index-DAP9ZmeX.cjs → index-BJ3PYYwQ.cjs} +17 -16
  46. package/schematics/bundles/{index-jMQgXbRg.cjs → index-BUgQDm-J.cjs} +1018 -589
  47. package/schematics/bundles/inject-flags.cjs +5 -5
  48. package/schematics/bundles/inject-migration.cjs +4 -9
  49. package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
  50. package/schematics/bundles/{migrate_ts_type_references-CX0snBqz.cjs → migrate_ts_type_references-MBd4NBjn.cjs} +26 -77
  51. package/schematics/bundles/ng_decorators-B5HCqr20.cjs +1 -1
  52. package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
  53. package/schematics/bundles/output-migration.cjs +6 -6
  54. package/schematics/bundles/{project_paths-C4WM31v5.cjs → project_paths-C5Df24y1.cjs} +3 -3
  55. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
  56. package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
  57. package/schematics/bundles/route-lazy-loading.cjs +3 -3
  58. package/schematics/bundles/self-closing-tags-migration.cjs +7 -19
  59. package/schematics/bundles/signal-input-migration.cjs +28 -12
  60. package/schematics/bundles/signal-queries-migration.cjs +7 -7
  61. package/schematics/bundles/signals.cjs +7 -7
  62. package/schematics/bundles/standalone-migration.cjs +4 -4
  63. package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
  64. package/schematics/bundles/test-bed-get.cjs +4 -4
  65. package/{signal.d.d.ts → signal.d-BcmOdASA.d.ts} +2 -2
  66. package/testing/index.d.ts +6 -73
  67. package/{weak_ref.d.d.ts → weak_ref.d-eGOEP9S1.d.ts} +1 -1
  68. package/fesm2022/attribute.mjs.map +0 -1
  69. package/fesm2022/debug_node.mjs.map +0 -1
  70. package/fesm2022/resource.mjs.map +0 -1
  71. package/fesm2022/root_effect_scheduler.mjs.map +0 -1
  72. package/fesm2022/signal.mjs.map +0 -1
  73. package/fesm2022/untracked.mjs.map +0 -1
  74. package/fesm2022/weak_ref.mjs.map +0 -1
@@ -1,18 +1,18 @@
1
1
  /**
2
- * @license Angular v20.0.6
2
+ * @license Angular v20.1.0-next.1
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.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-CGQXW8qF.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.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-BvK6bnZD.mjs';
11
11
  import { ResourceLoader } from '@angular/compiler';
12
- import './signal.mjs';
12
+ import './signal-nCiHhWf6.mjs';
13
13
  import '@angular/core/primitives/signals';
14
14
  import 'rxjs/operators';
15
- import './attribute.mjs';
15
+ import './attribute-BWp59EjE.mjs';
16
16
  import './primitives/di.mjs';
17
17
  import '@angular/core/primitives/di';
18
18
 
@@ -408,9 +408,17 @@ class ComponentFixture {
408
408
  }
409
409
 
410
410
  const _Zone = typeof Zone !== 'undefined' ? Zone : null;
411
- const fakeAsyncTestModule = _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')];
412
- const fakeAsyncTestModuleNotLoadedErrorMessage = `zone-testing.js is needed for the fakeAsync() test helper but could not be found.
413
- Please make sure that your environment includes zone.js/testing`;
411
+ function getFakeAsyncTestModule() {
412
+ return _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')];
413
+ }
414
+ function withFakeAsyncTestModule(fn) {
415
+ const fakeAsyncTestModule = getFakeAsyncTestModule();
416
+ if (!fakeAsyncTestModule) {
417
+ throw new Error(`zone-testing.js is needed for the fakeAsync() test helper but could not be found.
418
+ Please make sure that your environment includes zone.js/testing`);
419
+ }
420
+ return fn(fakeAsyncTestModule);
421
+ }
414
422
  /**
415
423
  * Clears out the shared fake async zone for a test.
416
424
  * To be called in a global `beforeEach`.
@@ -418,14 +426,11 @@ const fakeAsyncTestModuleNotLoadedErrorMessage = `zone-testing.js is needed for
418
426
  * @publicApi
419
427
  */
420
428
  function resetFakeAsyncZone() {
421
- if (fakeAsyncTestModule) {
422
- return fakeAsyncTestModule.resetFakeAsyncZone();
423
- }
424
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
429
+ withFakeAsyncTestModule((v) => v.resetFakeAsyncZone());
425
430
  }
426
431
  function resetFakeAsyncZoneIfExists() {
427
- if (fakeAsyncTestModule && Zone['ProxyZoneSpec']?.isLoaded()) {
428
- fakeAsyncTestModule.resetFakeAsyncZone();
432
+ if (getFakeAsyncTestModule() && Zone['ProxyZoneSpec']?.isLoaded()) {
433
+ getFakeAsyncTestModule().resetFakeAsyncZone();
429
434
  }
430
435
  }
431
436
  /**
@@ -453,10 +458,7 @@ function resetFakeAsyncZoneIfExists() {
453
458
  * @publicApi
454
459
  */
455
460
  function fakeAsync(fn, options) {
456
- if (fakeAsyncTestModule) {
457
- return fakeAsyncTestModule.fakeAsync(fn, options);
458
- }
459
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
461
+ return withFakeAsyncTestModule((v) => v.fakeAsync(fn, options));
460
462
  }
461
463
  /**
462
464
  * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
@@ -525,10 +527,7 @@ function fakeAsync(fn, options) {
525
527
  function tick(millis = 0, tickOptions = {
526
528
  processNewMacroTasksSynchronously: true,
527
529
  }) {
528
- if (fakeAsyncTestModule) {
529
- return fakeAsyncTestModule.tick(millis, tickOptions);
530
- }
531
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
530
+ return withFakeAsyncTestModule((m) => m.tick(millis, tickOptions));
532
531
  }
533
532
  /**
534
533
  * Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in
@@ -542,10 +541,7 @@ function tick(millis = 0, tickOptions = {
542
541
  * @publicApi
543
542
  */
544
543
  function flush(maxTurns) {
545
- if (fakeAsyncTestModule) {
546
- return fakeAsyncTestModule.flush(maxTurns);
547
- }
548
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
544
+ return withFakeAsyncTestModule((m) => m.flush(maxTurns));
549
545
  }
550
546
  /**
551
547
  * Discard all remaining periodic tasks.
@@ -553,10 +549,7 @@ function flush(maxTurns) {
553
549
  * @publicApi
554
550
  */
555
551
  function discardPeriodicTasks() {
556
- if (fakeAsyncTestModule) {
557
- return fakeAsyncTestModule.discardPeriodicTasks();
558
- }
559
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
552
+ return withFakeAsyncTestModule((m) => m.discardPeriodicTasks());
560
553
  }
561
554
  /**
562
555
  * Flush any pending microtasks.
@@ -564,10 +557,7 @@ function discardPeriodicTasks() {
564
557
  * @publicApi
565
558
  */
566
559
  function flushMicrotasks() {
567
- if (fakeAsyncTestModule) {
568
- return fakeAsyncTestModule.flushMicrotasks();
569
- }
570
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
560
+ return withFakeAsyncTestModule((m) => m.flushMicrotasks());
571
561
  }
572
562
 
573
563
  let _nextReferenceId = 0;
@@ -2468,9 +2458,8 @@ class FakeNavigation {
2468
2458
  const hashChange = isHashChange(fromUrl, toUrl);
2469
2459
  const destination = new FakeNavigationDestination({
2470
2460
  url: toUrl.toString(),
2471
- sameDocument: true, // history.pushState/replaceState are always same-document
2461
+ sameDocument: true,
2472
2462
  historyState: data,
2473
- state: undefined, // No Navigation API state directly from history.pushState
2474
2463
  });
2475
2464
  const result = new InternalNavigationResult(this);
2476
2465
  const intercepted = this.userAgentNavigate(destination, result, {
@@ -2663,16 +2652,6 @@ class FakeNavigation {
2663
2652
  isDisposed() {
2664
2653
  return this.disposed;
2665
2654
  }
2666
- abortOngoingNavigation(eventToAbort, reason) {
2667
- if (this.navigateEvent !== eventToAbort) {
2668
- return;
2669
- }
2670
- if (this.navigateEvent.abortController.signal.aborted) {
2671
- return;
2672
- }
2673
- const abortReason = reason ?? new DOMException('Navigation aborted', 'AbortError');
2674
- this.navigateEvent.cancel(abortReason);
2675
- }
2676
2655
  /**
2677
2656
  * Implementation for all navigations and traversals.
2678
2657
  * @returns true if the event was intercepted, otherwise false
@@ -2682,24 +2661,21 @@ class FakeNavigation {
2682
2661
  // entry.
2683
2662
  this.canSetInitialEntry = false;
2684
2663
  if (this.navigateEvent) {
2685
- this.abortOngoingNavigation(this.navigateEvent, new DOMException('Navigation superseded by a new navigation.', 'AbortError'));
2664
+ this.navigateEvent.cancel(new DOMException('Navigation was aborted', 'AbortError'));
2665
+ this.navigateEvent = null;
2686
2666
  }
2687
- // TODO(atscott): Disposing doesn't really do much because new requests are still processed
2688
- // if (this.disposed) {
2689
- // return false;
2690
- // }
2691
- const dispatchResultIsTrueIfNoInterception = dispatchNavigateEvent({
2667
+ return dispatchNavigateEvent({
2692
2668
  navigationType: options.navigationType,
2693
2669
  cancelable: options.cancelable,
2694
2670
  canIntercept: options.canIntercept,
2695
2671
  userInitiated: options.userInitiated,
2696
2672
  hashChange: options.hashChange,
2673
+ signal: result.signal,
2697
2674
  destination,
2698
2675
  info: options.info,
2699
2676
  sameDocument: destination.sameDocument,
2700
2677
  result,
2701
2678
  });
2702
- return !dispatchResultIsTrueIfNoInterception;
2703
2679
  }
2704
2680
  /**
2705
2681
  * Implementation for a push or replace navigation.
@@ -2757,9 +2733,7 @@ class FakeNavigation {
2757
2733
  }
2758
2734
  if (navigationType === 'push' || navigationType === 'replace') {
2759
2735
  const index = this.currentEntryIndex;
2760
- const key = navigationType === 'push'
2761
- ? String(this.nextKey++)
2762
- : (oldCurrentNHE?.key ?? String(this.nextKey++));
2736
+ const key = navigationType === 'push' ? String(this.nextKey++) : this.currentEntry.key;
2763
2737
  const newNHE = new FakeNavigationHistoryEntry(this.eventTarget, destination.url, {
2764
2738
  id: String(this.nextId++),
2765
2739
  key,
@@ -2893,21 +2867,19 @@ class FakeNavigationHistoryEntry {
2893
2867
  *
2894
2868
  * https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigate-event-firing
2895
2869
  */
2896
- function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, destination, info, sameDocument, result, }) {
2870
+ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, signal, destination, info, sameDocument, result, }) {
2897
2871
  const { navigation } = result;
2898
- const eventAbortController = new AbortController();
2899
2872
  const event = new Event('navigate', { bubbles: false, cancelable });
2900
- event.navigationType = navigationType;
2901
- event.destination = destination;
2873
+ event.focusResetBehavior = null;
2874
+ event.scrollBehavior = null;
2875
+ event.interceptionState = 'none';
2902
2876
  event.canIntercept = canIntercept;
2903
2877
  event.userInitiated = userInitiated;
2904
2878
  event.hashChange = hashChange;
2905
- event.signal = eventAbortController.signal;
2906
- event.abortController = eventAbortController;
2879
+ event.navigationType = navigationType;
2880
+ event.signal = signal;
2881
+ event.destination = destination;
2907
2882
  event.info = info;
2908
- event.focusResetBehavior = null;
2909
- event.scrollBehavior = null;
2910
- event.interceptionState = 'none';
2911
2883
  event.downloadRequest = null;
2912
2884
  event.formData = null;
2913
2885
  event.result = result;
@@ -2949,7 +2921,7 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2949
2921
  processScrollBehavior(event);
2950
2922
  };
2951
2923
  // https://whatpr.org/html/10919/nav-history-apis.html#dom-navigationprecommitcontroller-redirect
2952
- function redirect(url, options = {}) {
2924
+ function redirect(url) {
2953
2925
  if (event.interceptionState === 'none') {
2954
2926
  throw new Error('cannot redirect when event is not intercepted');
2955
2927
  }
@@ -2959,17 +2931,8 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2959
2931
  if (event.navigationType !== 'push' && event.navigationType !== 'replace') {
2960
2932
  throw new DOMException(`cannot redirect when navigationType is not 'push' or 'replace`, 'InvalidStateError');
2961
2933
  }
2962
- const destinationUrl = new URL(url, navigation.currentEntry.url);
2963
- if (options.history === 'push' || options.history === 'replace') {
2964
- event.navigationType = options.history;
2965
- }
2966
- if (options.hasOwnProperty('state')) {
2967
- event.destination.state = options.state;
2968
- }
2969
- event.destination.url = destinationUrl.href;
2970
- if (options.hasOwnProperty('info')) {
2971
- event.info = options.info;
2972
- }
2934
+ const toUrl = new URL(url, navigation.currentEntry.url);
2935
+ event.destination.url = toUrl.href;
2973
2936
  }
2974
2937
  // https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
2975
2938
  // "Let commit be the following steps:"
@@ -2977,9 +2940,12 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
2977
2940
  if (result.signal.aborted) {
2978
2941
  return;
2979
2942
  }
2980
- navigation.transition?.committedResolve();
2981
- if (event.interceptionState === 'intercepted') {
2943
+ if (event.interceptionState !== 'none') {
2982
2944
  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);
2983
2949
  switch (event.navigationType) {
2984
2950
  case 'push':
2985
2951
  case 'replace': {
@@ -3008,27 +2974,19 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
3008
2974
  return;
3009
2975
  }
3010
2976
  if (event !== navigation.navigateEvent) {
3011
- if (!result.signal.aborted && result.committedTo) {
3012
- result.finishedReject(new DOMException('Navigation superseded before handler completion', 'AbortError'));
3013
- }
3014
- return;
2977
+ throw new Error("Navigation's ongoing event not equal to resolved event");
3015
2978
  }
3016
2979
  navigation.navigateEvent = null;
3017
2980
  finishNavigationEvent(event, true);
3018
- const navigatesuccessEvent = new Event('navigatesuccess', {
3019
- bubbles: false,
3020
- cancelable: false,
3021
- });
2981
+ const navigatesuccessEvent = new Event('navigatesuccess', { bubbles: false, cancelable });
3022
2982
  navigation.eventTarget.dispatchEvent(navigatesuccessEvent);
3023
2983
  result.finishedResolve();
3024
- navigation.transition?.finishedResolve();
2984
+ if (navigation.transition !== null) {
2985
+ navigation.transition.finishedResolve();
2986
+ }
3025
2987
  navigation.transition = null;
3026
2988
  })
3027
- .catch((reason) => {
3028
- if (!event.abortController.signal.aborted) {
3029
- event.cancel(reason);
3030
- }
3031
- });
2989
+ .catch((reason) => event.cancel(reason));
3032
2990
  }
3033
2991
  // Internal only.
3034
2992
  // https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
@@ -3037,84 +2995,37 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
3037
2995
  if (result.signal.aborted) {
3038
2996
  return;
3039
2997
  }
3040
- this.abortController.abort(reason);
3041
- const isCurrentGlobalNavigationEvent = this === navigation.navigateEvent;
3042
- if (isCurrentGlobalNavigationEvent) {
3043
- navigation.navigateEvent = null;
2998
+ if (event !== navigation.navigateEvent) {
2999
+ throw new Error("Navigation's ongoing event not equal to resolved event");
3044
3000
  }
3045
- if (this.interceptionState !== 'intercepted' && this.interceptionState !== 'finished') {
3046
- finishNavigationEvent(this, false);
3047
- }
3048
- else if (this.interceptionState === 'intercepted') {
3049
- this.interceptionState = 'finished';
3001
+ navigation.navigateEvent = null;
3002
+ if (event.interceptionState !== 'intercepted') {
3003
+ finishNavigationEvent(event, false);
3050
3004
  }
3051
- const navigateerrorEvent = new Event('navigateerror', {
3052
- bubbles: false,
3053
- cancelable,
3054
- });
3055
- navigateerrorEvent.error = reason;
3005
+ const navigateerrorEvent = new Event('navigateerror', { bubbles: false, cancelable });
3056
3006
  navigation.eventTarget.dispatchEvent(navigateerrorEvent);
3057
- if (result.committedTo === null && !result.signal.aborted) {
3058
- result.committedReject(reason);
3059
- }
3060
3007
  result.finishedReject(reason);
3061
- const transition = navigation.transition;
3062
- transition?.committedReject(reason);
3063
- transition?.finishedReject(reason);
3008
+ if (navigation.transition !== null) {
3009
+ navigation.transition.finishedReject(reason);
3010
+ }
3064
3011
  navigation.transition = null;
3065
3012
  };
3066
3013
  function dispatch() {
3067
3014
  navigation.navigateEvent = event;
3068
- const dispatchResult = navigation.eventTarget.dispatchEvent(event);
3069
- if (event.interceptionState === 'intercepted') {
3070
- if (!navigation.currentEntry) {
3071
- event.cancel(new DOMException('Cannot create transition without a currentEntry for intercepted navigation.', 'InvalidStateError'));
3072
- return;
3073
- }
3074
- const transition = new InternalNavigationTransition(navigation.currentEntry, navigationType);
3075
- navigation.transition = transition;
3076
- // Mark transition.finished as handled (Spec Step 33.4)
3077
- transition.finished.catch(() => { });
3078
- transition.committed.catch(() => { });
3079
- }
3080
- if (!dispatchResult && event.cancelable) {
3081
- if (!event.abortController.signal.aborted) {
3082
- event.cancel(new DOMException('Navigation prevented by event.preventDefault()', 'AbortError'));
3083
- }
3015
+ navigation.eventTarget.dispatchEvent(event);
3016
+ if (precommitHandlers.length === 0) {
3017
+ commit();
3084
3018
  }
3085
3019
  else {
3086
- if (precommitHandlers.length === 0) {
3087
- commit();
3088
- }
3089
- else {
3090
- const precommitController = { redirect };
3091
- const precommitPromisesList = precommitHandlers.map((handler) => {
3092
- let p;
3093
- try {
3094
- p = handler(precommitController);
3095
- }
3096
- catch (e) {
3097
- p = Promise.reject(e);
3098
- }
3099
- p.catch(() => { });
3100
- return p;
3101
- });
3102
- Promise.all(precommitPromisesList)
3103
- .then(() => commit())
3104
- .catch((reason) => {
3105
- if (event.abortController.signal.aborted) {
3106
- return;
3107
- }
3108
- if (navigation.transition) {
3109
- navigation.transition.committedReject(reason);
3110
- }
3111
- event.cancel(reason);
3112
- });
3113
- }
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));
3114
3025
  }
3115
3026
  }
3116
3027
  dispatch();
3117
- return event.interceptionState === 'none';
3028
+ return event.interceptionState !== 'none';
3118
3029
  }
3119
3030
  /** https://whatpr.org/html/10919/nav-history-apis.html#navigateevent-finish */
3120
3031
  function finishNavigationEvent(event, didFulfill) {
@@ -3125,6 +3036,7 @@ function finishNavigationEvent(event, didFulfill) {
3125
3036
  if (didFulfill === true) {
3126
3037
  throw new Error('didFulfill should be false');
3127
3038
  }
3039
+ // assert precommit handlers is not empty
3128
3040
  event.interceptionState = 'finished';
3129
3041
  return;
3130
3042
  }
@@ -3142,10 +3054,7 @@ function potentiallyResetFocus(event) {
3142
3054
  if (event.interceptionState !== 'committed' && event.interceptionState !== 'scrolled') {
3143
3055
  throw new Error('cannot reset focus if navigation event is not committed or scrolled');
3144
3056
  }
3145
- if (event.focusResetBehavior === 'manual') {
3146
- return;
3147
- }
3148
- // TODO(atscott): the rest of the steps
3057
+ // TODO(atscott): The rest of the steps
3149
3058
  }
3150
3059
  function potentiallyResetScroll(event) {
3151
3060
  if (event.interceptionState !== 'committed' && event.interceptionState !== 'scrolled') {
@@ -3236,11 +3145,8 @@ class InternalNavigationTransition {
3236
3145
  from;
3237
3146
  navigationType;
3238
3147
  finished;
3239
- committed;
3240
3148
  finishedResolve;
3241
3149
  finishedReject;
3242
- committedResolve;
3243
- committedReject;
3244
3150
  constructor(from, navigationType) {
3245
3151
  this.from = from;
3246
3152
  this.navigationType = navigationType;
@@ -3248,13 +3154,8 @@ class InternalNavigationTransition {
3248
3154
  this.finishedReject = reject;
3249
3155
  this.finishedResolve = resolve;
3250
3156
  });
3251
- this.committed = new Promise((resolve, reject) => {
3252
- this.committedReject = reject;
3253
- this.committedResolve = resolve;
3254
- });
3255
3157
  // All rejections are handled.
3256
3158
  this.finished.catch(() => { });
3257
- this.committed.catch(() => { });
3258
3159
  }
3259
3160
  }
3260
3161
  /**
@@ -3283,7 +3184,7 @@ class InternalNavigationResult {
3283
3184
  };
3284
3185
  this.committedReject = reject;
3285
3186
  });
3286
- this.finished = new Promise((resolve, reject) => {
3187
+ this.finished = new Promise(async (resolve, reject) => {
3287
3188
  this.finishedResolve = () => {
3288
3189
  if (this.committedTo === null) {
3289
3190
  throw new Error('NavigateEvent should have been committed before resolving finished promise.');