@angular/router 14.1.0-next.0 → 14.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.
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Angular v14.1.0-next.0
2
+ * @license Angular v14.1.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
8
  import { ɵisObservable, ɵisPromise, EventEmitter, Directive, Attribute, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, InjectionToken, InjectFlags, NgModuleFactory, Injectable, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
9
- import { from, of, BehaviorSubject, combineLatest, throwError, EmptyError, concat, defer, Observable, EMPTY, ConnectableObservable, Subject } from 'rxjs';
10
- import { map, switchMap, take, startWith, scan, filter, catchError, concatMap, last as last$1, first, mergeMap, tap, takeLast, mapTo, finalize, refCount, defaultIfEmpty, mergeAll } from 'rxjs/operators';
9
+ import { from, of, BehaviorSubject, combineLatest, concat, defer, pipe, throwError, EmptyError, Observable, EMPTY, ConnectableObservable, Subject } from 'rxjs';
10
+ import { map, switchMap, take, startWith, scan, filter, mergeMap, first, concatMap, tap, catchError, last as last$1, takeWhile, defaultIfEmpty, takeLast, mapTo, finalize, refCount, mergeAll } from 'rxjs/operators';
11
11
  import * as i3 from '@angular/common';
12
12
  import { Location, LocationStrategy, PlatformLocation, APP_BASE_HREF, ViewportScroller, HashLocationStrategy, PathLocationStrategy, LOCATION_INITIALIZED } from '@angular/common';
13
13
  import * as i1 from '@angular/platform-browser';
@@ -2493,9 +2493,9 @@ class RouterOutlet {
2493
2493
  this.activateEvents.emit(this.activated.instance);
2494
2494
  }
2495
2495
  }
2496
- RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2497
- RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.0", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterOutlet, decorators: [{
2496
+ RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2497
+ RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterOutlet, decorators: [{
2499
2499
  type: Directive,
2500
2500
  args: [{ selector: 'router-outlet', exportAs: 'outlet' }]
2501
2501
  }], ctorParameters: function () {
@@ -2554,9 +2554,9 @@ function isComponentFactoryResolver(item) {
2554
2554
  */
2555
2555
  class ɵEmptyOutletComponent {
2556
2556
  }
2557
- ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2558
- ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0-next.0", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2559
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2557
+ ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2558
+ ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0-next.1", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2559
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2560
2560
  type: Component,
2561
2561
  args: [{ template: `<router-outlet></router-outlet>` }]
2562
2562
  }] });
@@ -2929,6 +2929,146 @@ class ActivateRoutes {
2929
2929
  }
2930
2930
  }
2931
2931
 
