@angular/router 21.1.0-next.4 → 21.1.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.
- package/LICENSE +1 -1
- package/fesm2022/_router-chunk.mjs +190 -532
- package/fesm2022/_router-chunk.mjs.map +1 -1
- package/fesm2022/_router_module-chunk.mjs +59 -52
- package/fesm2022/_router_module-chunk.mjs.map +1 -1
- package/fesm2022/router.mjs +5 -5
- package/fesm2022/router.mjs.map +1 -1
- package/fesm2022/testing.mjs +12 -12
- package/fesm2022/upgrade.mjs +2 -2
- package/package.json +4 -4
- package/types/_router_module-chunk.d.ts +2729 -2693
- package/types/router.d.ts +110 -63
- package/types/testing.d.ts +2 -2
- package/types/upgrade.d.ts +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v21.1.0
|
|
3
|
+
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { DOCUMENT, Location } from '@angular/common';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
|
-
import { ɵisPromise as _isPromise, ɵRuntimeError as _RuntimeError, Injectable, InjectionToken, EventEmitter, input, inject, ViewContainerRef, ChangeDetectorRef, Directive, Input, Output, reflectComponentType, Component, runInInjectionContext, ɵisInjectable as _isInjectable, ɵisNgModule as _isNgModule, isStandalone, createEnvironmentInjector,
|
|
10
|
-
import { isObservable, from, of, BehaviorSubject, combineLatest, EmptyError, Observable, concat, defer, pipe,
|
|
11
|
-
import { first, map, switchMap, take, startWith, filter, takeUntil, mergeMap, concatMap, tap,
|
|
9
|
+
import { ɵisPromise as _isPromise, computed, ɵRuntimeError as _RuntimeError, Injectable, InjectionToken, EventEmitter, input, inject, ViewContainerRef, ChangeDetectorRef, Directive, Input, Output, reflectComponentType, Component, runInInjectionContext, ɵisInjectable as _isInjectable, ɵisNgModule as _isNgModule, isStandalone, createEnvironmentInjector, Compiler, NgModuleFactory, ɵresolveComponentResources as _resolveComponentResources, afterNextRender, signal, EnvironmentInjector, DestroyRef, untracked, ɵConsole as _Console, ɵPendingTasksInternal as _PendingTasksInternal, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, ɵformatRuntimeError as _formatRuntimeError } from '@angular/core';
|
|
10
|
+
import { isObservable, from, of, BehaviorSubject, combineLatest, EmptyError, Observable, concat, defer, pipe, EMPTY, throwError, Subject, Subscription } from 'rxjs';
|
|
11
|
+
import { first, map, switchMap, take, startWith, filter, takeUntil, mergeMap, concatMap, tap, takeLast, catchError, finalize } from 'rxjs/operators';
|
|
12
12
|
import * as i1 from '@angular/platform-browser';
|
|
13
13
|
|
|
14
14
|
const PRIMARY_OUTLET = 'primary';
|
|
@@ -171,6 +171,10 @@ const paramCompareMap = {
|
|
|
171
171
|
'subset': containsParams,
|
|
172
172
|
'ignored': () => true
|
|
173
173
|
};
|
|
174
|
+
function isActive(url, router, matchOptions) {
|
|
175
|
+
const urlTree = url instanceof UrlTree ? url : router.parseUrl(url);
|
|
176
|
+
return computed(() => containsTree(router.lastSuccessfulNavigation()?.finalUrl ?? new UrlTree(), urlTree, matchOptions));
|
|
177
|
+
}
|
|
174
178
|
function containsTree(container, containee, options) {
|
|
175
179
|
return pathCompareMap[options.paths](container.root, containee.root, options.matrixParams) && paramCompareMap[options.queryParams](container.queryParams, containee.queryParams) && !(options.fragment === 'exact' && container.fragment !== containee.fragment);
|
|
176
180
|
}
|
|
@@ -308,7 +312,7 @@ function mapChildrenIntoArray(segment, fn) {
|
|
|
308
312
|
class UrlSerializer {
|
|
309
313
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
310
314
|
minVersion: "12.0.0",
|
|
311
|
-
version: "21.1.0
|
|
315
|
+
version: "21.1.0",
|
|
312
316
|
ngImport: i0,
|
|
313
317
|
type: UrlSerializer,
|
|
314
318
|
deps: [],
|
|
@@ -316,7 +320,7 @@ class UrlSerializer {
|
|
|
316
320
|
});
|
|
317
321
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
318
322
|
minVersion: "12.0.0",
|
|
319
|
-
version: "21.1.0
|
|
323
|
+
version: "21.1.0",
|
|
320
324
|
ngImport: i0,
|
|
321
325
|
type: UrlSerializer,
|
|
322
326
|
providedIn: 'root',
|
|
@@ -325,7 +329,7 @@ class UrlSerializer {
|
|
|
325
329
|
}
|
|
326
330
|
i0.ɵɵngDeclareClassMetadata({
|
|
327
331
|
minVersion: "12.0.0",
|
|
328
|
-
version: "21.1.0
|
|
332
|
+
version: "21.1.0",
|
|
329
333
|
ngImport: i0,
|
|
330
334
|
type: UrlSerializer,
|
|
331
335
|
decorators: [{
|
|
@@ -1278,7 +1282,7 @@ class ChildrenOutletContexts {
|
|
|
1278
1282
|
}
|
|
1279
1283
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1280
1284
|
minVersion: "12.0.0",
|
|
1281
|
-
version: "21.1.0
|
|
1285
|
+
version: "21.1.0",
|
|
1282
1286
|
ngImport: i0,
|
|
1283
1287
|
type: ChildrenOutletContexts,
|
|
1284
1288
|
deps: [{
|
|
@@ -1288,7 +1292,7 @@ class ChildrenOutletContexts {
|
|
|
1288
1292
|
});
|
|
1289
1293
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1290
1294
|
minVersion: "12.0.0",
|
|
1291
|
-
version: "21.1.0
|
|
1295
|
+
version: "21.1.0",
|
|
1292
1296
|
ngImport: i0,
|
|
1293
1297
|
type: ChildrenOutletContexts,
|
|
1294
1298
|
providedIn: 'root'
|
|
@@ -1296,7 +1300,7 @@ class ChildrenOutletContexts {
|
|
|
1296
1300
|
}
|
|
1297
1301
|
i0.ɵɵngDeclareClassMetadata({
|
|
1298
1302
|
minVersion: "12.0.0",
|
|
1299
|
-
version: "21.1.0
|
|
1303
|
+
version: "21.1.0",
|
|
1300
1304
|
ngImport: i0,
|
|
1301
1305
|
type: ChildrenOutletContexts,
|
|
1302
1306
|
decorators: [{
|
|
@@ -1753,7 +1757,7 @@ class RouterOutlet {
|
|
|
1753
1757
|
}
|
|
1754
1758
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1755
1759
|
minVersion: "12.0.0",
|
|
1756
|
-
version: "21.1.0
|
|
1760
|
+
version: "21.1.0",
|
|
1757
1761
|
ngImport: i0,
|
|
1758
1762
|
type: RouterOutlet,
|
|
1759
1763
|
deps: [],
|
|
@@ -1761,7 +1765,7 @@ class RouterOutlet {
|
|
|
1761
1765
|
});
|
|
1762
1766
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1763
1767
|
minVersion: "17.1.0",
|
|
1764
|
-
version: "21.1.0
|
|
1768
|
+
version: "21.1.0",
|
|
1765
1769
|
type: RouterOutlet,
|
|
1766
1770
|
isStandalone: true,
|
|
1767
1771
|
selector: "router-outlet",
|
|
@@ -1794,7 +1798,7 @@ class RouterOutlet {
|
|
|
1794
1798
|
}
|
|
1795
1799
|
i0.ɵɵngDeclareClassMetadata({
|
|
1796
1800
|
minVersion: "12.0.0",
|
|
1797
|
-
version: "21.1.0
|
|
1801
|
+
version: "21.1.0",
|
|
1798
1802
|
ngImport: i0,
|
|
1799
1803
|
type: RouterOutlet,
|
|
1800
1804
|
decorators: [{
|
|
@@ -1903,7 +1907,7 @@ class RoutedComponentInputBinder {
|
|
|
1903
1907
|
}
|
|
1904
1908
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1905
1909
|
minVersion: "12.0.0",
|
|
1906
|
-
version: "21.1.0
|
|
1910
|
+
version: "21.1.0",
|
|
1907
1911
|
ngImport: i0,
|
|
1908
1912
|
type: RoutedComponentInputBinder,
|
|
1909
1913
|
deps: [],
|
|
@@ -1911,14 +1915,14 @@ class RoutedComponentInputBinder {
|
|
|
1911
1915
|
});
|
|
1912
1916
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1913
1917
|
minVersion: "12.0.0",
|
|
1914
|
-
version: "21.1.0
|
|
1918
|
+
version: "21.1.0",
|
|
1915
1919
|
ngImport: i0,
|
|
1916
1920
|
type: RoutedComponentInputBinder
|
|
1917
1921
|
});
|
|
1918
1922
|
}
|
|
1919
1923
|
i0.ɵɵngDeclareClassMetadata({
|
|
1920
1924
|
minVersion: "12.0.0",
|
|
1921
|
-
version: "21.1.0
|
|
1925
|
+
version: "21.1.0",
|
|
1922
1926
|
ngImport: i0,
|
|
1923
1927
|
type: RoutedComponentInputBinder,
|
|
1924
1928
|
decorators: [{
|
|
@@ -1929,7 +1933,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1929
1933
|
class ɵEmptyOutletComponent {
|
|
1930
1934
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1931
1935
|
minVersion: "12.0.0",
|
|
1932
|
-
version: "21.1.0
|
|
1936
|
+
version: "21.1.0",
|
|
1933
1937
|
ngImport: i0,
|
|
1934
1938
|
type: ɵEmptyOutletComponent,
|
|
1935
1939
|
deps: [],
|
|
@@ -1937,7 +1941,7 @@ class ɵEmptyOutletComponent {
|
|
|
1937
1941
|
});
|
|
1938
1942
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1939
1943
|
minVersion: "14.0.0",
|
|
1940
|
-
version: "21.1.0
|
|
1944
|
+
version: "21.1.0",
|
|
1941
1945
|
type: ɵEmptyOutletComponent,
|
|
1942
1946
|
isStandalone: true,
|
|
1943
1947
|
selector: "ng-component",
|
|
@@ -1957,7 +1961,7 @@ class ɵEmptyOutletComponent {
|
|
|
1957
1961
|
}
|
|
1958
1962
|
i0.ɵɵngDeclareClassMetadata({
|
|
1959
1963
|
minVersion: "12.0.0",
|
|
1960
|
-
version: "21.1.0
|
|
1964
|
+
version: "21.1.0",
|
|
1961
1965
|
ngImport: i0,
|
|
1962
1966
|
type: ɵEmptyOutletComponent,
|
|
1963
1967
|
decorators: [{
|
|
@@ -2510,35 +2514,34 @@ function runCanMatchGuards(injector, route, segments, urlSerializer, abortSignal
|
|
|
2510
2514
|
const canMatchObservables = canMatch.map(injectionToken => {
|
|
2511
2515
|
const guard = getTokenOrFunctionIdentity(injectionToken, injector);
|
|
2512
2516
|
const guardVal = isCanMatch(guard) ? guard.canMatch(route, segments) : runInInjectionContext(injector, () => guard(route, segments));
|
|
2513
|
-
|
|
2514
|
-
return abortSignal ? obs$.pipe(takeUntilAbort(abortSignal)) : obs$;
|
|
2517
|
+
return wrapIntoObservable(guardVal).pipe(takeUntilAbort(abortSignal));
|
|
2515
2518
|
});
|
|
2516
2519
|
return of(canMatchObservables).pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
|
|
2517
2520
|
}
|
|
2518
2521
|
|
|
2519
|
-
|
|
2522
|
+
class NoMatch extends Error {
|
|
2520
2523
|
segmentGroup;
|
|
2521
2524
|
constructor(segmentGroup) {
|
|
2522
2525
|
super();
|
|
2523
2526
|
this.segmentGroup = segmentGroup || null;
|
|
2524
2527
|
Object.setPrototypeOf(this, NoMatch.prototype);
|
|
2525
2528
|
}
|
|
2526
|
-
}
|
|
2527
|
-
|
|
2529
|
+
}
|
|
2530
|
+
class AbsoluteRedirect extends Error {
|
|
2528
2531
|
urlTree;
|
|
2529
2532
|
constructor(urlTree) {
|
|
2530
2533
|
super();
|
|
2531
2534
|
this.urlTree = urlTree;
|
|
2532
2535
|
Object.setPrototypeOf(this, AbsoluteRedirect.prototype);
|
|
2533
2536
|
}
|
|
2534
|
-
}
|
|
2535
|
-
function namedOutletsRedirect
|
|
2537
|
+
}
|
|
2538
|
+
function namedOutletsRedirect(redirectTo) {
|
|
2536
2539
|
throw new _RuntimeError(4000, (typeof ngDevMode === 'undefined' || ngDevMode) && `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`);
|
|
2537
2540
|
}
|
|
2538
|
-
function canLoadFails
|
|
2541
|
+
function canLoadFails(route) {
|
|
2539
2542
|
throw navigationCancelingError((typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot load children because the guard of the route "path: '${route.path}'" returned false`, NavigationCancellationCode.GuardRejected);
|
|
2540
2543
|
}
|
|
2541
|
-
|
|
2544
|
+
class ApplyRedirects {
|
|
2542
2545
|
urlSerializer;
|
|
2543
2546
|
urlTree;
|
|
2544
2547
|
constructor(urlSerializer, urlTree) {
|
|
@@ -2554,19 +2557,19 @@ let ApplyRedirects$1 = class ApplyRedirects {
|
|
|
2554
2557
|
return res;
|
|
2555
2558
|
}
|
|
2556
2559
|
if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
|
|
2557
|
-
throw namedOutletsRedirect
|
|
2560
|
+
throw namedOutletsRedirect(`${route.redirectTo}`);
|
|
2558
2561
|
}
|
|
2559
2562
|
c = c.children[PRIMARY_OUTLET];
|
|
2560
2563
|
}
|
|
2561
2564
|
}
|
|
2562
2565
|
async applyRedirectCommands(segments, redirectTo, posParams, currentSnapshot, injector) {
|
|
2563
|
-
const redirect = await getRedirectResult
|
|
2566
|
+
const redirect = await getRedirectResult(redirectTo, currentSnapshot, injector);
|
|
2564
2567
|
if (redirect instanceof UrlTree) {
|
|
2565
|
-
throw new AbsoluteRedirect
|
|
2568
|
+
throw new AbsoluteRedirect(redirect);
|
|
2566
2569
|
}
|
|
2567
2570
|
const newTree = this.applyRedirectCreateUrlTree(redirect, this.urlSerializer.parse(redirect), segments, posParams);
|
|
2568
2571
|
if (redirect[0] === '/') {
|
|
2569
|
-
throw new AbsoluteRedirect
|
|
2572
|
+
throw new AbsoluteRedirect(newTree);
|
|
2570
2573
|
}
|
|
2571
2574
|
return newTree;
|
|
2572
2575
|
}
|
|
@@ -2614,8 +2617,8 @@ let ApplyRedirects$1 = class ApplyRedirects {
|
|
|
2614
2617
|
}
|
|
2615
2618
|
return redirectToUrlSegment;
|
|
2616
2619
|
}
|
|
2617
|
-
}
|
|
2618
|
-
function getRedirectResult
|
|
2620
|
+
}
|
|
2621
|
+
function getRedirectResult(redirectTo, currentSnapshot, injector) {
|
|
2619
2622
|
if (typeof redirectTo === 'string') {
|
|
2620
2623
|
return Promise.resolve(redirectTo);
|
|
2621
2624
|
}
|
|
@@ -2628,7 +2631,9 @@ function getRedirectResult$1(redirectTo, currentSnapshot, injector) {
|
|
|
2628
2631
|
outlet,
|
|
2629
2632
|
params,
|
|
2630
2633
|
data,
|
|
2631
|
-
title
|
|
2634
|
+
title,
|
|
2635
|
+
paramMap,
|
|
2636
|
+
queryParamMap
|
|
2632
2637
|
} = currentSnapshot;
|
|
2633
2638
|
return firstValueFrom(wrapIntoObservable(runInInjectionContext(injector, () => redirectToFn({
|
|
2634
2639
|
params,
|
|
@@ -2638,7 +2643,9 @@ function getRedirectResult$1(redirectTo, currentSnapshot, injector) {
|
|
|
2638
2643
|
routeConfig,
|
|
2639
2644
|
url,
|
|
2640
2645
|
outlet,
|
|
2641
|
-
title
|
|
2646
|
+
title,
|
|
2647
|
+
paramMap,
|
|
2648
|
+
queryParamMap
|
|
2642
2649
|
}))));
|
|
2643
2650
|
}
|
|
2644
2651
|
|
|
@@ -2750,7 +2757,7 @@ function sortByMatchingOutlets(routes, outletName) {
|
|
|
2750
2757
|
return sortedConfig;
|
|
2751
2758
|
}
|
|
2752
2759
|
|
|
2753
|
-
const noMatch
|
|
2760
|
+
const noMatch = {
|
|
2754
2761
|
matched: false,
|
|
2755
2762
|
consumedSegments: [],
|
|
2756
2763
|
remainingSegments: [],
|
|
@@ -2764,14 +2771,14 @@ function matchWithChecks(segmentGroup, route, segments, injector, urlSerializer,
|
|
|
2764
2771
|
}
|
|
2765
2772
|
injector = getOrCreateRouteInjectorIfNeeded(route, injector);
|
|
2766
2773
|
return runCanMatchGuards(injector, route, segments, urlSerializer, abortSignal).pipe(map(v => v === true ? result : {
|
|
2767
|
-
...noMatch
|
|
2774
|
+
...noMatch
|
|
2768
2775
|
}));
|
|
2769
2776
|
}
|
|
2770
2777
|
function match(segmentGroup, route, segments) {
|
|
2771
2778
|
if (route.path === '') {
|
|
2772
2779
|
if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
|
|
2773
2780
|
return {
|
|
2774
|
-
...noMatch
|
|
2781
|
+
...noMatch
|
|
2775
2782
|
};
|
|
2776
2783
|
}
|
|
2777
2784
|
return {
|
|
@@ -2785,7 +2792,7 @@ function match(segmentGroup, route, segments) {
|
|
|
2785
2792
|
const matcher = route.matcher || defaultUrlMatcher;
|
|
2786
2793
|
const res = matcher(segments, segmentGroup, route);
|
|
2787
2794
|
if (!res) return {
|
|
2788
|
-
...noMatch
|
|
2795
|
+
...noMatch
|
|
2789
2796
|
};
|
|
2790
2797
|
const posParams = {};
|
|
2791
2798
|
Object.entries(res.posParams ?? {}).forEach(([k, v]) => {
|
|
@@ -2864,12 +2871,12 @@ function noLeftoversInUrl(segmentGroup, segments, outlet) {
|
|
|
2864
2871
|
return segments.length === 0 && !segmentGroup.children[outlet];
|
|
2865
2872
|
}
|
|
2866
2873
|
|
|
2867
|
-
|
|
2868
|
-
async function recognize$
|
|
2869
|
-
return new Recognizer
|
|
2874
|
+
class NoLeftoversInUrl {}
|
|
2875
|
+
async function recognize$1(injector, configLoader, rootComponentType, config, urlTree, urlSerializer, paramsInheritanceStrategy = 'emptyOnly', abortSignal) {
|
|
2876
|
+
return new Recognizer(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer, abortSignal).recognize();
|
|
2870
2877
|
}
|
|
2871
|
-
const MAX_ALLOWED_REDIRECTS
|
|
2872
|
-
|
|
2878
|
+
const MAX_ALLOWED_REDIRECTS = 31;
|
|
2879
|
+
class Recognizer {
|
|
2873
2880
|
injector;
|
|
2874
2881
|
configLoader;
|
|
2875
2882
|
rootComponentType;
|
|
@@ -2890,7 +2897,7 @@ let Recognizer$1 = class Recognizer {
|
|
|
2890
2897
|
this.paramsInheritanceStrategy = paramsInheritanceStrategy;
|
|
2891
2898
|
this.urlSerializer = urlSerializer;
|
|
2892
2899
|
this.abortSignal = abortSignal;
|
|
2893
|
-
this.applyRedirects = new ApplyRedirects
|
|
2900
|
+
this.applyRedirects = new ApplyRedirects(this.urlSerializer, this.urlTree);
|
|
2894
2901
|
}
|
|
2895
2902
|
noMatchError(e) {
|
|
2896
2903
|
return new _RuntimeError(4002, typeof ngDevMode === 'undefined' || ngDevMode ? `Cannot match any routes. URL Segment: '${e.segmentGroup}'` : `'${e.segmentGroup}'`);
|
|
@@ -2922,11 +2929,11 @@ let Recognizer$1 = class Recognizer {
|
|
|
2922
2929
|
rootSnapshot
|
|
2923
2930
|
};
|
|
2924
2931
|
} catch (e) {
|
|
2925
|
-
if (e instanceof AbsoluteRedirect
|
|
2932
|
+
if (e instanceof AbsoluteRedirect) {
|
|
2926
2933
|
this.urlTree = e.urlTree;
|
|
2927
2934
|
return this.match(e.urlTree.root);
|
|
2928
2935
|
}
|
|
2929
|
-
if (e instanceof NoMatch
|
|
2936
|
+
if (e instanceof NoMatch) {
|
|
2930
2937
|
throw this.noMatchError(e);
|
|
2931
2938
|
}
|
|
2932
2939
|
throw e;
|
|
@@ -2955,11 +2962,11 @@ let Recognizer$1 = class Recognizer {
|
|
|
2955
2962
|
const outletChildren = await this.processSegmentGroup(injector, sortedConfig, child, childOutlet, parentRoute);
|
|
2956
2963
|
children.push(...outletChildren);
|
|
2957
2964
|
}
|
|
2958
|
-
const mergedChildren = mergeEmptyPathMatches
|
|
2965
|
+
const mergedChildren = mergeEmptyPathMatches(children);
|
|
2959
2966
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
2960
|
-
checkOutletNameUniqueness
|
|
2967
|
+
checkOutletNameUniqueness(mergedChildren);
|
|
2961
2968
|
}
|
|
2962
|
-
sortActivatedRouteSnapshots
|
|
2969
|
+
sortActivatedRouteSnapshots(mergedChildren);
|
|
2963
2970
|
return mergedChildren;
|
|
2964
2971
|
}
|
|
2965
2972
|
async processSegment(injector, routes, segmentGroup, segments, outlet, allowRedirects, parentRoute) {
|
|
@@ -2967,20 +2974,20 @@ let Recognizer$1 = class Recognizer {
|
|
|
2967
2974
|
try {
|
|
2968
2975
|
return await this.processSegmentAgainstRoute(r._injector ?? injector, routes, r, segmentGroup, segments, outlet, allowRedirects, parentRoute);
|
|
2969
2976
|
} catch (e) {
|
|
2970
|
-
if (e instanceof NoMatch
|
|
2977
|
+
if (e instanceof NoMatch || isEmptyError(e)) {
|
|
2971
2978
|
continue;
|
|
2972
2979
|
}
|
|
2973
2980
|
throw e;
|
|
2974
2981
|
}
|
|
2975
2982
|
}
|
|
2976
2983
|
if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
2977
|
-
return new NoLeftoversInUrl
|
|
2984
|
+
return new NoLeftoversInUrl();
|
|
2978
2985
|
}
|
|
2979
|
-
throw new NoMatch
|
|
2986
|
+
throw new NoMatch(segmentGroup);
|
|
2980
2987
|
}
|
|
2981
2988
|
async processSegmentAgainstRoute(injector, routes, route, rawSegment, segments, outlet, allowRedirects, parentRoute) {
|
|
2982
2989
|
if (getOutlet(route) !== outlet && (outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) {
|
|
2983
|
-
throw new NoMatch
|
|
2990
|
+
throw new NoMatch(rawSegment);
|
|
2984
2991
|
}
|
|
2985
2992
|
if (route.redirectTo === undefined) {
|
|
2986
2993
|
return this.matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute);
|
|
@@ -2988,7 +2995,7 @@ let Recognizer$1 = class Recognizer {
|
|
|
2988
2995
|
if (this.allowRedirects && allowRedirects) {
|
|
2989
2996
|
return this.expandSegmentAgainstRouteUsingRedirect(injector, rawSegment, routes, route, segments, outlet, parentRoute);
|
|
2990
2997
|
}
|
|
2991
|
-
throw new NoMatch
|
|
2998
|
+
throw new NoMatch(rawSegment);
|
|
2992
2999
|
}
|
|
2993
3000
|
async expandSegmentAgainstRouteUsingRedirect(injector, segmentGroup, routes, route, segments, outlet, parentRoute) {
|
|
2994
3001
|
const {
|
|
@@ -2998,10 +3005,10 @@ let Recognizer$1 = class Recognizer {
|
|
|
2998
3005
|
positionalParamSegments,
|
|
2999
3006
|
remainingSegments
|
|
3000
3007
|
} = match(segmentGroup, route, segments);
|
|
3001
|
-
if (!matched) throw new NoMatch
|
|
3008
|
+
if (!matched) throw new NoMatch(segmentGroup);
|
|
3002
3009
|
if (typeof route.redirectTo === 'string' && route.redirectTo[0] === '/') {
|
|
3003
3010
|
this.absoluteRedirectCount++;
|
|
3004
|
-
if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS
|
|
3011
|
+
if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS) {
|
|
3005
3012
|
if (ngDevMode) {
|
|
3006
3013
|
throw new _RuntimeError(4016, `Detected possible infinite redirect when redirecting from '${this.urlTree}' to '${route.redirectTo}'.\n` + `This is currently a dev mode only error but will become a` + ` call stack size exceeded error in production in a future major version.`);
|
|
3007
3014
|
}
|
|
@@ -3010,7 +3017,7 @@ let Recognizer$1 = class Recognizer {
|
|
|
3010
3017
|
}
|
|
3011
3018
|
const currentSnapshot = new ActivatedRouteSnapshot(segments, parameters, Object.freeze({
|
|
3012
3019
|
...this.urlTree.queryParams
|
|
3013
|
-
}), this.urlTree.fragment, getData
|
|
3020
|
+
}), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route), injector);
|
|
3014
3021
|
const inherited = getInherited(currentSnapshot, parentRoute, this.paramsInheritanceStrategy);
|
|
3015
3022
|
currentSnapshot.params = Object.freeze(inherited.params);
|
|
3016
3023
|
currentSnapshot.data = Object.freeze(inherited.data);
|
|
@@ -3030,7 +3037,7 @@ let Recognizer$1 = class Recognizer {
|
|
|
3030
3037
|
rawSegment.children = {};
|
|
3031
3038
|
}
|
|
3032
3039
|
if (!result?.matched) {
|
|
3033
|
-
throw new NoMatch
|
|
3040
|
+
throw new NoMatch(rawSegment);
|
|
3034
3041
|
}
|
|
3035
3042
|
injector = route._injector ?? injector;
|
|
3036
3043
|
const {
|
|
@@ -3044,7 +3051,7 @@ let Recognizer$1 = class Recognizer {
|
|
|
3044
3051
|
} = result;
|
|
3045
3052
|
const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({
|
|
3046
3053
|
...this.urlTree.queryParams
|
|
3047
|
-
}), this.urlTree.fragment, getData
|
|
3054
|
+
}), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route), injector);
|
|
3048
3055
|
const inherited = getInherited(snapshot, parentRoute, this.paramsInheritanceStrategy);
|
|
3049
3056
|
snapshot.params = Object.freeze(inherited.params);
|
|
3050
3057
|
snapshot.data = Object.freeze(inherited.data);
|
|
@@ -3072,6 +3079,10 @@ let Recognizer$1 = class Recognizer {
|
|
|
3072
3079
|
}
|
|
3073
3080
|
if (route.loadChildren) {
|
|
3074
3081
|
if (route._loadedRoutes !== undefined) {
|
|
3082
|
+
const ngModuleFactory = route._loadedNgModuleFactory;
|
|
3083
|
+
if (ngModuleFactory && !route._loadedInjector) {
|
|
3084
|
+
route._loadedInjector = ngModuleFactory.create(injector).injector;
|
|
3085
|
+
}
|
|
3075
3086
|
return {
|
|
3076
3087
|
routes: route._loadedRoutes,
|
|
3077
3088
|
injector: route._loadedInjector
|
|
@@ -3085,425 +3096,16 @@ let Recognizer$1 = class Recognizer {
|
|
|
3085
3096
|
const cfg = await this.configLoader.loadChildren(injector, route);
|
|
3086
3097
|
route._loadedRoutes = cfg.routes;
|
|
3087
3098
|
route._loadedInjector = cfg.injector;
|
|
3099
|
+
route._loadedNgModuleFactory = cfg.factory;
|
|
3088
3100
|
return cfg;
|
|
3089
3101
|
}
|
|
3090
|
-
throw canLoadFails
|
|
3102
|
+
throw canLoadFails(route);
|
|
3091
3103
|
}
|
|
3092
3104
|
return {
|
|
3093
3105
|
routes: [],
|
|
3094
3106
|
injector
|
|
3095
3107
|
};
|
|
3096
3108
|
}
|
|
3097
|
-
};
|
|
3098
|
-
function sortActivatedRouteSnapshots$1(nodes) {
|
|
3099
|
-
nodes.sort((a, b) => {
|
|
3100
|
-
if (a.value.outlet === PRIMARY_OUTLET) return -1;
|
|
3101
|
-
if (b.value.outlet === PRIMARY_OUTLET) return 1;
|
|
3102
|
-
return a.value.outlet.localeCompare(b.value.outlet);
|
|
3103
|
-
});
|
|
3104
|
-
}
|
|
3105
|
-
function hasEmptyPathConfig$1(node) {
|
|
3106
|
-
const config = node.value.routeConfig;
|
|
3107
|
-
return config && config.path === '';
|
|
3108
|
-
}
|
|
3109
|
-
function mergeEmptyPathMatches$1(nodes) {
|
|
3110
|
-
const result = [];
|
|
3111
|
-
const mergedNodes = new Set();
|
|
3112
|
-
for (const node of nodes) {
|
|
3113
|
-
if (!hasEmptyPathConfig$1(node)) {
|
|
3114
|
-
result.push(node);
|
|
3115
|
-
continue;
|
|
3116
|
-
}
|
|
3117
|
-
const duplicateEmptyPathNode = result.find(resultNode => node.value.routeConfig === resultNode.value.routeConfig);
|
|
3118
|
-
if (duplicateEmptyPathNode !== undefined) {
|
|
3119
|
-
duplicateEmptyPathNode.children.push(...node.children);
|
|
3120
|
-
mergedNodes.add(duplicateEmptyPathNode);
|
|
3121
|
-
} else {
|
|
3122
|
-
result.push(node);
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
for (const mergedNode of mergedNodes) {
|
|
3126
|
-
const mergedChildren = mergeEmptyPathMatches$1(mergedNode.children);
|
|
3127
|
-
result.push(new TreeNode(mergedNode.value, mergedChildren));
|
|
3128
|
-
}
|
|
3129
|
-
return result.filter(n => !mergedNodes.has(n));
|
|
3130
|
-
}
|
|
3131
|
-
function checkOutletNameUniqueness$1(nodes) {
|
|
3132
|
-
const names = {};
|
|
3133
|
-
nodes.forEach(n => {
|
|
3134
|
-
const routeWithSameOutletName = names[n.value.outlet];
|
|
3135
|
-
if (routeWithSameOutletName) {
|
|
3136
|
-
const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
|
|
3137
|
-
const c = n.value.url.map(s => s.toString()).join('/');
|
|
3138
|
-
throw new _RuntimeError(4006, (typeof ngDevMode === 'undefined' || ngDevMode) && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
|
|
3139
|
-
}
|
|
3140
|
-
names[n.value.outlet] = n.value;
|
|
3141
|
-
});
|
|
3142
|
-
}
|
|
3143
|
-
function getData$1(route) {
|
|
3144
|
-
return route.data || {};
|
|
3145
|
-
}
|
|
3146
|
-
function getResolve$1(route) {
|
|
3147
|
-
return route.resolve || {};
|
|
3148
|
-
}
|
|
3149
|
-
|
|
3150
|
-
class NoMatch {
|
|
3151
|
-
segmentGroup;
|
|
3152
|
-
constructor(segmentGroup) {
|
|
3153
|
-
this.segmentGroup = segmentGroup || null;
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
class AbsoluteRedirect extends Error {
|
|
3157
|
-
urlTree;
|
|
3158
|
-
constructor(urlTree) {
|
|
3159
|
-
super();
|
|
3160
|
-
this.urlTree = urlTree;
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
function noMatch(segmentGroup) {
|
|
3164
|
-
return throwError(new NoMatch(segmentGroup));
|
|
3165
|
-
}
|
|
3166
|
-
function namedOutletsRedirect(redirectTo) {
|
|
3167
|
-
return throwError(new _RuntimeError(4000, (typeof ngDevMode === 'undefined' || ngDevMode) && `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`));
|
|
3168
|
-
}
|
|
3169
|
-
function canLoadFails(route) {
|
|
3170
|
-
return throwError(navigationCancelingError((typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot load children because the guard of the route "path: '${route.path}'" returned false`, NavigationCancellationCode.GuardRejected));
|
|
3171
|
-
}
|
|
3172
|
-
class ApplyRedirects {
|
|
3173
|
-
urlSerializer;
|
|
3174
|
-
urlTree;
|
|
3175
|
-
constructor(urlSerializer, urlTree) {
|
|
3176
|
-
this.urlSerializer = urlSerializer;
|
|
3177
|
-
this.urlTree = urlTree;
|
|
3178
|
-
}
|
|
3179
|
-
lineralizeSegments(route, urlTree) {
|
|
3180
|
-
let res = [];
|
|
3181
|
-
let c = urlTree.root;
|
|
3182
|
-
while (true) {
|
|
3183
|
-
res = res.concat(c.segments);
|
|
3184
|
-
if (c.numberOfChildren === 0) {
|
|
3185
|
-
return of(res);
|
|
3186
|
-
}
|
|
3187
|
-
if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
|
|
3188
|
-
return namedOutletsRedirect(`${route.redirectTo}`);
|
|
3189
|
-
}
|
|
3190
|
-
c = c.children[PRIMARY_OUTLET];
|
|
3191
|
-
}
|
|
3192
|
-
}
|
|
3193
|
-
applyRedirectCommands(segments, redirectTo, posParams, currentSnapshot, injector) {
|
|
3194
|
-
return getRedirectResult(redirectTo, currentSnapshot, injector).pipe(map(redirect => {
|
|
3195
|
-
if (redirect instanceof UrlTree) {
|
|
3196
|
-
throw new AbsoluteRedirect(redirect);
|
|
3197
|
-
}
|
|
3198
|
-
const newTree = this.applyRedirectCreateUrlTree(redirect, this.urlSerializer.parse(redirect), segments, posParams);
|
|
3199
|
-
if (redirect[0] === '/') {
|
|
3200
|
-
throw new AbsoluteRedirect(newTree);
|
|
3201
|
-
}
|
|
3202
|
-
return newTree;
|
|
3203
|
-
}));
|
|
3204
|
-
}
|
|
3205
|
-
applyRedirectCreateUrlTree(redirectTo, urlTree, segments, posParams) {
|
|
3206
|
-
const newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
|
|
3207
|
-
return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
|
|
3208
|
-
}
|
|
3209
|
-
createQueryParams(redirectToParams, actualParams) {
|
|
3210
|
-
const res = {};
|
|
3211
|
-
Object.entries(redirectToParams).forEach(([k, v]) => {
|
|
3212
|
-
const copySourceValue = typeof v === 'string' && v[0] === ':';
|
|
3213
|
-
if (copySourceValue) {
|
|
3214
|
-
const sourceName = v.substring(1);
|
|
3215
|
-
res[k] = actualParams[sourceName];
|
|
3216
|
-
} else {
|
|
3217
|
-
res[k] = v;
|
|
3218
|
-
}
|
|
3219
|
-
});
|
|
3220
|
-
return res;
|
|
3221
|
-
}
|
|
3222
|
-
createSegmentGroup(redirectTo, group, segments, posParams) {
|
|
3223
|
-
const updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
|
|
3224
|
-
let children = {};
|
|
3225
|
-
Object.entries(group.children).forEach(([name, child]) => {
|
|
3226
|
-
children[name] = this.createSegmentGroup(redirectTo, child, segments, posParams);
|
|
3227
|
-
});
|
|
3228
|
-
return new UrlSegmentGroup(updatedSegments, children);
|
|
3229
|
-
}
|
|
3230
|
-
createSegments(redirectTo, redirectToSegments, actualSegments, posParams) {
|
|
3231
|
-
return redirectToSegments.map(s => s.path[0] === ':' ? this.findPosParam(redirectTo, s, posParams) : this.findOrReturn(s, actualSegments));
|
|
3232
|
-
}
|
|
3233
|
-
findPosParam(redirectTo, redirectToUrlSegment, posParams) {
|
|
3234
|
-
const pos = posParams[redirectToUrlSegment.path.substring(1)];
|
|
3235
|
-
if (!pos) throw new _RuntimeError(4001, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
|
|
3236
|
-
return pos;
|
|
3237
|
-
}
|
|
3238
|
-
findOrReturn(redirectToUrlSegment, actualSegments) {
|
|
3239
|
-
let idx = 0;
|
|
3240
|
-
for (const s of actualSegments) {
|
|
3241
|
-
if (s.path === redirectToUrlSegment.path) {
|
|
3242
|
-
actualSegments.splice(idx);
|
|
3243
|
-
return s;
|
|
3244
|
-
}
|
|
3245
|
-
idx++;
|
|
3246
|
-
}
|
|
3247
|
-
return redirectToUrlSegment;
|
|
3248
|
-
}
|
|
3249
|
-
}
|
|
3250
|
-
function getRedirectResult(redirectTo, currentSnapshot, injector) {
|
|
3251
|
-
if (typeof redirectTo === 'string') {
|
|
3252
|
-
return of(redirectTo);
|
|
3253
|
-
}
|
|
3254
|
-
const redirectToFn = redirectTo;
|
|
3255
|
-
const {
|
|
3256
|
-
queryParams,
|
|
3257
|
-
fragment,
|
|
3258
|
-
routeConfig,
|
|
3259
|
-
url,
|
|
3260
|
-
outlet,
|
|
3261
|
-
params,
|
|
3262
|
-
data,
|
|
3263
|
-
title
|
|
3264
|
-
} = currentSnapshot;
|
|
3265
|
-
return wrapIntoObservable(runInInjectionContext(injector, () => redirectToFn({
|
|
3266
|
-
params,
|
|
3267
|
-
data,
|
|
3268
|
-
queryParams,
|
|
3269
|
-
fragment,
|
|
3270
|
-
routeConfig,
|
|
3271
|
-
url,
|
|
3272
|
-
outlet,
|
|
3273
|
-
title
|
|
3274
|
-
})));
|
|
3275
|
-
}
|
|
3276
|
-
|
|
3277
|
-
class NoLeftoversInUrl {}
|
|
3278
|
-
function recognize$1(injector, configLoader, rootComponentType, config, urlTree, urlSerializer, paramsInheritanceStrategy = 'emptyOnly', abortSignal) {
|
|
3279
|
-
return new Recognizer(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer).recognize();
|
|
3280
|
-
}
|
|
3281
|
-
const MAX_ALLOWED_REDIRECTS = 31;
|
|
3282
|
-
class Recognizer {
|
|
3283
|
-
injector;
|
|
3284
|
-
configLoader;
|
|
3285
|
-
rootComponentType;
|
|
3286
|
-
config;
|
|
3287
|
-
urlTree;
|
|
3288
|
-
paramsInheritanceStrategy;
|
|
3289
|
-
urlSerializer;
|
|
3290
|
-
applyRedirects;
|
|
3291
|
-
absoluteRedirectCount = 0;
|
|
3292
|
-
allowRedirects = true;
|
|
3293
|
-
constructor(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer) {
|
|
3294
|
-
this.injector = injector;
|
|
3295
|
-
this.configLoader = configLoader;
|
|
3296
|
-
this.rootComponentType = rootComponentType;
|
|
3297
|
-
this.config = config;
|
|
3298
|
-
this.urlTree = urlTree;
|
|
3299
|
-
this.paramsInheritanceStrategy = paramsInheritanceStrategy;
|
|
3300
|
-
this.urlSerializer = urlSerializer;
|
|
3301
|
-
this.applyRedirects = new ApplyRedirects(this.urlSerializer, this.urlTree);
|
|
3302
|
-
}
|
|
3303
|
-
noMatchError(e) {
|
|
3304
|
-
return new _RuntimeError(4002, typeof ngDevMode === 'undefined' || ngDevMode ? `Cannot match any routes. URL Segment: '${e.segmentGroup}'` : `'${e.segmentGroup}'`);
|
|
3305
|
-
}
|
|
3306
|
-
recognize() {
|
|
3307
|
-
const rootSegmentGroup = split(this.urlTree.root, [], [], this.config).segmentGroup;
|
|
3308
|
-
return this.match(rootSegmentGroup).pipe(map(({
|
|
3309
|
-
children,
|
|
3310
|
-
rootSnapshot
|
|
3311
|
-
}) => {
|
|
3312
|
-
const rootNode = new TreeNode(rootSnapshot, children);
|
|
3313
|
-
const routeState = new RouterStateSnapshot('', rootNode);
|
|
3314
|
-
const tree = createUrlTreeFromSnapshot(rootSnapshot, [], this.urlTree.queryParams, this.urlTree.fragment);
|
|
3315
|
-
tree.queryParams = this.urlTree.queryParams;
|
|
3316
|
-
routeState.url = this.urlSerializer.serialize(tree);
|
|
3317
|
-
return {
|
|
3318
|
-
state: routeState,
|
|
3319
|
-
tree
|
|
3320
|
-
};
|
|
3321
|
-
}));
|
|
3322
|
-
}
|
|
3323
|
-
match(rootSegmentGroup) {
|
|
3324
|
-
const rootSnapshot = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze({
|
|
3325
|
-
...this.urlTree.queryParams
|
|
3326
|
-
}), this.urlTree.fragment, Object.freeze({}), PRIMARY_OUTLET, this.rootComponentType, null, {}, this.injector);
|
|
3327
|
-
return this.processSegmentGroup(this.injector, this.config, rootSegmentGroup, PRIMARY_OUTLET, rootSnapshot).pipe(map(children => {
|
|
3328
|
-
return {
|
|
3329
|
-
children,
|
|
3330
|
-
rootSnapshot
|
|
3331
|
-
};
|
|
3332
|
-
}), catchError(e => {
|
|
3333
|
-
if (e instanceof AbsoluteRedirect) {
|
|
3334
|
-
this.urlTree = e.urlTree;
|
|
3335
|
-
return this.match(e.urlTree.root);
|
|
3336
|
-
}
|
|
3337
|
-
if (e instanceof NoMatch) {
|
|
3338
|
-
throw this.noMatchError(e);
|
|
3339
|
-
}
|
|
3340
|
-
throw e;
|
|
3341
|
-
}));
|
|
3342
|
-
}
|
|
3343
|
-
processSegmentGroup(injector, config, segmentGroup, outlet, parentRoute) {
|
|
3344
|
-
if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
|
|
3345
|
-
return this.processChildren(injector, config, segmentGroup, parentRoute);
|
|
3346
|
-
}
|
|
3347
|
-
return this.processSegment(injector, config, segmentGroup, segmentGroup.segments, outlet, true, parentRoute).pipe(map(child => child instanceof TreeNode ? [child] : []));
|
|
3348
|
-
}
|
|
3349
|
-
processChildren(injector, config, segmentGroup, parentRoute) {
|
|
3350
|
-
const childOutlets = [];
|
|
3351
|
-
for (const child of Object.keys(segmentGroup.children)) {
|
|
3352
|
-
if (child === 'primary') {
|
|
3353
|
-
childOutlets.unshift(child);
|
|
3354
|
-
} else {
|
|
3355
|
-
childOutlets.push(child);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
|
-
return from(childOutlets).pipe(concatMap(childOutlet => {
|
|
3359
|
-
const child = segmentGroup.children[childOutlet];
|
|
3360
|
-
const sortedConfig = sortByMatchingOutlets(config, childOutlet);
|
|
3361
|
-
return this.processSegmentGroup(injector, sortedConfig, child, childOutlet, parentRoute);
|
|
3362
|
-
}), scan((children, outletChildren) => {
|
|
3363
|
-
children.push(...outletChildren);
|
|
3364
|
-
return children;
|
|
3365
|
-
}), defaultIfEmpty(null), last$1(), mergeMap(children => {
|
|
3366
|
-
if (children === null) return noMatch(segmentGroup);
|
|
3367
|
-
const mergedChildren = mergeEmptyPathMatches(children);
|
|
3368
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3369
|
-
checkOutletNameUniqueness(mergedChildren);
|
|
3370
|
-
}
|
|
3371
|
-
sortActivatedRouteSnapshots(mergedChildren);
|
|
3372
|
-
return of(mergedChildren);
|
|
3373
|
-
}));
|
|
3374
|
-
}
|
|
3375
|
-
processSegment(injector, routes, segmentGroup, segments, outlet, allowRedirects, parentRoute) {
|
|
3376
|
-
return from(routes).pipe(concatMap(r => {
|
|
3377
|
-
return this.processSegmentAgainstRoute(r._injector ?? injector, routes, r, segmentGroup, segments, outlet, allowRedirects, parentRoute).pipe(catchError(e => {
|
|
3378
|
-
if (e instanceof NoMatch) {
|
|
3379
|
-
return of(null);
|
|
3380
|
-
}
|
|
3381
|
-
throw e;
|
|
3382
|
-
}));
|
|
3383
|
-
}), first(x => !!x), catchError(e => {
|
|
3384
|
-
if (isEmptyError(e)) {
|
|
3385
|
-
if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
3386
|
-
return of(new NoLeftoversInUrl());
|
|
3387
|
-
}
|
|
3388
|
-
return noMatch(segmentGroup);
|
|
3389
|
-
}
|
|
3390
|
-
throw e;
|
|
3391
|
-
}));
|
|
3392
|
-
}
|
|
3393
|
-
processSegmentAgainstRoute(injector, routes, route, rawSegment, segments, outlet, allowRedirects, parentRoute) {
|
|
3394
|
-
if (getOutlet(route) !== outlet && (outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) {
|
|
3395
|
-
return noMatch(rawSegment);
|
|
3396
|
-
}
|
|
3397
|
-
if (route.redirectTo === undefined) {
|
|
3398
|
-
return this.matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute);
|
|
3399
|
-
}
|
|
3400
|
-
if (this.allowRedirects && allowRedirects) {
|
|
3401
|
-
return this.expandSegmentAgainstRouteUsingRedirect(injector, rawSegment, routes, route, segments, outlet, parentRoute);
|
|
3402
|
-
}
|
|
3403
|
-
return noMatch(rawSegment);
|
|
3404
|
-
}
|
|
3405
|
-
expandSegmentAgainstRouteUsingRedirect(injector, segmentGroup, routes, route, segments, outlet, parentRoute) {
|
|
3406
|
-
const {
|
|
3407
|
-
matched,
|
|
3408
|
-
parameters,
|
|
3409
|
-
consumedSegments,
|
|
3410
|
-
positionalParamSegments,
|
|
3411
|
-
remainingSegments
|
|
3412
|
-
} = match(segmentGroup, route, segments);
|
|
3413
|
-
if (!matched) return noMatch(segmentGroup);
|
|
3414
|
-
if (typeof route.redirectTo === 'string' && route.redirectTo[0] === '/') {
|
|
3415
|
-
this.absoluteRedirectCount++;
|
|
3416
|
-
if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS) {
|
|
3417
|
-
if (ngDevMode) {
|
|
3418
|
-
throw new _RuntimeError(4016, `Detected possible infinite redirect when redirecting from '${this.urlTree}' to '${route.redirectTo}'.\n` + `This is currently a dev mode only error but will become a` + ` call stack size exceeded error in production in a future major version.`);
|
|
3419
|
-
}
|
|
3420
|
-
this.allowRedirects = false;
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
const currentSnapshot = new ActivatedRouteSnapshot(segments, parameters, Object.freeze({
|
|
3424
|
-
...this.urlTree.queryParams
|
|
3425
|
-
}), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route), injector);
|
|
3426
|
-
const inherited = getInherited(currentSnapshot, parentRoute, this.paramsInheritanceStrategy);
|
|
3427
|
-
currentSnapshot.params = Object.freeze(inherited.params);
|
|
3428
|
-
currentSnapshot.data = Object.freeze(inherited.data);
|
|
3429
|
-
const newTree$ = this.applyRedirects.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments, currentSnapshot, injector);
|
|
3430
|
-
return newTree$.pipe(switchMap(newTree => this.applyRedirects.lineralizeSegments(route, newTree)), mergeMap(newSegments => {
|
|
3431
|
-
return this.processSegment(injector, routes, segmentGroup, newSegments.concat(remainingSegments), outlet, false, parentRoute);
|
|
3432
|
-
}));
|
|
3433
|
-
}
|
|
3434
|
-
matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute) {
|
|
3435
|
-
const matchResult = matchWithChecks(rawSegment, route, segments, injector, this.urlSerializer);
|
|
3436
|
-
if (route.path === '**') {
|
|
3437
|
-
rawSegment.children = {};
|
|
3438
|
-
}
|
|
3439
|
-
return matchResult.pipe(switchMap(result => {
|
|
3440
|
-
if (!result.matched) {
|
|
3441
|
-
return noMatch(rawSegment);
|
|
3442
|
-
}
|
|
3443
|
-
injector = route._injector ?? injector;
|
|
3444
|
-
return this.getChildConfig(injector, route, segments).pipe(switchMap(({
|
|
3445
|
-
routes: childConfig
|
|
3446
|
-
}) => {
|
|
3447
|
-
const childInjector = route._loadedInjector ?? injector;
|
|
3448
|
-
const {
|
|
3449
|
-
parameters,
|
|
3450
|
-
consumedSegments,
|
|
3451
|
-
remainingSegments
|
|
3452
|
-
} = result;
|
|
3453
|
-
const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({
|
|
3454
|
-
...this.urlTree.queryParams
|
|
3455
|
-
}), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route), injector);
|
|
3456
|
-
const inherited = getInherited(snapshot, parentRoute, this.paramsInheritanceStrategy);
|
|
3457
|
-
snapshot.params = Object.freeze(inherited.params);
|
|
3458
|
-
snapshot.data = Object.freeze(inherited.data);
|
|
3459
|
-
const {
|
|
3460
|
-
segmentGroup,
|
|
3461
|
-
slicedSegments
|
|
3462
|
-
} = split(rawSegment, consumedSegments, remainingSegments, childConfig);
|
|
3463
|
-
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
|
3464
|
-
return this.processChildren(childInjector, childConfig, segmentGroup, snapshot).pipe(map(children => {
|
|
3465
|
-
return new TreeNode(snapshot, children);
|
|
3466
|
-
}));
|
|
3467
|
-
}
|
|
3468
|
-
if (childConfig.length === 0 && slicedSegments.length === 0) {
|
|
3469
|
-
return of(new TreeNode(snapshot, []));
|
|
3470
|
-
}
|
|
3471
|
-
const matchedOnOutlet = getOutlet(route) === outlet;
|
|
3472
|
-
return this.processSegment(childInjector, childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true, snapshot).pipe(map(child => {
|
|
3473
|
-
return new TreeNode(snapshot, child instanceof TreeNode ? [child] : []);
|
|
3474
|
-
}));
|
|
3475
|
-
}));
|
|
3476
|
-
}));
|
|
3477
|
-
}
|
|
3478
|
-
getChildConfig(injector, route, segments) {
|
|
3479
|
-
if (route.children) {
|
|
3480
|
-
return of({
|
|
3481
|
-
routes: route.children,
|
|
3482
|
-
injector
|
|
3483
|
-
});
|
|
3484
|
-
}
|
|
3485
|
-
if (route.loadChildren) {
|
|
3486
|
-
if (route._loadedRoutes !== undefined) {
|
|
3487
|
-
return of({
|
|
3488
|
-
routes: route._loadedRoutes,
|
|
3489
|
-
injector: route._loadedInjector
|
|
3490
|
-
});
|
|
3491
|
-
}
|
|
3492
|
-
return runCanLoadGuards(injector, route, segments, this.urlSerializer).pipe(mergeMap(shouldLoadResult => {
|
|
3493
|
-
if (shouldLoadResult) {
|
|
3494
|
-
return from(this.configLoader.loadChildren(injector, route)).pipe(tap(cfg => {
|
|
3495
|
-
route._loadedRoutes = cfg.routes;
|
|
3496
|
-
route._loadedInjector = cfg.injector;
|
|
3497
|
-
}));
|
|
3498
|
-
}
|
|
3499
|
-
return canLoadFails(route);
|
|
3500
|
-
}));
|
|
3501
|
-
}
|
|
3502
|
-
return of({
|
|
3503
|
-
routes: [],
|
|
3504
|
-
injector
|
|
3505
|
-
});
|
|
3506
|
-
}
|
|
3507
3109
|
}
|
|
3508
3110
|
function sortActivatedRouteSnapshots(nodes) {
|
|
3509
3111
|
nodes.sort((a, b) => {
|
|
@@ -3557,29 +3159,18 @@ function getResolve(route) {
|
|
|
3557
3159
|
return route.resolve || {};
|
|
3558
3160
|
}
|
|
3559
3161
|
|
|
3560
|
-
const RECOGNIZE_IMPL = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'RECOGNIZE_IMPL' : '', {
|
|
3561
|
-
factory: () => {
|
|
3562
|
-
return recognize$2;
|
|
3563
|
-
}
|
|
3564
|
-
});
|
|
3565
|
-
function provideSometimesSyncRecognize() {
|
|
3566
|
-
return makeEnvironmentProviders([{
|
|
3567
|
-
provide: RECOGNIZE_IMPL,
|
|
3568
|
-
useValue: recognize$1
|
|
3569
|
-
}]);
|
|
3570
|
-
}
|
|
3571
3162
|
function recognize(injector, configLoader, rootComponentType, config, serializer, paramsInheritanceStrategy, abortSignal) {
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3163
|
+
return mergeMap(async t => {
|
|
3164
|
+
const {
|
|
3165
|
+
state: targetSnapshot,
|
|
3166
|
+
tree: urlAfterRedirects
|
|
3167
|
+
} = await recognize$1(injector, configLoader, rootComponentType, config, t.extractedUrl, serializer, paramsInheritanceStrategy, abortSignal);
|
|
3577
3168
|
return {
|
|
3578
3169
|
...t,
|
|
3579
3170
|
targetSnapshot,
|
|
3580
3171
|
urlAfterRedirects
|
|
3581
3172
|
};
|
|
3582
|
-
})
|
|
3173
|
+
});
|
|
3583
3174
|
}
|
|
3584
3175
|
|
|
3585
3176
|
function resolveData(paramsInheritanceStrategy) {
|
|
@@ -3681,7 +3272,7 @@ class TitleStrategy {
|
|
|
3681
3272
|
}
|
|
3682
3273
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3683
3274
|
minVersion: "12.0.0",
|
|
3684
|
-
version: "21.1.0
|
|
3275
|
+
version: "21.1.0",
|
|
3685
3276
|
ngImport: i0,
|
|
3686
3277
|
type: TitleStrategy,
|
|
3687
3278
|
deps: [],
|
|
@@ -3689,7 +3280,7 @@ class TitleStrategy {
|
|
|
3689
3280
|
});
|
|
3690
3281
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
3691
3282
|
minVersion: "12.0.0",
|
|
3692
|
-
version: "21.1.0
|
|
3283
|
+
version: "21.1.0",
|
|
3693
3284
|
ngImport: i0,
|
|
3694
3285
|
type: TitleStrategy,
|
|
3695
3286
|
providedIn: 'root',
|
|
@@ -3698,7 +3289,7 @@ class TitleStrategy {
|
|
|
3698
3289
|
}
|
|
3699
3290
|
i0.ɵɵngDeclareClassMetadata({
|
|
3700
3291
|
minVersion: "12.0.0",
|
|
3701
|
-
version: "21.1.0
|
|
3292
|
+
version: "21.1.0",
|
|
3702
3293
|
ngImport: i0,
|
|
3703
3294
|
type: TitleStrategy,
|
|
3704
3295
|
decorators: [{
|
|
@@ -3723,7 +3314,7 @@ class DefaultTitleStrategy extends TitleStrategy {
|
|
|
3723
3314
|
}
|
|
3724
3315
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3725
3316
|
minVersion: "12.0.0",
|
|
3726
|
-
version: "21.1.0
|
|
3317
|
+
version: "21.1.0",
|
|
3727
3318
|
ngImport: i0,
|
|
3728
3319
|
type: DefaultTitleStrategy,
|
|
3729
3320
|
deps: [{
|
|
@@ -3733,7 +3324,7 @@ class DefaultTitleStrategy extends TitleStrategy {
|
|
|
3733
3324
|
});
|
|
3734
3325
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
3735
3326
|
minVersion: "12.0.0",
|
|
3736
|
-
version: "21.1.0
|
|
3327
|
+
version: "21.1.0",
|
|
3737
3328
|
ngImport: i0,
|
|
3738
3329
|
type: DefaultTitleStrategy,
|
|
3739
3330
|
providedIn: 'root'
|
|
@@ -3741,7 +3332,7 @@ class DefaultTitleStrategy extends TitleStrategy {
|
|
|
3741
3332
|
}
|
|
3742
3333
|
i0.ɵɵngDeclareClassMetadata({
|
|
3743
3334
|
minVersion: "12.0.0",
|
|
3744
|
-
version: "21.1.0
|
|
3335
|
+
version: "21.1.0",
|
|
3745
3336
|
ngImport: i0,
|
|
3746
3337
|
type: DefaultTitleStrategy,
|
|
3747
3338
|
decorators: [{
|
|
@@ -3809,6 +3400,7 @@ class RouterConfigLoader {
|
|
|
3809
3400
|
const result = await loadChildren(route, this.compiler, parentInjector, this.onLoadEndListener);
|
|
3810
3401
|
route._loadedRoutes = result.routes;
|
|
3811
3402
|
route._loadedInjector = result.injector;
|
|
3403
|
+
route._loadedNgModuleFactory = result.factory;
|
|
3812
3404
|
return result;
|
|
3813
3405
|
} finally {
|
|
3814
3406
|
this.childrenLoaders.delete(route);
|
|
@@ -3819,7 +3411,7 @@ class RouterConfigLoader {
|
|
|
3819
3411
|
}
|
|
3820
3412
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3821
3413
|
minVersion: "12.0.0",
|
|
3822
|
-
version: "21.1.0
|
|
3414
|
+
version: "21.1.0",
|
|
3823
3415
|
ngImport: i0,
|
|
3824
3416
|
type: RouterConfigLoader,
|
|
3825
3417
|
deps: [],
|
|
@@ -3827,7 +3419,7 @@ class RouterConfigLoader {
|
|
|
3827
3419
|
});
|
|
3828
3420
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
3829
3421
|
minVersion: "12.0.0",
|
|
3830
|
-
version: "21.1.0
|
|
3422
|
+
version: "21.1.0",
|
|
3831
3423
|
ngImport: i0,
|
|
3832
3424
|
type: RouterConfigLoader,
|
|
3833
3425
|
providedIn: 'root'
|
|
@@ -3835,7 +3427,7 @@ class RouterConfigLoader {
|
|
|
3835
3427
|
}
|
|
3836
3428
|
i0.ɵɵngDeclareClassMetadata({
|
|
3837
3429
|
minVersion: "12.0.0",
|
|
3838
|
-
version: "21.1.0
|
|
3430
|
+
version: "21.1.0",
|
|
3839
3431
|
ngImport: i0,
|
|
3840
3432
|
type: RouterConfigLoader,
|
|
3841
3433
|
decorators: [{
|
|
@@ -3860,11 +3452,13 @@ async function loadChildren(route, compiler, parentInjector, onLoadEndListener)
|
|
|
3860
3452
|
let injector;
|
|
3861
3453
|
let rawRoutes;
|
|
3862
3454
|
let requireStandaloneComponents = false;
|
|
3455
|
+
let factory = undefined;
|
|
3863
3456
|
if (Array.isArray(factoryOrRoutes)) {
|
|
3864
3457
|
rawRoutes = factoryOrRoutes;
|
|
3865
3458
|
requireStandaloneComponents = true;
|
|
3866
3459
|
} else {
|
|
3867
3460
|
injector = factoryOrRoutes.create(parentInjector).injector;
|
|
3461
|
+
factory = factoryOrRoutes;
|
|
3868
3462
|
rawRoutes = injector.get(ROUTES, [], {
|
|
3869
3463
|
optional: true,
|
|
3870
3464
|
self: true
|
|
@@ -3874,7 +3468,8 @@ async function loadChildren(route, compiler, parentInjector, onLoadEndListener)
|
|
|
3874
3468
|
(typeof ngDevMode === 'undefined' || ngDevMode) && validateConfig(routes, route.path, requireStandaloneComponents);
|
|
3875
3469
|
return {
|
|
3876
3470
|
routes,
|
|
3877
|
-
injector
|
|
3471
|
+
injector,
|
|
3472
|
+
factory
|
|
3878
3473
|
};
|
|
3879
3474
|
}
|
|
3880
3475
|
function isWrappedDefaultExport(value) {
|
|
@@ -3897,7 +3492,7 @@ async function maybeResolveResources(value) {
|
|
|
3897
3492
|
class UrlHandlingStrategy {
|
|
3898
3493
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3899
3494
|
minVersion: "12.0.0",
|
|
3900
|
-
version: "21.1.0
|
|
3495
|
+
version: "21.1.0",
|
|
3901
3496
|
ngImport: i0,
|
|
3902
3497
|
type: UrlHandlingStrategy,
|
|
3903
3498
|
deps: [],
|
|
@@ -3905,7 +3500,7 @@ class UrlHandlingStrategy {
|
|
|
3905
3500
|
});
|
|
3906
3501
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
3907
3502
|
minVersion: "12.0.0",
|
|
3908
|
-
version: "21.1.0
|
|
3503
|
+
version: "21.1.0",
|
|
3909
3504
|
ngImport: i0,
|
|
3910
3505
|
type: UrlHandlingStrategy,
|
|
3911
3506
|
providedIn: 'root',
|
|
@@ -3914,7 +3509,7 @@ class UrlHandlingStrategy {
|
|
|
3914
3509
|
}
|
|
3915
3510
|
i0.ɵɵngDeclareClassMetadata({
|
|
3916
3511
|
minVersion: "12.0.0",
|
|
3917
|
-
version: "21.1.0
|
|
3512
|
+
version: "21.1.0",
|
|
3918
3513
|
ngImport: i0,
|
|
3919
3514
|
type: UrlHandlingStrategy,
|
|
3920
3515
|
decorators: [{
|
|
@@ -3937,7 +3532,7 @@ class DefaultUrlHandlingStrategy {
|
|
|
3937
3532
|
}
|
|
3938
3533
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
3939
3534
|
minVersion: "12.0.0",
|
|
3940
|
-
version: "21.1.0
|
|
3535
|
+
version: "21.1.0",
|
|
3941
3536
|
ngImport: i0,
|
|
3942
3537
|
type: DefaultUrlHandlingStrategy,
|
|
3943
3538
|
deps: [],
|
|
@@ -3945,7 +3540,7 @@ class DefaultUrlHandlingStrategy {
|
|
|
3945
3540
|
});
|
|
3946
3541
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
3947
3542
|
minVersion: "12.0.0",
|
|
3948
|
-
version: "21.1.0
|
|
3543
|
+
version: "21.1.0",
|
|
3949
3544
|
ngImport: i0,
|
|
3950
3545
|
type: DefaultUrlHandlingStrategy,
|
|
3951
3546
|
providedIn: 'root'
|
|
@@ -3953,7 +3548,7 @@ class DefaultUrlHandlingStrategy {
|
|
|
3953
3548
|
}
|
|
3954
3549
|
i0.ɵɵngDeclareClassMetadata({
|
|
3955
3550
|
minVersion: "12.0.0",
|
|
3956
|
-
version: "21.1.0
|
|
3551
|
+
version: "21.1.0",
|
|
3957
3552
|
ngImport: i0,
|
|
3958
3553
|
type: DefaultUrlHandlingStrategy,
|
|
3959
3554
|
decorators: [{
|
|
@@ -3981,6 +3576,11 @@ function createViewTransition(injector, from, to) {
|
|
|
3981
3576
|
resolveViewTransitionStarted();
|
|
3982
3577
|
return createRenderPromise(injector);
|
|
3983
3578
|
});
|
|
3579
|
+
transition.updateCallbackDone.catch(error => {
|
|
3580
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3581
|
+
console.error(error);
|
|
3582
|
+
}
|
|
3583
|
+
});
|
|
3984
3584
|
transition.ready.catch(error => {
|
|
3985
3585
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3986
3586
|
console.error(error);
|
|
@@ -4341,7 +3941,7 @@ class NavigationTransitions {
|
|
|
4341
3941
|
}
|
|
4342
3942
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4343
3943
|
minVersion: "12.0.0",
|
|
4344
|
-
version: "21.1.0
|
|
3944
|
+
version: "21.1.0",
|
|
4345
3945
|
ngImport: i0,
|
|
4346
3946
|
type: NavigationTransitions,
|
|
4347
3947
|
deps: [],
|
|
@@ -4349,7 +3949,7 @@ class NavigationTransitions {
|
|
|
4349
3949
|
});
|
|
4350
3950
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4351
3951
|
minVersion: "12.0.0",
|
|
4352
|
-
version: "21.1.0
|
|
3952
|
+
version: "21.1.0",
|
|
4353
3953
|
ngImport: i0,
|
|
4354
3954
|
type: NavigationTransitions,
|
|
4355
3955
|
providedIn: 'root'
|
|
@@ -4357,7 +3957,7 @@ class NavigationTransitions {
|
|
|
4357
3957
|
}
|
|
4358
3958
|
i0.ɵɵngDeclareClassMetadata({
|
|
4359
3959
|
minVersion: "12.0.0",
|
|
4360
|
-
version: "21.1.0
|
|
3960
|
+
version: "21.1.0",
|
|
4361
3961
|
ngImport: i0,
|
|
4362
3962
|
type: NavigationTransitions,
|
|
4363
3963
|
decorators: [{
|
|
@@ -4372,10 +3972,65 @@ function isBrowserTriggeredNavigation(source) {
|
|
|
4372
3972
|
return source !== IMPERATIVE_NAVIGATION;
|
|
4373
3973
|
}
|
|
4374
3974
|
|
|
3975
|
+
const ROUTE_INJECTOR_CLEANUP = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'RouteInjectorCleanup' : '');
|
|
3976
|
+
function routeInjectorCleanup(routeReuseStrategy, routerState, config) {
|
|
3977
|
+
const activeRoutes = new Set();
|
|
3978
|
+
if (routerState.snapshot.root) {
|
|
3979
|
+
collectDescendants(routerState.snapshot.root, activeRoutes);
|
|
3980
|
+
}
|
|
3981
|
+
const storedHandles = routeReuseStrategy.retrieveStoredRouteHandles?.() || [];
|
|
3982
|
+
for (const handle of storedHandles) {
|
|
3983
|
+
const internalHandle = handle;
|
|
3984
|
+
if (internalHandle?.route?.value?.snapshot) {
|
|
3985
|
+
for (const snapshot of internalHandle.route.value.snapshot.pathFromRoot) {
|
|
3986
|
+
if (snapshot.routeConfig) {
|
|
3987
|
+
activeRoutes.add(snapshot.routeConfig);
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
destroyUnusedInjectors(config, activeRoutes, routeReuseStrategy, false);
|
|
3993
|
+
}
|
|
3994
|
+
function collectDescendants(snapshot, activeRoutes) {
|
|
3995
|
+
if (snapshot.routeConfig) {
|
|
3996
|
+
activeRoutes.add(snapshot.routeConfig);
|
|
3997
|
+
}
|
|
3998
|
+
for (const child of snapshot.children) {
|
|
3999
|
+
collectDescendants(child, activeRoutes);
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
function destroyUnusedInjectors(routes, activeRoutes, strategy, inheritedForceDestroy) {
|
|
4003
|
+
for (const route of routes) {
|
|
4004
|
+
const shouldDestroyCurrentRoute = inheritedForceDestroy || !!((route._injector || route._loadedInjector) && !activeRoutes.has(route) && (strategy.shouldDestroyInjector?.(route) ?? false));
|
|
4005
|
+
if (route.children) {
|
|
4006
|
+
destroyUnusedInjectors(route.children, activeRoutes, strategy, shouldDestroyCurrentRoute);
|
|
4007
|
+
}
|
|
4008
|
+
if (route.loadChildren && route._loadedRoutes) {
|
|
4009
|
+
destroyUnusedInjectors(route._loadedRoutes, activeRoutes, strategy, shouldDestroyCurrentRoute);
|
|
4010
|
+
}
|
|
4011
|
+
if (shouldDestroyCurrentRoute) {
|
|
4012
|
+
if (route._injector) {
|
|
4013
|
+
route._injector.destroy();
|
|
4014
|
+
route._injector = undefined;
|
|
4015
|
+
}
|
|
4016
|
+
if (route._loadedInjector) {
|
|
4017
|
+
route._loadedInjector.destroy();
|
|
4018
|
+
route._loadedInjector = undefined;
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
|
|
4024
|
+
function destroyDetachedRouteHandle(handle) {
|
|
4025
|
+
const internalHandle = handle;
|
|
4026
|
+
if (internalHandle && internalHandle.componentRef) {
|
|
4027
|
+
internalHandle.componentRef.destroy();
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4375
4030
|
class RouteReuseStrategy {
|
|
4376
4031
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4377
4032
|
minVersion: "12.0.0",
|
|
4378
|
-
version: "21.1.0
|
|
4033
|
+
version: "21.1.0",
|
|
4379
4034
|
ngImport: i0,
|
|
4380
4035
|
type: RouteReuseStrategy,
|
|
4381
4036
|
deps: [],
|
|
@@ -4383,7 +4038,7 @@ class RouteReuseStrategy {
|
|
|
4383
4038
|
});
|
|
4384
4039
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4385
4040
|
minVersion: "12.0.0",
|
|
4386
|
-
version: "21.1.0
|
|
4041
|
+
version: "21.1.0",
|
|
4387
4042
|
ngImport: i0,
|
|
4388
4043
|
type: RouteReuseStrategy,
|
|
4389
4044
|
providedIn: 'root',
|
|
@@ -4392,7 +4047,7 @@ class RouteReuseStrategy {
|
|
|
4392
4047
|
}
|
|
4393
4048
|
i0.ɵɵngDeclareClassMetadata({
|
|
4394
4049
|
minVersion: "12.0.0",
|
|
4395
|
-
version: "21.1.0
|
|
4050
|
+
version: "21.1.0",
|
|
4396
4051
|
ngImport: i0,
|
|
4397
4052
|
type: RouteReuseStrategy,
|
|
4398
4053
|
decorators: [{
|
|
@@ -4417,11 +4072,14 @@ class BaseRouteReuseStrategy {
|
|
|
4417
4072
|
shouldReuseRoute(future, curr) {
|
|
4418
4073
|
return future.routeConfig === curr.routeConfig;
|
|
4419
4074
|
}
|
|
4075
|
+
shouldDestroyInjector(route) {
|
|
4076
|
+
return true;
|
|
4077
|
+
}
|
|
4420
4078
|
}
|
|
4421
4079
|
class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
|
|
4422
4080
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4423
4081
|
minVersion: "12.0.0",
|
|
4424
|
-
version: "21.1.0
|
|
4082
|
+
version: "21.1.0",
|
|
4425
4083
|
ngImport: i0,
|
|
4426
4084
|
type: DefaultRouteReuseStrategy,
|
|
4427
4085
|
deps: null,
|
|
@@ -4429,7 +4087,7 @@ class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
|
|
|
4429
4087
|
});
|
|
4430
4088
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4431
4089
|
minVersion: "12.0.0",
|
|
4432
|
-
version: "21.1.0
|
|
4090
|
+
version: "21.1.0",
|
|
4433
4091
|
ngImport: i0,
|
|
4434
4092
|
type: DefaultRouteReuseStrategy,
|
|
4435
4093
|
providedIn: 'root'
|
|
@@ -4437,7 +4095,7 @@ class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
|
|
|
4437
4095
|
}
|
|
4438
4096
|
i0.ɵɵngDeclareClassMetadata({
|
|
4439
4097
|
minVersion: "12.0.0",
|
|
4440
|
-
version: "21.1.0
|
|
4098
|
+
version: "21.1.0",
|
|
4441
4099
|
ngImport: i0,
|
|
4442
4100
|
type: DefaultRouteReuseStrategy,
|
|
4443
4101
|
decorators: [{
|
|
@@ -4511,7 +4169,7 @@ class StateManager {
|
|
|
4511
4169
|
}
|
|
4512
4170
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4513
4171
|
minVersion: "12.0.0",
|
|
4514
|
-
version: "21.1.0
|
|
4172
|
+
version: "21.1.0",
|
|
4515
4173
|
ngImport: i0,
|
|
4516
4174
|
type: StateManager,
|
|
4517
4175
|
deps: [],
|
|
@@ -4519,7 +4177,7 @@ class StateManager {
|
|
|
4519
4177
|
});
|
|
4520
4178
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4521
4179
|
minVersion: "12.0.0",
|
|
4522
|
-
version: "21.1.0
|
|
4180
|
+
version: "21.1.0",
|
|
4523
4181
|
ngImport: i0,
|
|
4524
4182
|
type: StateManager,
|
|
4525
4183
|
providedIn: 'root',
|
|
@@ -4528,7 +4186,7 @@ class StateManager {
|
|
|
4528
4186
|
}
|
|
4529
4187
|
i0.ɵɵngDeclareClassMetadata({
|
|
4530
4188
|
minVersion: "12.0.0",
|
|
4531
|
-
version: "21.1.0
|
|
4189
|
+
version: "21.1.0",
|
|
4532
4190
|
ngImport: i0,
|
|
4533
4191
|
type: StateManager,
|
|
4534
4192
|
decorators: [{
|
|
@@ -4645,7 +4303,7 @@ class HistoryStateManager extends StateManager {
|
|
|
4645
4303
|
}
|
|
4646
4304
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4647
4305
|
minVersion: "12.0.0",
|
|
4648
|
-
version: "21.1.0
|
|
4306
|
+
version: "21.1.0",
|
|
4649
4307
|
ngImport: i0,
|
|
4650
4308
|
type: HistoryStateManager,
|
|
4651
4309
|
deps: null,
|
|
@@ -4653,7 +4311,7 @@ class HistoryStateManager extends StateManager {
|
|
|
4653
4311
|
});
|
|
4654
4312
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4655
4313
|
minVersion: "12.0.0",
|
|
4656
|
-
version: "21.1.0
|
|
4314
|
+
version: "21.1.0",
|
|
4657
4315
|
ngImport: i0,
|
|
4658
4316
|
type: HistoryStateManager,
|
|
4659
4317
|
providedIn: 'root'
|
|
@@ -4661,7 +4319,7 @@ class HistoryStateManager extends StateManager {
|
|
|
4661
4319
|
}
|
|
4662
4320
|
i0.ɵɵngDeclareClassMetadata({
|
|
4663
4321
|
minVersion: "12.0.0",
|
|
4664
|
-
version: "21.1.0
|
|
4322
|
+
version: "21.1.0",
|
|
4665
4323
|
ngImport: i0,
|
|
4666
4324
|
type: HistoryStateManager,
|
|
4667
4325
|
decorators: [{
|
|
@@ -4726,6 +4384,9 @@ class Router {
|
|
|
4726
4384
|
}
|
|
4727
4385
|
navigated = false;
|
|
4728
4386
|
routeReuseStrategy = inject(RouteReuseStrategy);
|
|
4387
|
+
injectorCleanup = inject(ROUTE_INJECTOR_CLEANUP, {
|
|
4388
|
+
optional: true
|
|
4389
|
+
});
|
|
4729
4390
|
onSameUrlNavigation = this.options.onSameUrlNavigation || 'ignore';
|
|
4730
4391
|
config = inject(ROUTES, {
|
|
4731
4392
|
optional: true
|
|
@@ -4737,9 +4398,7 @@ class Router {
|
|
|
4737
4398
|
constructor() {
|
|
4738
4399
|
this.resetConfig(this.config);
|
|
4739
4400
|
this.navigationTransitions.setupNavigations(this).subscribe({
|
|
4740
|
-
error: e => {
|
|
4741
|
-
this.console.warn(ngDevMode ? `Unhandled Navigation Error: ${e}` : e);
|
|
4742
|
-
}
|
|
4401
|
+
error: e => {}
|
|
4743
4402
|
});
|
|
4744
4403
|
this.subscribeToNavigationEvents();
|
|
4745
4404
|
}
|
|
@@ -4755,6 +4414,7 @@ class Router {
|
|
|
4755
4414
|
this.navigated = true;
|
|
4756
4415
|
} else if (e instanceof NavigationEnd) {
|
|
4757
4416
|
this.navigated = true;
|
|
4417
|
+
this.injectorCleanup?.(this.routeReuseStrategy, this.routerState, this.config);
|
|
4758
4418
|
} else if (e instanceof RedirectRequest) {
|
|
4759
4419
|
const opts = e.navigationBehaviorOptions;
|
|
4760
4420
|
const mergedTree = this.urlHandlingStrategy.merge(e.url, currentTransition.currentRawUrl);
|
|
@@ -4840,10 +4500,8 @@ class Router {
|
|
|
4840
4500
|
dispose() {
|
|
4841
4501
|
this._events.unsubscribe();
|
|
4842
4502
|
this.navigationTransitions.complete();
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
this.nonRouterCurrentEntryChangeSubscription = undefined;
|
|
4846
|
-
}
|
|
4503
|
+
this.nonRouterCurrentEntryChangeSubscription?.unsubscribe();
|
|
4504
|
+
this.nonRouterCurrentEntryChangeSubscription = undefined;
|
|
4847
4505
|
this.disposed = true;
|
|
4848
4506
|
this.eventsSubscription.unsubscribe();
|
|
4849
4507
|
}
|
|
@@ -4976,7 +4634,7 @@ class Router {
|
|
|
4976
4634
|
}
|
|
4977
4635
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
4978
4636
|
minVersion: "12.0.0",
|
|
4979
|
-
version: "21.1.0
|
|
4637
|
+
version: "21.1.0",
|
|
4980
4638
|
ngImport: i0,
|
|
4981
4639
|
type: Router,
|
|
4982
4640
|
deps: [],
|
|
@@ -4984,7 +4642,7 @@ class Router {
|
|
|
4984
4642
|
});
|
|
4985
4643
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
4986
4644
|
minVersion: "12.0.0",
|
|
4987
|
-
version: "21.1.0
|
|
4645
|
+
version: "21.1.0",
|
|
4988
4646
|
ngImport: i0,
|
|
4989
4647
|
type: Router,
|
|
4990
4648
|
providedIn: 'root'
|
|
@@ -4992,7 +4650,7 @@ class Router {
|
|
|
4992
4650
|
}
|
|
4993
4651
|
i0.ɵɵngDeclareClassMetadata({
|
|
4994
4652
|
minVersion: "12.0.0",
|
|
4995
|
-
version: "21.1.0
|
|
4653
|
+
version: "21.1.0",
|
|
4996
4654
|
ngImport: i0,
|
|
4997
4655
|
type: Router,
|
|
4998
4656
|
decorators: [{
|
|
@@ -5012,5 +4670,5 @@ function validateCommands(commands) {
|
|
|
5012
4670
|
}
|
|
5013
4671
|
}
|
|
5014
4672
|
|
|
5015
|
-
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, BeforeActivateRoutes, CREATE_VIEW_TRANSITION, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, EventType, GuardsCheckEnd, GuardsCheckStart, IMPERATIVE_NAVIGATION, INPUT_BINDER, NAVIGATION_ERROR_HANDLER, NavigationCancel, NavigationCancellationCode, NavigationEnd, NavigationError, NavigationSkipped, NavigationSkippedCode, NavigationStart, NavigationTransitions, OutletContext, PRIMARY_OUTLET, ROUTER_CONFIGURATION, ROUTER_OUTLET_DATA, ROUTES, RedirectCommand, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, RoutedComponentInputBinder, Router, RouterConfigLoader, RouterEvent, RouterOutlet, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, StateManager, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VIEW_TRANSITION_OPTIONS, afterNextNavigation, convertToParamMap, createUrlTreeFromSnapshot, createViewTransition, defaultUrlMatcher, isRedirectingEvent, isUrlTree, loadChildren,
|
|
4673
|
+
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, BeforeActivateRoutes, CREATE_VIEW_TRANSITION, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, EventType, GuardsCheckEnd, GuardsCheckStart, IMPERATIVE_NAVIGATION, INPUT_BINDER, NAVIGATION_ERROR_HANDLER, NavigationCancel, NavigationCancellationCode, NavigationEnd, NavigationError, NavigationSkipped, NavigationSkippedCode, NavigationStart, NavigationTransitions, OutletContext, PRIMARY_OUTLET, ROUTER_CONFIGURATION, ROUTER_OUTLET_DATA, ROUTES, ROUTE_INJECTOR_CLEANUP, RedirectCommand, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, RoutedComponentInputBinder, Router, RouterConfigLoader, RouterEvent, RouterOutlet, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, StateManager, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VIEW_TRANSITION_OPTIONS, afterNextNavigation, convertToParamMap, createUrlTreeFromSnapshot, createViewTransition, defaultUrlMatcher, destroyDetachedRouteHandle, exactMatchOptions, isActive, isRedirectingEvent, isUrlTree, loadChildren, routeInjectorCleanup, stringifyEvent, subsetMatchOptions, ɵEmptyOutletComponent };
|
|
5016
4674
|
//# sourceMappingURL=_router-chunk.mjs.map
|