2932
+ /**
2933
+ * @license
2934
+ * Copyright Google LLC All Rights Reserved.
2935
+ *
2936
+ * Use of this source code is governed by an MIT-style license that can be
2937
+ * found in the LICENSE file at https://angular.io/license
2938
+ */
2939
+ class CanActivate {
2940
+ constructor(path) {
2941
+ this.path = path;
2942
+ this.route = this.path[this.path.length - 1];
2943
+ }
2944
+ }
2945
+ class CanDeactivate {
2946
+ constructor(component, route) {
2947
+ this.component = component;
2948
+ this.route = route;
2949
+ }
2950
+ }
2951
+ function getAllRouteGuards(future, curr, parentContexts) {
2952
+ const futureRoot = future._root;
2953
+ const currRoot = curr ? curr._root : null;
2954
+ return getChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
2955
+ }
2956
+ function getCanActivateChild(p) {
2957
+ const canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
2958
+ if (!canActivateChild || canActivateChild.length === 0)
2959
+ return null;
2960
+ return { node: p, guards: canActivateChild };
2961
+ }
2962
+ function getToken(token, snapshot, fallbackInjector) {
2963
+ const routeInjector = getClosestRouteInjector(snapshot);
2964
+ const injector = routeInjector !== null && routeInjector !== void 0 ? routeInjector : fallbackInjector;
2965
+ return injector.get(token);
2966
+ }
2967
+ function getChildRouteGuards(futureNode, currNode, contexts, futurePath, checks = {
2968
+ canDeactivateChecks: [],
2969
+ canActivateChecks: []
2970
+ }) {
2971
+ const prevChildren = nodeChildrenAsMap(currNode);
2972
+ // Process the children of the future route
2973
+ futureNode.children.forEach(c => {
2974
+ getRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]), checks);
2975
+ delete prevChildren[c.value.outlet];
2976
+ });
2977
+ // Process any children left from the current route (not active for the future route)
2978
+ forEach(prevChildren, (v, k) => deactivateRouteAndItsChildren(v, contexts.getContext(k), checks));
2979
+ return checks;
2980
+ }
2981
+ function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks = {
2982
+ canDeactivateChecks: [],
2983
+ canActivateChecks: []
2984
+ }) {
2985
+ const future = futureNode.value;
2986
+ const curr = currNode ? currNode.value : null;
2987
+ const context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
2988
+ // reusing the node
2989
+ if (curr && future.routeConfig === curr.routeConfig) {
2990
+ const shouldRun = shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
2991
+ if (shouldRun) {
2992
+ checks.canActivateChecks.push(new CanActivate(futurePath));
2993
+ }
2994
+ else {
2995
+ // we need to set the data
2996
+ future.data = curr.data;
2997
+ future._resolvedData = curr._resolvedData;
2998
+ }
2999
+ // If we have a component, we need to go through an outlet.
3000
+ if (future.component) {
3001
+ getChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath, checks);
3002
+ // if we have a componentless route, we recurse but keep the same outlet map.
3003
+ }
3004
+ else {
3005
+ getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks);
3006
+ }
3007
+ if (shouldRun && context && context.outlet && context.outlet.isActivated) {
3008
+ checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, curr));
3009
+ }
3010
+ }
3011
+ else {
3012
+ if (curr) {
3013
+ deactivateRouteAndItsChildren(currNode, context, checks);
3014
+ }
3015
+ checks.canActivateChecks.push(new CanActivate(futurePath));
3016
+ // If we have a component, we need to go through an outlet.
3017
+ if (future.component) {
3018
+ getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks);
3019
+ // if we have a componentless route, we recurse but keep the same outlet map.
3020
+ }
3021
+ else {
3022
+ getChildRouteGuards(futureNode, null, parentContexts, futurePath, checks);
3023
+ }
3024
+ }
3025
+ return checks;
3026
+ }
3027
+ function shouldRunGuardsAndResolvers(curr, future, mode) {
3028
+ if (typeof mode === 'function') {
3029
+ return mode(curr, future);
3030
+ }
3031
+ switch (mode) {
3032
+ case 'pathParamsChange':
3033
+ return !equalPath(curr.url, future.url);
3034
+ case 'pathParamsOrQueryParamsChange':
3035
+ return !equalPath(curr.url, future.url) ||
3036
+ !shallowEqual(curr.queryParams, future.queryParams);
3037
+ case 'always':
3038
+ return true;
3039
+ case 'paramsOrQueryParamsChange':
3040
+ return !equalParamsAndUrlSegments(curr, future) ||
3041
+ !shallowEqual(curr.queryParams, future.queryParams);
3042
+ case 'paramsChange':
3043
+ default:
3044
+ return !equalParamsAndUrlSegments(curr, future);
3045
+ }
3046
+ }
3047
+ function deactivateRouteAndItsChildren(route, context, checks) {
3048
+ const children = nodeChildrenAsMap(route);
3049
+ const r = route.value;
3050
+ forEach(children, (node, childName) => {
3051
+ if (!r.component) {
3052
+ deactivateRouteAndItsChildren(node, context, checks);
3053
+ }
3054
+ else if (context) {
3055
+ deactivateRouteAndItsChildren(node, context.children.getContext(childName), checks);
3056
+ }
3057
+ else {
3058
+ deactivateRouteAndItsChildren(node, null, checks);
3059
+ }
3060
+ });
3061
+ if (!r.component) {
3062
+ checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3063
+ }
3064
+ else if (context && context.outlet && context.outlet.isActivated) {
3065
+ checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
3066
+ }
3067
+ else {
3068
+ checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3069
+ }
3070
+ }
3071
+
2932
3072
  /**
2933
3073
  * @license
2934
3074
  * Copyright Google LLC All Rights Reserved.
@@ -2970,6 +3110,9 @@ function isCanActivateChild(guard) {
2970
3110
  function isCanDeactivate(guard) {
2971
3111
  return guard && isFunction(guard.canDeactivate);
2972
3112
  }
3113
+ function isCanMatch(guard) {
3114
+ return guard && isFunction(guard.canMatch);
3115
+ }
2973
3116
 
2974
3117
  /**
2975
3118
  * @license
@@ -3010,6 +3153,180 @@ function prioritizedGuardValue() {
3010
3153
  });
3011
3154
  }
3012
3155
 
3156
+ /**
3157
+ * @license
3158
+ * Copyright Google LLC All Rights Reserved.
3159
+ *
3160
+ * Use of this source code is governed by an MIT-style license that can be
3161
+ * found in the LICENSE file at https://angular.io/license
3162
+ */
3163
+ function checkGuards(moduleInjector, forwardEvent) {
3164
+ return mergeMap(t => {
3165
+ const { targetSnapshot, currentSnapshot, guards: { canActivateChecks, canDeactivateChecks } } = t;
3166
+ if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
3167
+ return of(Object.assign(Object.assign({}, t), { guardsResult: true }));
3168
+ }
3169
+ return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, moduleInjector)
3170
+ .pipe(mergeMap(canDeactivate => {
3171
+ return canDeactivate && isBoolean(canDeactivate) ?
3172
+ runCanActivateChecks(targetSnapshot, canActivateChecks, moduleInjector, forwardEvent) :
3173
+ of(canDeactivate);
3174
+ }), map(guardsResult => (Object.assign(Object.assign({}, t), { guardsResult }))));
3175
+ });
3176
+ }
3177
+ function runCanDeactivateChecks(checks, futureRSS, currRSS, moduleInjector) {
3178
+ return from(checks).pipe(mergeMap(check => runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector)), first(result => {
3179
+ return result !== true;
3180
+ }, true));
3181
+ }
3182
+ function runCanActivateChecks(futureSnapshot, checks, moduleInjector, forwardEvent) {
3183
+ return from(checks).pipe(concatMap((check) => {
3184
+ return concat(fireChildActivationStart(check.route.parent, forwardEvent), fireActivationStart(check.route, forwardEvent), runCanActivateChild(futureSnapshot, check.path, moduleInjector), runCanActivate(futureSnapshot, check.route, moduleInjector));
3185
+ }), first(result => {
3186
+ return result !== true;
3187
+ }, true));
3188
+ }
3189
+ /**
3190
+ * This should fire off `ActivationStart` events for each route being activated at this
3191
+ * level.
3192
+ * In other words, if you're activating `a` and `b` below, `path` will contain the
3193
+ * `ActivatedRouteSnapshot`s for both and we will fire `ActivationStart` for both. Always
3194
+ * return
3195
+ * `true` so checks continue to run.
3196
+ */
3197
+ function fireActivationStart(snapshot, forwardEvent) {
3198
+ if (snapshot !== null && forwardEvent) {
3199
+ forwardEvent(new ActivationStart(snapshot));
3200
+ }
3201
+ return of(true);
3202
+ }
3203
+ /**
3204
+ * This should fire off `ChildActivationStart` events for each route being activated at this
3205
+ * level.
3206
+ * In other words, if you're activating `a` and `b` below, `path` will contain the
3207
+ * `ActivatedRouteSnapshot`s for both and we will fire `ChildActivationStart` for both. Always
3208
+ * return
3209
+ * `true` so checks continue to run.
3210
+ */
3211
+ function fireChildActivationStart(snapshot, forwardEvent) {
3212
+ if (snapshot !== null && forwardEvent) {
3213
+ forwardEvent(new ChildActivationStart(snapshot));
3214
+ }
3215
+ return of(true);
3216
+ }
3217
+ function runCanActivate(futureRSS, futureARS, moduleInjector) {
3218
+ const canActivate = futureARS.routeConfig ? futureARS.routeConfig.canActivate : null;
3219
+ if (!canActivate || canActivate.length === 0)
3220
+ return of(true);
3221
+ const canActivateObservables = canActivate.map((c) => {
3222
+ return defer(() => {
3223
+ const guard = getToken(c, futureARS, moduleInjector);
3224
+ let observable;
3225
+ if (isCanActivate(guard)) {
3226
+ observable = wrapIntoObservable(guard.canActivate(futureARS, futureRSS));
3227
+ }
3228
+ else if (isFunction(guard)) {
3229
+ observable = wrapIntoObservable(guard(futureARS, futureRSS));
3230
+ }
3231
+ else {
3232
+ throw new Error('Invalid CanActivate guard');
3233
+ }
3234
+ return observable.pipe(first());
3235
+ });
3236
+ });
3237
+ return of(canActivateObservables).pipe(prioritizedGuardValue());
3238
+ }
3239
+ function runCanActivateChild(futureRSS, path, moduleInjector) {
3240
+ const futureARS = path[path.length - 1];
3241
+ const canActivateChildGuards = path.slice(0, path.length - 1)
3242
+ .reverse()
3243
+ .map(p => getCanActivateChild(p))
3244
+ .filter(_ => _ !== null);
3245
+ const canActivateChildGuardsMapped = canActivateChildGuards.map((d) => {
3246
+ return defer(() => {
3247
+ const guardsMapped = d.guards.map((c) => {
3248
+ const guard = getToken(c, d.node, moduleInjector);
3249
+ let observable;
3250
+ if (isCanActivateChild(guard)) {
3251
+ observable = wrapIntoObservable(guard.canActivateChild(futureARS, futureRSS));
3252
+ }
3253
+ else if (isFunction(guard)) {
3254
+ observable = wrapIntoObservable(guard(futureARS, futureRSS));
3255
+ }
3256
+ else {
3257
+ throw new Error('Invalid CanActivateChild guard');
3258
+ }
3259
+ return observable.pipe(first());
3260
+ });
3261
+ return of(guardsMapped).pipe(prioritizedGuardValue());
3262
+ });
3263
+ });
3264
+ return of(canActivateChildGuardsMapped).pipe(prioritizedGuardValue());
3265
+ }
3266
+ function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector) {
3267
+ const canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
3268
+ if (!canDeactivate || canDeactivate.length === 0)
3269
+ return of(true);
3270
+ const canDeactivateObservables = canDeactivate.map((c) => {
3271
+ const guard = getToken(c, currARS, moduleInjector);
3272
+ let observable;
3273
+ if (isCanDeactivate(guard)) {
3274
+ observable = wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
3275
+ }
3276
+ else if (isFunction(guard)) {
3277
+ observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
3278
+ }
3279
+ else {
3280
+ throw new Error('Invalid CanDeactivate guard');
3281
+ }
3282
+ return observable.pipe(first());
3283
+ });
3284
+ return of(canDeactivateObservables).pipe(prioritizedGuardValue());
3285
+ }
3286
+ function runCanLoadGuards(injector, route, segments, urlSerializer) {
3287
+ const canLoad = route.canLoad;
3288
+ if (canLoad === undefined || canLoad.length === 0) {
3289
+ return of(true);
3290
+ }
3291
+ const canLoadObservables = canLoad.map((injectionToken) => {
3292
+ const guard = injector.get(injectionToken);
3293
+ let guardVal;
3294
+ if (isCanLoad(guard)) {
3295
+ guardVal = guard.canLoad(route, segments);
3296
+ }
3297
+ else if (isFunction(guard)) {
3298
+ guardVal = guard(route, segments);
3299
+ }
3300
+ else {
3301
+ throw new Error('Invalid CanLoad guard');
3302
+ }
3303
+ return wrapIntoObservable(guardVal);
3304
+ });
3305
+ return of(canLoadObservables)
3306
+ .pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
3307
+ }
3308
+ function redirectIfUrlTree(urlSerializer) {
3309
+ return pipe(tap((result) => {
3310
+ if (!isUrlTree(result))
3311
+ return;
3312
+ const error = navigationCancelingError(`Redirecting to "${urlSerializer.serialize(result)}"`);
3313
+ error.url = result;
3314
+ throw error;
3315
+ }), map(result => result === true));
3316
+ }
3317
+ function runCanMatchGuards(injector, route, segments, urlSerializer) {
3318
+ const canMatch = route.canMatch;
3319
+ if (!canMatch || canMatch.length === 0)
3320
+ return of(true);
3321
+ const canMatchObservables = canMatch.map(injectionToken => {
3322
+ const guard = injector.get(injectionToken);
3323
+ const guardVal = isCanMatch(guard) ? guard.canMatch(route, segments) : guard(route, segments);
3324
+ return wrapIntoObservable(guardVal);
3325
+ });
3326
+ return of(canMatchObservables)
3327
+ .pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
3328
+ }
3329
+
3013
3330
  /**
3014
3331
  * @license
3015
3332
  * Copyright Google LLC All Rights Reserved.
@@ -3024,6 +3341,14 @@ const noMatch$1 = {
3024
3341
  parameters: {},
3025
3342
  positionalParamSegments: {}
3026
3343
  };
3344
+ function matchWithChecks(segmentGroup, route, segments, injector, urlSerializer) {
3345
+ const result = match(segmentGroup, route, segments);
3346
+ if (!result.matched) {
3347
+ return of(result);
3348
+ }
3349
+ return runCanMatchGuards(injector, route, segments, urlSerializer)
3350
+ .pipe(map((v) => v === true ? result : Object.assign({}, noMatch$1)));
3351
+ }
3027
3352
  function match(segmentGroup, route, segments) {
3028
3353
  var _a;
3029
3354
  if (route.path === '') {
@@ -3355,29 +3680,32 @@ class ApplyRedirects {
3355
3680
  }
3356
3681
  return of(new UrlSegmentGroup(segments, {}));
3357
3682
  }
3358
- const { matched, consumedSegments, remainingSegments } = match(rawSegmentGroup, route, segments);
3359
- if (!matched)
3360
- return noMatch(rawSegmentGroup);
3361
- // Only create the Route's `EnvironmentInjector` if it matches the attempted navigation
3362
- injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3363
- const childConfig$ = this.getChildConfig(injector, route, segments);
3364
- return childConfig$.pipe(mergeMap((routerConfig) => {
3365
- var _a;
3366
- const childInjector = (_a = routerConfig.injector) !== null && _a !== void 0 ? _a : injector;
3367
- const childConfig = routerConfig.routes;
3368
- const { segmentGroup: splitSegmentGroup, slicedSegments } = split(rawSegmentGroup, consumedSegments, remainingSegments, childConfig);
3369
- // See comment on the other call to `split` about why this is necessary.
3370
- const segmentGroup = new UrlSegmentGroup(splitSegmentGroup.segments, splitSegmentGroup.children);
3371
- if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3372
- const expanded$ = this.expandChildren(childInjector, childConfig, segmentGroup);
3373
- return expanded$.pipe(map((children) => new UrlSegmentGroup(consumedSegments, children)));
3374
- }
3375
- if (childConfig.length === 0 && slicedSegments.length === 0) {
3376
- return of(new UrlSegmentGroup(consumedSegments, {}));
3377
- }
3378
- const matchedOnOutlet = getOutlet(route) === outlet;
3379
- const expanded$ = this.expandSegment(childInjector, segmentGroup, childConfig, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true);
3380
- return expanded$.pipe(map((cs) => new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children)));
3683
+ return matchWithChecks(rawSegmentGroup, route, segments, injector, this.urlSerializer)
3684
+ .pipe(switchMap(({ matched, consumedSegments, remainingSegments }) => {
3685
+ if (!matched)
3686
+ return noMatch(rawSegmentGroup);
3687
+ // Only create the Route's `EnvironmentInjector` if it matches the attempted
3688
+ // navigation
3689
+ injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3690
+ const childConfig$ = this.getChildConfig(injector, route, segments);
3691
+ return childConfig$.pipe(mergeMap((routerConfig) => {
3692
+ var _a;
3693
+ const childInjector = (_a = routerConfig.injector) !== null && _a !== void 0 ? _a : injector;
3694
+ const childConfig = routerConfig.routes;
3695
+ const { segmentGroup: splitSegmentGroup, slicedSegments } = split(rawSegmentGroup, consumedSegments, remainingSegments, childConfig);
3696
+ // See comment on the other call to `split` about why this is necessary.
3697
+ const segmentGroup = new UrlSegmentGroup(splitSegmentGroup.segments, splitSegmentGroup.children);
3698
+ if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3699
+ const expanded$ = this.expandChildren(childInjector, childConfig, segmentGroup);
3700
+ return expanded$.pipe(map((children) => new UrlSegmentGroup(consumedSegments, children)));
3701
+ }
3702
+ if (childConfig.length === 0 && slicedSegments.length === 0) {
3703
+ return of(new UrlSegmentGroup(consumedSegments, {}));
3704
+ }
3705
+ const matchedOnOutlet = getOutlet(route) === outlet;
3706
+ const expanded$ = this.expandSegment(childInjector, segmentGroup, childConfig, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true);
3707
+ return expanded$.pipe(map((cs) => new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children)));
3708
+ }));
3381
3709
  }));
3382
3710
  }
3383
3711
  getChildConfig(injector, route, segments) {
@@ -3390,7 +3718,7 @@ class ApplyRedirects {
3390
3718
  if (route._loadedRoutes !== undefined) {
3391
3719
  return of({ routes: route._loadedRoutes, injector: route._loadedInjector });
3392
3720
  }
3393
- return this.runCanLoadGuards(injector, route, segments)
3721
+ return runCanLoadGuards(injector, route, segments, this.urlSerializer)
3394
3722
  .pipe(mergeMap((shouldLoadResult) => {
3395
3723
  if (shouldLoadResult) {
3396
3724
  return this.configLoader.loadChildren(injector, route)
@@ -3404,33 +3732,6 @@ class ApplyRedirects {
3404
3732
  }
3405
3733
  return of({ routes: [], injector });
3406
3734
  }
3407
- runCanLoadGuards(injector, route, segments) {
3408
- const canLoad = route.canLoad;
3409
- if (!canLoad || canLoad.length === 0)
3410
- return of(true);
3411
- const canLoadObservables = canLoad.map((injectionToken) => {
3412
- const guard = injector.get(injectionToken);
3413
- let guardVal;
3414
- if (isCanLoad(guard)) {
3415
- guardVal = guard.canLoad(route, segments);
3416
- }
3417
- else if (isFunction(guard)) {
3418
- guardVal = guard(route, segments);
3419
- }
3420
- else {
3421
- throw new Error('Invalid CanLoad guard');
3422
- }
3423
- return wrapIntoObservable(guardVal);
3424
- });
3425
- return of(canLoadObservables)
3426
- .pipe(prioritizedGuardValue(), tap((result) => {
3427
- if (!isUrlTree(result))
3428
- return;
3429
- const error = navigationCancelingError(`Redirecting to "${this.urlSerializer.serialize(result)}"`);
3430
- error.url = result;
3431
- throw error;
3432
- }), map(result => result === true));
3433
- }
3434
3735
  lineralizeSegments(route, urlTree) {
3435
3736
  let res = [];
3436
3737
  let c = urlTree.root;
@@ -3459,193 +3760,41 @@ class ApplyRedirects {
3459
3760
  if (copySourceValue) {
3460
3761
  const sourceName = v.substring(1);
3461
3762
  res[k] = actualParams[sourceName];
3462
- }
3463
- else {
3464
- res[k] = v;
3465
- }
3466
- });
3467
- return res;
3468
- }
3469
- createSegmentGroup(redirectTo, group, segments, posParams) {
3470
- const updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
3471
- let children = {};
3472
- forEach(group.children, (child, name) => {
3473
- children[name] = this.createSegmentGroup(redirectTo, child, segments, posParams);
3474
- });
3475
- return new UrlSegmentGroup(updatedSegments, children);
3476
- }
3477
- createSegments(redirectTo, redirectToSegments, actualSegments, posParams) {
3478
- return redirectToSegments.map(s => s.path.startsWith(':') ? this.findPosParam(redirectTo, s, posParams) :
3479
- this.findOrReturn(s, actualSegments));
3480
- }
3481
- findPosParam(redirectTo, redirectToUrlSegment, posParams) {
3482
- const pos = posParams[redirectToUrlSegment.path.substring(1)];
3483
- if (!pos)
3484
- throw new Error(`Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3485
- return pos;
3486
- }
3487
- findOrReturn(redirectToUrlSegment, actualSegments) {
3488
- let idx = 0;
3489
- for (const s of actualSegments) {
3490
- if (s.path === redirectToUrlSegment.path) {
3491
- actualSegments.splice(idx);
3492
- return s;
3493
- }
3494
- idx++;
3495
- }
3496
- return redirectToUrlSegment;
3497
- }
3498
- }
3499
-
3500
- /**
3501
- * @license
3502
- * Copyright Google LLC All Rights Reserved.
3503
- *
3504
- * Use of this source code is governed by an MIT-style license that can be
3505
- * found in the LICENSE file at https://angular.io/license
3506
- */
3507
- function applyRedirects(environmentInjector, configLoader, urlSerializer, config) {
3508
- return switchMap(t => applyRedirects$1(environmentInjector, configLoader, urlSerializer, t.extractedUrl, config)
3509
- .pipe(map(urlAfterRedirects => (Object.assign(Object.assign({}, t), { urlAfterRedirects })))));
3510
- }
3511
-
3512
- /**
3513
- * @license
3514
- * Copyright Google LLC All Rights Reserved.
3515
- *
3516
- * Use of this source code is governed by an MIT-style license that can be
3517
- * found in the LICENSE file at https://angular.io/license
3518
- */
3519
- class CanActivate {
3520
- constructor(path) {
3521
- this.path = path;
3522
- this.route = this.path[this.path.length - 1];
3523
- }
3524
- }
3525
- class CanDeactivate {
3526
- constructor(component, route) {
3527
- this.component = component;
3528
- this.route = route;
3529
- }
3530
- }
3531
- function getAllRouteGuards(future, curr, parentContexts) {
3532
- const futureRoot = future._root;
3533
- const currRoot = curr ? curr._root : null;
3534
- return getChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
3535
- }
3536
- function getCanActivateChild(p) {
3537
- const canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
3538
- if (!canActivateChild || canActivateChild.length === 0)
3539
- return null;
3540
- return { node: p, guards: canActivateChild };
3541
- }
3542
- function getToken(token, snapshot, fallbackInjector) {
3543
- const routeInjector = getClosestRouteInjector(snapshot);
3544
- const injector = routeInjector !== null && routeInjector !== void 0 ? routeInjector : fallbackInjector;
3545
- return injector.get(token);
3546
- }
3547
- function getChildRouteGuards(futureNode, currNode, contexts, futurePath, checks = {
3548
- canDeactivateChecks: [],
3549
- canActivateChecks: []
3550
- }) {
3551
- const prevChildren = nodeChildrenAsMap(currNode);
3552
- // Process the children of the future route
3553
- futureNode.children.forEach(c => {
3554
- getRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]), checks);
3555
- delete prevChildren[c.value.outlet];
3556
- });
3557
- // Process any children left from the current route (not active for the future route)
3558
- forEach(prevChildren, (v, k) => deactivateRouteAndItsChildren(v, contexts.getContext(k), checks));
3559
- return checks;
3560
- }
3561
- function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks = {
3562
- canDeactivateChecks: [],
3563
- canActivateChecks: []
3564
- }) {
3565
- const future = futureNode.value;
3566
- const curr = currNode ? currNode.value : null;
3567
- const context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
3568
- // reusing the node
3569
- if (curr && future.routeConfig === curr.routeConfig) {
3570
- const shouldRun = shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
3571
- if (shouldRun) {
3572
- checks.canActivateChecks.push(new CanActivate(futurePath));
3573
- }
3574
- else {
3575
- // we need to set the data
3576
- future.data = curr.data;
3577
- future._resolvedData = curr._resolvedData;
3578
- }
3579
- // If we have a component, we need to go through an outlet.
3580
- if (future.component) {
3581
- getChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath, checks);
3582
- // if we have a componentless route, we recurse but keep the same outlet map.
3583
- }
3584
- else {
3585
- getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks);
3586
- }
3587
- if (shouldRun && context && context.outlet && context.outlet.isActivated) {
3588
- checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, curr));
3589
- }
3590
- }
3591
- else {
3592
- if (curr) {
3593
- deactivateRouteAndItsChildren(currNode, context, checks);
3594
- }
3595
- checks.canActivateChecks.push(new CanActivate(futurePath));
3596
- // If we have a component, we need to go through an outlet.
3597
- if (future.component) {
3598
- getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks);
3599
- // if we have a componentless route, we recurse but keep the same outlet map.
3600
- }
3601
- else {
3602
- getChildRouteGuards(futureNode, null, parentContexts, futurePath, checks);
3603
- }
3604
- }
3605
- return checks;
3606
- }
3607
- function shouldRunGuardsAndResolvers(curr, future, mode) {
3608
- if (typeof mode === 'function') {
3609
- return mode(curr, future);
3763
+ }
3764
+ else {
3765
+ res[k] = v;
3766
+ }
3767
+ });
3768
+ return res;
3610
3769
  }
3611
- switch (mode) {
3612
- case 'pathParamsChange':
3613
- return !equalPath(curr.url, future.url);
3614
- case 'pathParamsOrQueryParamsChange':
3615
- return !equalPath(curr.url, future.url) ||
3616
- !shallowEqual(curr.queryParams, future.queryParams);
3617
- case 'always':
3618
- return true;
3619
- case 'paramsOrQueryParamsChange':
3620
- return !equalParamsAndUrlSegments(curr, future) ||
3621
- !shallowEqual(curr.queryParams, future.queryParams);
3622
- case 'paramsChange':
3623
- default:
3624
- return !equalParamsAndUrlSegments(curr, future);
3770
+ createSegmentGroup(redirectTo, group, segments, posParams) {
3771
+ const updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
3772
+ let children = {};
3773
+ forEach(group.children, (child, name) => {
3774
+ children[name] = this.createSegmentGroup(redirectTo, child, segments, posParams);
3775
+ });
3776
+ return new UrlSegmentGroup(updatedSegments, children);
3625
3777
  }
3626
- }
3627
- function deactivateRouteAndItsChildren(route, context, checks) {
3628
- const children = nodeChildrenAsMap(route);
3629
- const r = route.value;
3630
- forEach(children, (node, childName) => {
3631
- if (!r.component) {
3632
- deactivateRouteAndItsChildren(node, context, checks);
3633
- }
3634
- else if (context) {
3635
- deactivateRouteAndItsChildren(node, context.children.getContext(childName), checks);
3636
- }
3637
- else {
3638
- deactivateRouteAndItsChildren(node, null, checks);
3639
- }
3640
- });
3641
- if (!r.component) {
3642
- checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3778
+ createSegments(redirectTo, redirectToSegments, actualSegments, posParams) {
3779
+ return redirectToSegments.map(s => s.path.startsWith(':') ? this.findPosParam(redirectTo, s, posParams) :
3780
+ this.findOrReturn(s, actualSegments));
3643
3781
  }
3644
- else if (context && context.outlet && context.outlet.isActivated) {
3645
- checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
3782
+ findPosParam(redirectTo, redirectToUrlSegment, posParams) {
3783
+ const pos = posParams[redirectToUrlSegment.path.substring(1)];
3784
+ if (!pos)
3785
+ throw new Error(`Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3786
+ return pos;
3646
3787
  }
3647
- else {
3648
- checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3788
+ findOrReturn(redirectToUrlSegment, actualSegments) {
3789
+ let idx = 0;
3790
+ for (const s of actualSegments) {
3791
+ if (s.path === redirectToUrlSegment.path) {
3792
+ actualSegments.splice(idx);
3793
+ return s;
3794
+ }
3795
+ idx++;
3796
+ }
3797
+ return redirectToUrlSegment;
3649
3798
  }
3650
3799
  }
3651
3800
 
@@ -3656,128 +3805,9 @@ function deactivateRouteAndItsChildren(route, context, checks) {
3656
3805
  * Use of this source code is governed by an MIT-style license that can be
3657
3806
  * found in the LICENSE file at https://angular.io/license
3658
3807
  */
3659
- function checkGuards(moduleInjector, forwardEvent) {
3660
- return mergeMap(t => {
3661
- const { targetSnapshot, currentSnapshot, guards: { canActivateChecks, canDeactivateChecks } } = t;
3662
- if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
3663
- return of(Object.assign(Object.assign({}, t), { guardsResult: true }));
3664
- }
3665
- return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, moduleInjector)
3666
- .pipe(mergeMap(canDeactivate => {
3667
- return canDeactivate && isBoolean(canDeactivate) ?
3668
- runCanActivateChecks(targetSnapshot, canActivateChecks, moduleInjector, forwardEvent) :
3669
- of(canDeactivate);
3670
- }), map(guardsResult => (Object.assign(Object.assign({}, t), { guardsResult }))));
3671
- });
3672
- }
3673
- function runCanDeactivateChecks(checks, futureRSS, currRSS, moduleInjector) {
3674
- return from(checks).pipe(mergeMap(check => runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector)), first(result => {
3675
- return result !== true;
3676
- }, true));
3677
- }
3678
- function runCanActivateChecks(futureSnapshot, checks, moduleInjector, forwardEvent) {
3679
- return from(checks).pipe(concatMap((check) => {
3680
- return concat(fireChildActivationStart(check.route.parent, forwardEvent), fireActivationStart(check.route, forwardEvent), runCanActivateChild(futureSnapshot, check.path, moduleInjector), runCanActivate(futureSnapshot, check.route, moduleInjector));
3681
- }), first(result => {
3682
- return result !== true;
3683
- }, true));
3684
- }
3685
- /**
3686
- * This should fire off `ActivationStart` events for each route being activated at this
3687
- * level.
3688
- * In other words, if you're activating `a` and `b` below, `path` will contain the
3689
- * `ActivatedRouteSnapshot`s for both and we will fire `ActivationStart` for both. Always
3690
- * return
3691
- * `true` so checks continue to run.
3692
- */
3693
- function fireActivationStart(snapshot, forwardEvent) {
3694
- if (snapshot !== null && forwardEvent) {
3695
- forwardEvent(new ActivationStart(snapshot));
3696
- }
3697
- return of(true);
3698
- }
3699
- /**
3700
- * This should fire off `ChildActivationStart` events for each route being activated at this
3701
- * level.
3702
- * In other words, if you're activating `a` and `b` below, `path` will contain the
3703
- * `ActivatedRouteSnapshot`s for both and we will fire `ChildActivationStart` for both. Always
3704
- * return
3705
- * `true` so checks continue to run.
3706
- */
3707
- function fireChildActivationStart(snapshot, forwardEvent) {
3708
- if (snapshot !== null && forwardEvent) {
3709
- forwardEvent(new ChildActivationStart(snapshot));
3710
- }
3711
- return of(true);
3712
- }
3713
- function runCanActivate(futureRSS, futureARS, moduleInjector) {
3714
- const canActivate = futureARS.routeConfig ? futureARS.routeConfig.canActivate : null;
3715
- if (!canActivate || canActivate.length === 0)
3716
- return of(true);
3717
- const canActivateObservables = canActivate.map((c) => {
3718
- return defer(() => {
3719
- const guard = getToken(c, futureARS, moduleInjector);
3720
- let observable;
3721
- if (isCanActivate(guard)) {
3722
- observable = wrapIntoObservable(guard.canActivate(futureARS, futureRSS));
3723
- }
3724
- else if (isFunction(guard)) {
3725
- observable = wrapIntoObservable(guard(futureARS, futureRSS));
3726
- }
3727
- else {
3728
- throw new Error('Invalid CanActivate guard');
3729
- }
3730
- return observable.pipe(first());
3731
- });
3732
- });
3733
- return of(canActivateObservables).pipe(prioritizedGuardValue());
3734
- }
3735
- function runCanActivateChild(futureRSS, path, moduleInjector) {
3736
- const futureARS = path[path.length - 1];
3737
- const canActivateChildGuards = path.slice(0, path.length - 1)
3738
- .reverse()
3739
- .map(p => getCanActivateChild(p))
3740
- .filter(_ => _ !== null);
3741
- const canActivateChildGuardsMapped = canActivateChildGuards.map((d) => {
3742
- return defer(() => {
3743
- const guardsMapped = d.guards.map((c) => {
3744
- const guard = getToken(c, d.node, moduleInjector);
3745
- let observable;
3746
- if (isCanActivateChild(guard)) {
3747
- observable = wrapIntoObservable(guard.canActivateChild(futureARS, futureRSS));
3748
- }
3749
- else if (isFunction(guard)) {
3750
- observable = wrapIntoObservable(guard(futureARS, futureRSS));
3751
- }
3752
- else {
3753
- throw new Error('Invalid CanActivateChild guard');
3754
- }
3755
- return observable.pipe(first());
3756
- });
3757
- return of(guardsMapped).pipe(prioritizedGuardValue());
3758
- });
3759
- });
3760
- return of(canActivateChildGuardsMapped).pipe(prioritizedGuardValue());
3761
- }
3762
- function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector) {
3763
- const canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
3764
- if (!canDeactivate || canDeactivate.length === 0)
3765
- return of(true);
3766
- const canDeactivateObservables = canDeactivate.map((c) => {
3767
- const guard = getToken(c, currARS, moduleInjector);
3768
- let observable;
3769
- if (isCanDeactivate(guard)) {
3770
- observable = wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
3771
- }
3772
- else if (isFunction(guard)) {
3773
- observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
3774
- }
3775
- else {
3776
- throw new Error('Invalid CanDeactivate guard');
3777
- }
3778
- return observable.pipe(first());
3779
- });
3780
- return of(canDeactivateObservables).pipe(prioritizedGuardValue());
3808
+ function applyRedirects(environmentInjector, configLoader, urlSerializer, config) {
3809
+ return switchMap(t => applyRedirects$1(environmentInjector, configLoader, urlSerializer, t.extractedUrl, config)
3810
+ .pipe(map(urlAfterRedirects => (Object.assign(Object.assign({}, t), { urlAfterRedirects })))));
3781
3811
  }
3782
3812
 
3783
3813
  /**
@@ -3794,46 +3824,45 @@ function newObservableError(e) {
3794
3824
  // TODO(atscott): This pattern is used throughout the router code and can be `throwError` instead.
3795
3825
  return new Observable((obs) => obs.error(e));
3796
3826
  }
3797
- function recognize$1(rootComponentType, config, urlTree, url, paramsInheritanceStrategy = 'emptyOnly', relativeLinkResolution = 'legacy') {
3798
- try {
3799
- const result = new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
3800
- .recognize();
3827
+ function recognize$1(injector, rootComponentType, config, urlTree, url, urlSerializer, paramsInheritanceStrategy = 'emptyOnly', relativeLinkResolution = 'legacy') {
3828
+ return new Recognizer(injector, rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution, urlSerializer)
3829
+ .recognize()
3830
+ .pipe(switchMap(result => {
3801
3831
  if (result === null) {
3802
3832
  return newObservableError(new NoMatch());
3803
3833
  }
3804
3834
  else {
3805
3835
  return of(result);
3806
3836
  }
3807
- }
3808
- catch (e) {
3809
- // Catch the potential error from recognize due to duplicate outlet matches and return as an
3810
- // `Observable` error instead.
3811
- return newObservableError(e);
3812
- }
3837
+ }));
3813
3838
  }
3814
3839
  class Recognizer {
3815
- constructor(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
3840
+ constructor(injector, rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution, urlSerializer) {
3841
+ this.injector = injector;
3816
3842
  this.rootComponentType = rootComponentType;
3817
3843
  this.config = config;
3818
3844
  this.urlTree = urlTree;
3819
3845
  this.url = url;
3820
3846
  this.paramsInheritanceStrategy = paramsInheritanceStrategy;
3821
3847
  this.relativeLinkResolution = relativeLinkResolution;
3848
+ this.urlSerializer = urlSerializer;
3822
3849
  }
3823
3850
  recognize() {
3824
3851
  const rootSegmentGroup = split(this.urlTree.root, [], [], this.config.filter(c => c.redirectTo === undefined), this.relativeLinkResolution)
3825
3852
  .segmentGroup;
3826
- const children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
3827
- if (children === null) {
3828
- return null;
3829
- }
3830
- // Use Object.freeze to prevent readers of the Router state from modifying it outside of a
3831
- // navigation, resulting in the router being out of sync with the browser.
3832
- const root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
3833
- const rootNode = new TreeNode(root, children);
3834
- const routeState = new RouterStateSnapshot(this.url, rootNode);
3835
- this.inheritParamsAndData(routeState._root);
3836
- return routeState;
3853
+ return this.processSegmentGroup(this.injector, this.config, rootSegmentGroup, PRIMARY_OUTLET)
3854
+ .pipe(map(children => {
3855
+ if (children === null) {
3856
+ return null;
3857
+ }
3858
+ // Use Object.freeze to prevent readers of the Router state from modifying it outside of a
3859
+ // navigation, resulting in the router being out of sync with the browser.
3860
+ const root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
3861
+ const rootNode = new TreeNode(root, children);
3862
+ const routeState = new RouterStateSnapshot(this.url, rootNode);
3863
+ this.inheritParamsAndData(routeState._root);
3864
+ return routeState;
3865
+ }));
3837
3866
  }
3838
3867
  inheritParamsAndData(routeNode) {
3839
3868
  const route = routeNode.value;
@@ -3842,11 +3871,11 @@ class Recognizer {
3842
3871
  route.data = Object.freeze(i.data);
3843
3872
  routeNode.children.forEach(n => this.inheritParamsAndData(n));
3844
3873
  }
3845
- processSegmentGroup(config, segmentGroup, outlet) {
3874
+ processSegmentGroup(injector, config, segmentGroup, outlet) {
3846
3875
  if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
3847
- return this.processChildren(config, segmentGroup);
3876
+ return this.processChildren(injector, config, segmentGroup);
3848
3877
  }
3849
- return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
3878
+ return this.processSegment(injector, config, segmentGroup, segmentGroup.segments, outlet);
3850
3879
  }
3851
3880
  /**
3852
3881
  * Matches every child outlet in the `segmentGroup` to a `Route` in the config. Returns `null` if
@@ -3856,103 +3885,130 @@ class Recognizer {
3856
3885
  * @param segmentGroup - The `UrlSegmentGroup` whose children need to be matched against the
3857
3886
  * config.
3858
3887
  */
3859
- processChildren(config, segmentGroup) {
3860
- const children = [];
3861
- for (const childOutlet of Object.keys(segmentGroup.children)) {
3888
+ processChildren(injector, config, segmentGroup) {
3889
+ return from(Object.keys(segmentGroup.children))
3890
+ .pipe(concatMap(childOutlet => {
3862
3891
  const child = segmentGroup.children[childOutlet];
3863
- // Sort the config so that routes with outlets that match the one being activated appear
3864
- // first, followed by routes for other outlets, which might match if they have an empty path.
3892
+ // Sort the config so that routes with outlets that match the one being activated
3893
+ // appear first, followed by routes for other outlets, which might match if they have
3894
+ // an empty path.
3865
3895
  const sortedConfig = sortByMatchingOutlets(config, childOutlet);
3866
- const outletChildren = this.processSegmentGroup(sortedConfig, child, childOutlet);
3867
- if (outletChildren === null) {
3868
- // Configs must match all segment children so because we did not find a match for this
3869
- // outlet, return `null`.
3896
+ return this.processSegmentGroup(injector, sortedConfig, child, childOutlet);
3897
+ }), scan((children, outletChildren) => {
3898
+ if (!children || !outletChildren)
3870
3899
  return null;
3871
- }
3872
3900
  children.push(...outletChildren);
3873
- }
3874
- // Because we may have matched two outlets to the same empty path segment, we can have multiple
3875
- // activated results for the same outlet. We should merge the children of these results so the
3876
- // final return value is only one `TreeNode` per outlet.
3877
- const mergedChildren = mergeEmptyPathMatches(children);
3878
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
3879
- // This should really never happen - we are only taking the first match for each outlet and
3880
- // merge the empty path matches.
3881
- checkOutletNameUniqueness(mergedChildren);
3882
- }
3883
- sortActivatedRouteSnapshots(mergedChildren);
3884
- return mergedChildren;
3885
- }
3886
- processSegment(config, segmentGroup, segments, outlet) {
3887
- for (const r of config) {
3888
- const children = this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
3889
- if (children !== null) {
3890
- return children;
3901
+ return children;
3902
+ }), takeWhile(children => children !== null), defaultIfEmpty(null), last$1(), map(children => {
3903
+ if (children === null)
3904
+ return null;
3905
+ // Because we may have matched two outlets to the same empty path segment, we can have
3906
+ // multiple activated results for the same outlet. We should merge the children of
3907
+ // these results so the final return value is only one `TreeNode` per outlet.
3908
+ const mergedChildren = mergeEmptyPathMatches(children);
3909
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
3910
+ // This should really never happen - we are only taking the first match for each
3911
+ // outlet and merge the empty path matches.
3912
+ checkOutletNameUniqueness(mergedChildren);
3891
3913
  }
3892
- }
3893
- if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
3894
- return [];
3895
- }
3896
- return null;
3914
+ sortActivatedRouteSnapshots(mergedChildren);
3915
+ return mergedChildren;
3916
+ }));
3917
+ }
3918
+ processSegment(injector, routes, segmentGroup, segments, outlet) {
3919
+ return from(routes).pipe(concatMap(r => {
3920
+ var _a;
3921
+ return this.processSegmentAgainstRoute((_a = r._injector) !== null && _a !== void 0 ? _a : injector, r, segmentGroup, segments, outlet);
3922
+ }), first((x) => !!x), catchError(e => {
3923
+ if (e instanceof EmptyError) {
3924
+ if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
3925
+ return of([]);
3926
+ }
3927
+ return of(null);
3928
+ }
3929
+ throw e;
3930
+ }));
3897
3931
  }
3898
- processSegmentAgainstRoute(route, rawSegment, segments, outlet) {
3899
- var _a, _b, _c, _d;
3932
+ processSegmentAgainstRoute(injector, route, rawSegment, segments, outlet) {
3933
+ var _a, _b;
3900
3934
  if (route.redirectTo || !isImmediateMatch(route, rawSegment, segments, outlet))
3901
- return null;
3902
- let snapshot;
3903
- let consumedSegments = [];
3904
- let remainingSegments = [];
3935
+ return of(null);
3936
+ let matchResult;
3905
3937
  if (route.path === '**') {
3906
3938
  const params = segments.length > 0 ? last(segments).parameters : {};
3907
3939
  const pathIndexShift = getPathIndexShift(rawSegment) + segments.length;
3908
- snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_b = (_a = route.component) !== null && _a !== void 0 ? _a : route._loadedComponent) !== null && _b !== void 0 ? _b : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route),
3940
+ const snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_b = (_a = route.component) !== null && _a !== void 0 ? _a : route._loadedComponent) !== null && _b !== void 0 ? _b : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route),
3909
3941
  // NG_DEV_MODE is used to prevent the getCorrectedPathIndexShift function from affecting
3910
3942
  // production bundle size. This value is intended only to surface a warning to users
3911
3943
  // depending on `relativeLinkResolution: 'legacy'` in dev mode.
3912
3944
  (NG_DEV_MODE$2 ? getCorrectedPathIndexShift(rawSegment) + segments.length :
3913
3945
  pathIndexShift));
3946
+ matchResult = of({
3947
+ snapshot,
3948
+ consumedSegments: [],
3949
+ remainingSegments: [],
3950
+ });
3914
3951
  }
3915
3952
  else {
3916
- const result = match(rawSegment, route, segments);
3917
- if (!result.matched) {
3918
- return null;
3919
- }
3920
- consumedSegments = result.consumedSegments;
3921
- remainingSegments = result.remainingSegments;
3922
- const pathIndexShift = getPathIndexShift(rawSegment) + consumedSegments.length;
3923
- snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_d = (_c = route.component) !== null && _c !== void 0 ? _c : route._loadedComponent) !== null && _d !== void 0 ? _d : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$2 ? getCorrectedPathIndexShift(rawSegment) + consumedSegments.length :
3924
- pathIndexShift));
3953
+ matchResult =
3954
+ matchWithChecks(rawSegment, route, segments, injector, this.urlSerializer)
3955
+ .pipe(map(({ matched, consumedSegments, remainingSegments, parameters }) => {
3956
+ var _a, _b;
3957
+ if (!matched) {
3958
+ return null;
3959
+ }
3960
+ const pathIndexShift = getPathIndexShift(rawSegment) + consumedSegments.length;
3961
+ const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_b = (_a = route.component) !== null && _a !== void 0 ? _a : route._loadedComponent) !== null && _b !== void 0 ? _b : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$2 ?
3962
+ getCorrectedPathIndexShift(rawSegment) + consumedSegments.length :
3963
+ pathIndexShift));
3964
+ return { snapshot, consumedSegments, remainingSegments };
3965
+ }));
3925
3966
  }
3926
- const childConfig = getChildConfig(route);
3927
- const { segmentGroup, slicedSegments } = split(rawSegment, consumedSegments, remainingSegments,
3928
- // Filter out routes with redirectTo because we are trying to create activated route
3929
- // snapshots and don't handle redirects here. That should have been done in
3930
- // `applyRedirects`.
3931
- childConfig.filter(c => c.redirectTo === undefined), this.relativeLinkResolution);
3932
- if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3933
- const children = this.processChildren(childConfig, segmentGroup);
3934
- if (children === null) {
3935
- return null;
3967
+ return matchResult.pipe(switchMap((result) => {
3968
+ var _a;
3969
+ if (result === null) {
3970
+ return of(null);
3936
3971
  }
3937
- return [new TreeNode(snapshot, children)];
3938
- }
3939
- if (childConfig.length === 0 && slicedSegments.length === 0) {
3940
- return [new TreeNode(snapshot, [])];
3941
- }
3942
- const matchedOnOutlet = getOutlet(route) === outlet;
3943
- // If we matched a config due to empty path match on a different outlet, we need to continue
3944
- // passing the current outlet for the segment rather than switch to PRIMARY.
3945
- // Note that we switch to primary when we have a match because outlet configs look like this:
3946
- // {path: 'a', outlet: 'a', children: [
3947
- // {path: 'b', component: B},
3948
- // {path: 'c', component: C},
3949
- // ]}
3950
- // Notice that the children of the named outlet are configured with the primary outlet
3951
- const children = this.processSegment(childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet);
3952
- if (children === null) {
3953
- return null;
3954
- }
3955
- return [new TreeNode(snapshot, children)];
3972
+ const { snapshot, consumedSegments, remainingSegments } = result;
3973
+ // Only create the Route's `EnvironmentInjector` if it matches the attempted
3974
+ // navigation
3975
+ injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3976
+ const childInjector = (_a = route._loadedInjector) !== null && _a !== void 0 ? _a : injector;
3977
+ const childConfig = getChildConfig(route);
3978
+ const { segmentGroup, slicedSegments } = split(rawSegment, consumedSegments, remainingSegments,
3979
+ // Filter out routes with redirectTo because we are trying to create activated route
3980
+ // snapshots and don't handle redirects here. That should have been done in
3981
+ // `applyRedirects`.
3982
+ childConfig.filter(c => c.redirectTo === undefined), this.relativeLinkResolution);
3983
+ if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3984
+ return this.processChildren(childInjector, childConfig, segmentGroup).pipe(map(children => {
3985
+ if (children === null) {
3986
+ return null;
3987
+ }
3988
+ return [new TreeNode(snapshot, children)];
3989
+ }));
3990
+ }
3991
+ if (childConfig.length === 0 && slicedSegments.length === 0) {
3992
+ return of([new TreeNode(snapshot, [])]);
3993
+ }
3994
+ const matchedOnOutlet = getOutlet(route) === outlet;
3995
+ // If we matched a config due to empty path match on a different outlet, we need to
3996
+ // continue passing the current outlet for the segment rather than switch to PRIMARY.
3997
+ // Note that we switch to primary when we have a match because outlet configs look like
3998
+ // this: {path: 'a', outlet: 'a', children: [
3999
+ // {path: 'b', component: B},
4000
+ // {path: 'c', component: C},
4001
+ // ]}
4002
+ // Notice that the children of the named outlet are configured with the primary outlet
4003
+ return this
4004
+ .processSegment(childInjector, childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet)
4005
+ .pipe(map(children => {
4006
+ if (children === null) {
4007
+ return null;
4008
+ }
4009
+ return [new TreeNode(snapshot, children)];
4010
+ }));
4011
+ }));
3956
4012
  }
3957
4013
  }
3958
4014
  function sortActivatedRouteSnapshots(nodes) {
@@ -3978,9 +4034,9 @@ function hasEmptyPathConfig(node) {
3978
4034
  return config && config.path === '' && config.redirectTo === undefined;
3979
4035
  }
3980
4036
  /**
3981
- * Finds `TreeNode`s with matching empty path route configs and merges them into `TreeNode` with the
3982
- * children from each duplicate. This is necessary because different outlets can match a single
3983
- * empty path route config and the results need to then be merged.
4037
+ * Finds `TreeNode`s with matching empty path route configs and merges them into `TreeNode` with
4038
+ * the children from each duplicate. This is necessary because different outlets can match a
4039
+ * single empty path route config and the results need to then be merged.
3984
4040
  */
3985
4041
  function mergeEmptyPathMatches(nodes) {
3986
4042
  const result = [];
@@ -4001,9 +4057,9 @@ function mergeEmptyPathMatches(nodes) {
4001
4057
  }
4002
4058
  }
4003
4059
  // For each node which has children from multiple sources, we need to recompute a new `TreeNode`
4004
- // by also merging those children. This is necessary when there are multiple empty path configs in
4005
- // a row. Put another way: whenever we combine children of two nodes, we need to also check if any
4006
- // of those children can be combined into a single node as well.
4060
+ // by also merging those children. This is necessary when there are multiple empty path configs
4061
+ // in a row. Put another way: whenever we combine children of two nodes, we need to also check
4062
+ // if any of those children can be combined into a single node as well.
4007
4063
  for (const mergedNode of mergedNodes) {
4008
4064
  const mergedChildren = mergeEmptyPathMatches(mergedNode.children);
4009
4065
  result.push(new TreeNode(mergedNode.value, mergedChildren));
@@ -4063,8 +4119,8 @@ function getResolve(route) {
4063
4119
  * Use of this source code is governed by an MIT-style license that can be
4064
4120
  * found in the LICENSE file at https://angular.io/license
4065
4121
  */
4066
- function recognize(rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
4067
- return mergeMap(t => recognize$1(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
4122
+ function recognize(injector, rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
4123
+ return mergeMap(t => recognize$1(injector, rootComponentType, config, t.urlAfterRedirects, serializer.serialize(t.urlAfterRedirects), serializer, paramsInheritanceStrategy, relativeLinkResolution)
4068
4124
  .pipe(map(targetSnapshot => (Object.assign(Object.assign({}, t), { targetSnapshot })))));
4069
4125
  }
4070
4126
 
@@ -4326,9 +4382,9 @@ class RouterConfigLoader {
4326
4382
  }));
4327
4383
  }
4328
4384
  }
4329
- RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4330
- RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterConfigLoader });
4331
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterConfigLoader, decorators: [{
4385
+ RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4386
+ RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader });
4387
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader, decorators: [{
4332
4388
  type: Injectable
4333
4389
  }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }]; } });
4334
4390
 
@@ -4370,12 +4426,6 @@ function defaultErrorHandler(error) {
4370
4426
  function defaultMalformedUriErrorHandler(error, urlSerializer, url) {
4371
4427
  return urlSerializer.parse('/');
4372
4428
  }
4373
- /**
4374
- * @internal
4375
- */
4376
- function defaultRouterHook(snapshot, runExtras) {
4377
- return of(null);
4378
- }
4379
4429
  /**
4380
4430
  * The equivalent `IsActiveMatchOptions` options for `Router.isActive` is called with `true`
4381
4431
  * (exact = true).
@@ -4455,13 +4505,12 @@ class Router {
4455
4505
  this.navigated = false;
4456
4506
  this.lastSuccessfulId = -1;
4457
4507
  /**
4458
- * Hooks that enable you to pause navigation,
4459
- * either before or after the preactivation phase.
4508
+ * Hook that enables you to pause navigation after the preactivation phase.
4460
4509
  * Used by `RouterModule`.
4461
4510
  *
4462
4511
  * @internal
4463
4512
  */
4464
- this.hooks = { beforePreactivation: defaultRouterHook, afterPreactivation: defaultRouterHook };
4513
+ this.afterPreactivation = () => of(void 0);
4465
4514
  /**
4466
4515
  * A strategy for extracting and merging URLs.
4467
4516
  * Used for AngularJS to Angular migrations.
@@ -4638,7 +4687,7 @@ class Router {
4638
4687
  this.currentNavigation = Object.assign(Object.assign({}, this.currentNavigation), { finalUrl: t.urlAfterRedirects });
4639
4688
  }),
4640
4689
  // Recognize
4641
- recognize(this.rootComponentType, this.config, (url) => this.serializeUrl(url), this.paramsInheritanceStrategy, this.relativeLinkResolution),
4690
+ recognize(this.ngModule.injector, this.rootComponentType, this.config, this.urlSerializer, this.paramsInheritanceStrategy, this.relativeLinkResolution),
4642
4691
  // Update URL if in `eager` update mode
4643
4692
  tap(t => {
4644
4693
  if (this.urlUpdateStrategy === 'eager') {
@@ -4678,17 +4727,6 @@ class Router {
4678
4727
  }
4679
4728
  }
4680
4729
  }),
4681
- // Before Preactivation
4682
- switchTap(t => {
4683
- const { targetSnapshot, id: navigationId, extractedUrl: appliedUrlTree, rawUrl: rawUrlTree, extras: { skipLocationChange, replaceUrl } } = t;
4684
- return this.hooks.beforePreactivation(targetSnapshot, {
4685
- navigationId,
4686
- appliedUrlTree,
4687
- rawUrlTree,
4688
- skipLocationChange: !!skipLocationChange,
4689
- replaceUrl: !!replaceUrl,
4690
- });
4691
- }),
4692
4730
  // --- GUARDS ---
4693
4731
  tap(t => {
4694
4732
  const guardsStart = new GuardsCheckStart(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
@@ -4732,18 +4770,7 @@ class Router {
4732
4770
  }));
4733
4771
  }
4734
4772
  return undefined;
4735
- }),
4736
- // --- AFTER PREACTIVATION ---
4737
- switchTap((t) => {
4738
- const { targetSnapshot, id: navigationId, extractedUrl: appliedUrlTree, rawUrl: rawUrlTree, extras: { skipLocationChange, replaceUrl } } = t;
4739
- return this.hooks.afterPreactivation(targetSnapshot, {
4740
- navigationId,
4741
- appliedUrlTree,
4742
- rawUrlTree,
4743
- skipLocationChange: !!skipLocationChange,
4744
- replaceUrl: !!replaceUrl,
4745
- });
4746
- }),
4773
+ }), switchTap(() => this.afterPreactivation()),
4747
4774
  // --- LOAD COMPONENTS ---
4748
4775
  switchTap((t) => {
4749
4776
  const loadComponents = (route) => {
@@ -5321,9 +5348,9 @@ class Router {
5321
5348
  return { navigationId };
5322
5349
  }
5323
5350
  }
5324
- Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5325
- Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: Router });
5326
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: Router, decorators: [{
5351
+ Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5352
+ Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router });
5353
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router, decorators: [{
5327
5354
  type: Injectable
5328
5355
  }], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
5329
5356
  function validateCommands(commands) {
@@ -5515,9 +5542,9 @@ class RouterLink {
5515
5542
  });
5516
5543
  }
5517
5544
  }
5518
- RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5519
- RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.0", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5520
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLink, decorators: [{
5545
+ RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5546
+ RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5547
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLink, decorators: [{
5521
5548
  type: Directive,
5522
5549
  args: [{ selector: ':not(a):not(area)[routerLink]' }]
5523
5550
  }], ctorParameters: function () {
@@ -5636,9 +5663,9 @@ class RouterLinkWithHref {
5636
5663
  });
5637
5664
  }
5638
5665
  }
5639
- RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5640
- RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.0", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5641
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5666
+ RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5667
+ RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5668
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5642
5669
  type: Directive,
5643
5670
  args: [{ selector: 'a[routerLink],area[routerLink]' }]
5644
5671
  }], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: i3.LocationStrategy }]; }, propDecorators: { target: [{
@@ -5865,9 +5892,9 @@ class RouterLinkActive {
5865
5892
  this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
5866
5893
  }
5867
5894
  }
5868
- RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
5869
- RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.0", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
5870
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterLinkActive, decorators: [{
5895
+ RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
5896
+ RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
5897
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkActive, decorators: [{
5871
5898
  type: Directive,
5872
5899
  args: [{
5873
5900
  selector: '[routerLinkActive]',
@@ -5973,9 +6000,9 @@ class DefaultTitleStrategy extends TitleStrategy {
5973
6000
  }
5974
6001
  }
5975
6002
  }
5976
- DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
5977
- DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
5978
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
6003
+ DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
6004
+ DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
6005
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
5979
6006
  type: Injectable,
5980
6007
  args: [{ providedIn: 'root' }]
5981
6008
  }], ctorParameters: function () { return [{ type: i1.Title }]; } });
@@ -6110,9 +6137,9 @@ class RouterPreloader {
6110
6137
  });
6111
6138
  }
6112
6139
  }
6113
- RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6114
- RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterPreloader });
6115
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterPreloader, decorators: [{
6140
+ RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6141
+ RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader });
6142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader, decorators: [{
6116
6143
  type: Injectable
6117
6144
  }], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.EnvironmentInjector }, { type: PreloadingStrategy }, { type: RouterConfigLoader }]; } });
6118
6145
 
@@ -6191,9 +6218,9 @@ class RouterScroller {
6191
6218
  }
6192
6219
  }
6193
6220
  }
6194
- RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6195
- RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterScroller });
6196
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterScroller, decorators: [{
6221
+ RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6222
+ RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller });
6223
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller, decorators: [{
6197
6224
  type: Injectable
6198
6225
  }], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: undefined }]; } });
6199
6226
 
@@ -6335,10 +6362,10 @@ class RouterModule {
6335
6362
  return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
6336
6363
  }
6337
6364
  }
6338
- RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6339
- RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6340
- RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterModule });
6341
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterModule, decorators: [{
6365
+ RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6366
+ RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6367
+ RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule });
6368
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, decorators: [{
6342
6369
  type: NgModule,
6343
6370
  args: [{
6344
6371
  declarations: ROUTER_DIRECTIVES,
@@ -6475,7 +6502,7 @@ class RouterInitializer {
6475
6502
  resolve(true);
6476
6503
  }
6477
6504
  else if (opts.initialNavigation === 'enabledBlocking') {
6478
- router.hooks.afterPreactivation = () => {
6505
+ router.afterPreactivation = () => {
6479
6506
  // only the initial navigation should be delayed
6480
6507
  if (!this.initNavigation) {
6481
6508
  this.initNavigation = true;
@@ -6484,7 +6511,7 @@ class RouterInitializer {
6484
6511
  // subsequent navigations should not be delayed
6485
6512
  }
6486
6513
  else {
6487
- return of(null);
6514
+ return of(void 0);
6488
6515
  }
6489
6516
  };
6490
6517
  router.initialNavigation();
@@ -6511,16 +6538,16 @@ class RouterInitializer {
6511
6538
  preloader.setUpPreloading();
6512
6539
  routerScroller.init();
6513
6540
  router.resetRootComponentType(ref.componentTypes[0]);
6514
- this.resultOfPreactivationDone.next(null);
6541
+ this.resultOfPreactivationDone.next(void 0);
6515
6542
  this.resultOfPreactivationDone.complete();
6516
6543
  }
6517
6544
  ngOnDestroy() {
6518
6545
  this.destroyed = true;
6519
6546
  }
6520
6547
  }
6521
- RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterInitializer, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
6522
- RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterInitializer });
6523
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.0", ngImport: i0, type: RouterInitializer, decorators: [{
6548
+ RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
6549
+ RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer });
6550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer, decorators: [{
6524
6551
  type: Injectable
6525
6552
  }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
6526
6553
  function getAppInitializer(r) {
@@ -6560,7 +6587,7 @@ function provideRouterInitializer() {
6560
6587
  /**
6561
6588
  * @publicApi
6562
6589
  */
6563
- const VERSION = new Version('14.1.0-next.0');
6590
+ const VERSION = new Version('14.1.0-next.1');
6564
6591
 
6565
6592
  /**
6566
6593
  * @license