@angular/router 11.0.5 → 11.0.9
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/bundles/router-testing.umd.js +1 -1
- package/bundles/router-testing.umd.min.js +1 -1
- package/bundles/router-testing.umd.min.js.map +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router-upgrade.umd.min.js +1 -1
- package/bundles/router-upgrade.umd.min.js.map +1 -1
- package/bundles/router.umd.js +514 -405
- package/bundles/router.umd.js.map +1 -1
- package/bundles/router.umd.min.js +19 -26
- package/bundles/router.umd.min.js.map +1 -1
- package/esm2015/src/apply_redirects.js +90 -117
- package/esm2015/src/directives/router_link_active.js +2 -4
- package/esm2015/src/operators/activate_routes.js +13 -11
- package/esm2015/src/operators/apply_redirects.js +3 -5
- package/esm2015/src/operators/check_guards.js +16 -26
- package/esm2015/src/operators/prioritized_guard_value.js +2 -2
- package/esm2015/src/operators/recognize.js +3 -5
- package/esm2015/src/operators/resolve_data.js +10 -12
- package/esm2015/src/operators/switch_tap.js +9 -11
- package/esm2015/src/recognize.js +126 -122
- package/esm2015/src/router.js +8 -12
- package/esm2015/src/router_module.js +1 -1
- package/esm2015/src/router_state.js +20 -2
- package/esm2015/src/url_tree.js +1 -1
- package/esm2015/src/utils/collection.js +1 -25
- package/esm2015/src/utils/config.js +10 -14
- package/esm2015/src/utils/config_matching.js +145 -0
- package/esm2015/src/version.js +1 -1
- package/fesm2015/router.js +437 -350
- package/fesm2015/router.js.map +1 -1
- package/fesm2015/testing.js +1 -1
- package/fesm2015/upgrade.js +1 -1
- package/package.json +4 -4
- package/router.d.ts +33 -4
- package/router.metadata.json +1 -1
- package/testing/testing.d.ts +1 -1
- package/testing.d.ts +1 -1
- package/upgrade/upgrade.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/bundles/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v11.0.
|
|
2
|
+
* @license Angular v11.0.9
|
|
3
3
|
* (c) 2010-2020 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -908,28 +908,6 @@
|
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
|
-
function waitForMap(obj, fn) {
|
|
912
|
-
if (Object.keys(obj).length === 0) {
|
|
913
|
-
return rxjs.of({});
|
|
914
|
-
}
|
|
915
|
-
var waitHead = [];
|
|
916
|
-
var waitTail = [];
|
|
917
|
-
var res = {};
|
|
918
|
-
forEach(obj, function (a, k) {
|
|
919
|
-
var mapped = fn(k, a).pipe(operators.map(function (r) { return res[k] = r; }));
|
|
920
|
-
if (k === PRIMARY_OUTLET) {
|
|
921
|
-
waitHead.push(mapped);
|
|
922
|
-
}
|
|
923
|
-
else {
|
|
924
|
-
waitTail.push(mapped);
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
// Closure compiler has problem with using spread operator here. So we use "Array.concat".
|
|
928
|
-
// Note that we also need to cast the new promise because TypeScript cannot infer the type
|
|
929
|
-
// when calling the "of" function through "Function.apply"
|
|
930
|
-
return rxjs.of.apply(null, waitHead.concat(waitTail))
|
|
931
|
-
.pipe(operators.concatAll(), operators.last(), operators.map(function () { return res; }));
|
|
932
|
-
}
|
|
933
911
|
function wrapIntoObservable(value) {
|
|
934
912
|
if (core.ɵisObservable(value)) {
|
|
935
913
|
return value;
|
|
@@ -1898,7 +1876,25 @@
|
|
|
1898
1876
|
function ActivatedRouteSnapshot(
|
|
1899
1877
|
/** The URL segments matched by this route */
|
|
1900
1878
|
url,
|
|
1901
|
-
/**
|
|
1879
|
+
/**
|
|
1880
|
+
* The matrix parameters scoped to this route.
|
|
1881
|
+
*
|
|
1882
|
+
* You can compute all params (or data) in the router state or to get params outside
|
|
1883
|
+
* of an activated component by traversing the `RouterState` tree as in the following
|
|
1884
|
+
* example:
|
|
1885
|
+
* ```
|
|
1886
|
+
* collectRouteParams(router: Router) {
|
|
1887
|
+
* let params = {};
|
|
1888
|
+
* let stack: ActivatedRouteSnapshot[] = [router.routerState.snapshot.root];
|
|
1889
|
+
* while (stack.length > 0) {
|
|
1890
|
+
* const route = stack.pop()!;
|
|
1891
|
+
* params = {...params, ...route.params};
|
|
1892
|
+
* stack.push(...route.children);
|
|
1893
|
+
* }
|
|
1894
|
+
* return params;
|
|
1895
|
+
* }
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1902
1898
|
params,
|
|
1903
1899
|
/** The query parameters shared by all the routes */
|
|
1904
1900
|
queryParams,
|
|
@@ -2432,13 +2428,6 @@
|
|
|
2432
2428
|
return path == segment.path && shallowEqual(params, segment.parameters);
|
|
2433
2429
|
}
|
|
2434
2430
|
|
|
2435
|
-
/**
|
|
2436
|
-
* @license
|
|
2437
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2438
|
-
*
|
|
2439
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2440
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2441
|
-
*/
|
|
2442
2431
|
var activateRoutes = function (rootContexts, routeReuseStrategy, forwardEvent) { return operators.map(function (t) {
|
|
2443
2432
|
new ActivateRoutes(routeReuseStrategy, t.targetRouterState, t.currentRouterState, forwardEvent)
|
|
2444
2433
|
.activate(rootContexts);
|
|
@@ -2514,19 +2503,31 @@
|
|
|
2514
2503
|
}
|
|
2515
2504
|
};
|
|
2516
2505
|
ActivateRoutes.prototype.deactivateRouteAndOutlet = function (route, parentContexts) {
|
|
2517
|
-
var
|
|
2506
|
+
var e_1, _a;
|
|
2518
2507
|
var context = parentContexts.getContext(route.value.outlet);
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
context.children.onOutletDeactivated();
|
|
2508
|
+
// The context could be `null` if we are on a componentless route but there may still be
|
|
2509
|
+
// children that need deactivating.
|
|
2510
|
+
var contexts = context && route.value.component ? context.children : parentContexts;
|
|
2511
|
+
var children = nodeChildrenAsMap(route);
|
|
2512
|
+
try {
|
|
2513
|
+
for (var _b = __values(Object.keys(children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2514
|
+
var childOutlet = _c.value;
|
|
2515
|
+
this.deactivateRouteAndItsChildren(children[childOutlet], contexts);
|
|
2528
2516
|
}
|
|
2529
2517
|
}
|
|
2518
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2519
|
+
finally {
|
|
2520
|
+
try {
|
|
2521
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2522
|
+
}
|
|
2523
|
+
finally { if (e_1) throw e_1.error; }
|
|
2524
|
+
}
|
|
2525
|
+
if (context && context.outlet) {
|
|
2526
|
+
// Destroy the component
|
|
2527
|
+
context.outlet.deactivate();
|
|
2528
|
+
// Destroy the contexts for all the outlets that were in the component
|
|
2529
|
+
context.children.onOutletDeactivated();
|
|
2530
|
+
}
|
|
2530
2531
|
};
|
|
2531
2532
|
ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, contexts) {
|
|
2532
2533
|
var _this = this;
|
|
@@ -2666,10 +2667,18 @@
|
|
|
2666
2667
|
return guard && isFunction(guard.canDeactivate);
|
|
2667
2668
|
}
|
|
2668
2669
|
|
|
2670
|
+
/**
|
|
2671
|
+
* @license
|
|
2672
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2673
|
+
*
|
|
2674
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2675
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2676
|
+
*/
|
|
2669
2677
|
var INITIAL_VALUE = Symbol('INITIAL_VALUE');
|
|
2670
2678
|
function prioritizedGuardValue() {
|
|
2671
2679
|
return operators.switchMap(function (obs) {
|
|
2672
|
-
return rxjs.combineLatest
|
|
2680
|
+
return rxjs.combineLatest(obs.map(function (o) { return o.pipe(operators.take(1), operators.startWith(INITIAL_VALUE)); }))
|
|
2681
|
+
.pipe(operators.scan(function (acc, list) {
|
|
2673
2682
|
var isPending = false;
|
|
2674
2683
|
return list.reduce(function (innerAcc, val, i) {
|
|
2675
2684
|
if (innerAcc !== INITIAL_VALUE)
|
|
@@ -2722,13 +2731,6 @@
|
|
|
2722
2731
|
{ type: core.Component, args: [{ template: "<router-outlet></router-outlet>" },] }
|
|
2723
2732
|
];
|
|
2724
2733
|
|
|
2725
|
-
/**
|
|
2726
|
-
* @license
|
|
2727
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2728
|
-
*
|
|
2729
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2730
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2731
|
-
*/
|
|
2732
2734
|
function validateConfig(config, parentPath) {
|
|
2733
2735
|
if (parentPath === void 0) { parentPath = ''; }
|
|
2734
2736
|
// forEach doesn't iterate undefined values
|
|
@@ -2814,23 +2816,176 @@
|
|
|
2814
2816
|
}
|
|
2815
2817
|
return c;
|
|
2816
2818
|
}
|
|
2817
|
-
/** Returns of `Map` of outlet names to the `Route`s for that outlet. */
|
|
2818
|
-
function groupRoutesByOutlet(routes) {
|
|
2819
|
-
return routes.reduce(function (map, route) {
|
|
2820
|
-
var routeOutlet = getOutlet(route);
|
|
2821
|
-
if (map.has(routeOutlet)) {
|
|
2822
|
-
map.get(routeOutlet).push(route);
|
|
2823
|
-
}
|
|
2824
|
-
else {
|
|
2825
|
-
map.set(routeOutlet, [route]);
|
|
2826
|
-
}
|
|
2827
|
-
return map;
|
|
2828
|
-
}, new Map());
|
|
2829
|
-
}
|
|
2830
2819
|
/** Returns the `route.outlet` or PRIMARY_OUTLET if none exists. */
|
|
2831
2820
|
function getOutlet(route) {
|
|
2832
2821
|
return route.outlet || PRIMARY_OUTLET;
|
|
2833
2822
|
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Sorts the `routes` such that the ones with an outlet matching `outletName` come first.
|
|
2825
|
+
* The order of the configs is otherwise preserved.
|
|
2826
|
+
*/
|
|
2827
|
+
function sortByMatchingOutlets(routes, outletName) {
|
|
2828
|
+
var sortedConfig = routes.filter(function (r) { return getOutlet(r) === outletName; });
|
|
2829
|
+
sortedConfig.push.apply(sortedConfig, __spread(routes.filter(function (r) { return getOutlet(r) !== outletName; })));
|
|
2830
|
+
return sortedConfig;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
var noMatch = {
|
|
2834
|
+
matched: false,
|
|
2835
|
+
consumedSegments: [],
|
|
2836
|
+
lastChild: 0,
|
|
2837
|
+
parameters: {},
|
|
2838
|
+
positionalParamSegments: {}
|
|
2839
|
+
};
|
|
2840
|
+
function match(segmentGroup, route, segments) {
|
|
2841
|
+
var _a;
|
|
2842
|
+
if (route.path === '') {
|
|
2843
|
+
if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
|
|
2844
|
+
return Object.assign({}, noMatch);
|
|
2845
|
+
}
|
|
2846
|
+
return {
|
|
2847
|
+
matched: true,
|
|
2848
|
+
consumedSegments: [],
|
|
2849
|
+
lastChild: 0,
|
|
2850
|
+
parameters: {},
|
|
2851
|
+
positionalParamSegments: {}
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
var matcher = route.matcher || defaultUrlMatcher;
|
|
2855
|
+
var res = matcher(segments, segmentGroup, route);
|
|
2856
|
+
if (!res)
|
|
2857
|
+
return Object.assign({}, noMatch);
|
|
2858
|
+
var posParams = {};
|
|
2859
|
+
forEach(res.posParams, function (v, k) {
|
|
2860
|
+
posParams[k] = v.path;
|
|
2861
|
+
});
|
|
2862
|
+
var parameters = res.consumed.length > 0 ? Object.assign(Object.assign({}, posParams), res.consumed[res.consumed.length - 1].parameters) :
|
|
2863
|
+
posParams;
|
|
2864
|
+
return {
|
|
2865
|
+
matched: true,
|
|
2866
|
+
consumedSegments: res.consumed,
|
|
2867
|
+
lastChild: res.consumed.length,
|
|
2868
|
+
// TODO(atscott): investigate combining parameters and positionalParamSegments
|
|
2869
|
+
parameters: parameters,
|
|
2870
|
+
positionalParamSegments: (_a = res.posParams) !== null && _a !== void 0 ? _a : {}
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
function split(segmentGroup, consumedSegments, slicedSegments, config, relativeLinkResolution) {
|
|
2874
|
+
if (relativeLinkResolution === void 0) { relativeLinkResolution = 'corrected'; }
|
|
2875
|
+
if (slicedSegments.length > 0 &&
|
|
2876
|
+
containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
|
2877
|
+
var s_1 = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
|
2878
|
+
s_1._sourceSegment = segmentGroup;
|
|
2879
|
+
s_1._segmentIndexShift = consumedSegments.length;
|
|
2880
|
+
return { segmentGroup: s_1, slicedSegments: [] };
|
|
2881
|
+
}
|
|
2882
|
+
if (slicedSegments.length === 0 &&
|
|
2883
|
+
containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
|
|
2884
|
+
var s_2 = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, config, segmentGroup.children, relativeLinkResolution));
|
|
2885
|
+
s_2._sourceSegment = segmentGroup;
|
|
2886
|
+
s_2._segmentIndexShift = consumedSegments.length;
|
|
2887
|
+
return { segmentGroup: s_2, slicedSegments: slicedSegments };
|
|
2888
|
+
}
|
|
2889
|
+
var s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
|
|
2890
|
+
s._sourceSegment = segmentGroup;
|
|
2891
|
+
s._segmentIndexShift = consumedSegments.length;
|
|
2892
|
+
return { segmentGroup: s, slicedSegments: slicedSegments };
|
|
2893
|
+
}
|
|
2894
|
+
function addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, routes, children, relativeLinkResolution) {
|
|
2895
|
+
var e_1, _b;
|
|
2896
|
+
var res = {};
|
|
2897
|
+
try {
|
|
2898
|
+
for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
|
|
2899
|
+
var r = routes_1_1.value;
|
|
2900
|
+
if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
|
|
2901
|
+
var s = new UrlSegmentGroup([], {});
|
|
2902
|
+
s._sourceSegment = segmentGroup;
|
|
2903
|
+
if (relativeLinkResolution === 'legacy') {
|
|
2904
|
+
s._segmentIndexShift = segmentGroup.segments.length;
|
|
2905
|
+
}
|
|
2906
|
+
else {
|
|
2907
|
+
s._segmentIndexShift = consumedSegments.length;
|
|
2908
|
+
}
|
|
2909
|
+
res[getOutlet(r)] = s;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2914
|
+
finally {
|
|
2915
|
+
try {
|
|
2916
|
+
if (routes_1_1 && !routes_1_1.done && (_b = routes_1.return)) _b.call(routes_1);
|
|
2917
|
+
}
|
|
2918
|
+
finally { if (e_1) throw e_1.error; }
|
|
2919
|
+
}
|
|
2920
|
+
return Object.assign(Object.assign({}, children), res);
|
|
2921
|
+
}
|
|
2922
|
+
function createChildrenForEmptyPaths(segmentGroup, consumedSegments, routes, primarySegment) {
|
|
2923
|
+
var e_2, _b;
|
|
2924
|
+
var res = {};
|
|
2925
|
+
res[PRIMARY_OUTLET] = primarySegment;
|
|
2926
|
+
primarySegment._sourceSegment = segmentGroup;
|
|
2927
|
+
primarySegment._segmentIndexShift = consumedSegments.length;
|
|
2928
|
+
try {
|
|
2929
|
+
for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
|
|
2930
|
+
var r = routes_2_1.value;
|
|
2931
|
+
if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
|
|
2932
|
+
var s = new UrlSegmentGroup([], {});
|
|
2933
|
+
s._sourceSegment = segmentGroup;
|
|
2934
|
+
s._segmentIndexShift = consumedSegments.length;
|
|
2935
|
+
res[getOutlet(r)] = s;
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2940
|
+
finally {
|
|
2941
|
+
try {
|
|
2942
|
+
if (routes_2_1 && !routes_2_1.done && (_b = routes_2.return)) _b.call(routes_2);
|
|
2943
|
+
}
|
|
2944
|
+
finally { if (e_2) throw e_2.error; }
|
|
2945
|
+
}
|
|
2946
|
+
return res;
|
|
2947
|
+
}
|
|
2948
|
+
function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
|
|
2949
|
+
return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
|
|
2950
|
+
}
|
|
2951
|
+
function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
|
|
2952
|
+
return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r); });
|
|
2953
|
+
}
|
|
2954
|
+
function emptyPathMatch(segmentGroup, slicedSegments, r) {
|
|
2955
|
+
if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
|
|
2956
|
+
return false;
|
|
2957
|
+
}
|
|
2958
|
+
return r.path === '';
|
|
2959
|
+
}
|
|
2960
|
+
/**
|
|
2961
|
+
* Determines if `route` is a path match for the `rawSegment`, `segments`, and `outlet` without
|
|
2962
|
+
* verifying that its children are a full match for the remainder of the `rawSegment` children as
|
|
2963
|
+
* well.
|
|
2964
|
+
*/
|
|
2965
|
+
function isImmediateMatch(route, rawSegment, segments, outlet) {
|
|
2966
|
+
// We allow matches to empty paths when the outlets differ so we can match a url like `/(b:b)` to
|
|
2967
|
+
// a config like
|
|
2968
|
+
// * `{path: '', children: [{path: 'b', outlet: 'b'}]}`
|
|
2969
|
+
// or even
|
|
2970
|
+
// * `{path: '', outlet: 'a', children: [{path: 'b', outlet: 'b'}]`
|
|
2971
|
+
//
|
|
2972
|
+
// The exception here is when the segment outlet is for the primary outlet. This would
|
|
2973
|
+
// result in a match inside the named outlet because all children there are written as primary
|
|
2974
|
+
// outlets. So we need to prevent child named outlet matches in a url like `/b` in a config like
|
|
2975
|
+
// * `{path: '', outlet: 'x' children: [{path: 'b'}]}`
|
|
2976
|
+
// This should only match if the url is `/(x:b)`.
|
|
2977
|
+
if (getOutlet(route) !== outlet &&
|
|
2978
|
+
(outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) {
|
|
2979
|
+
return false;
|
|
2980
|
+
}
|
|
2981
|
+
if (route.path === '**') {
|
|
2982
|
+
return true;
|
|
2983
|
+
}
|
|
2984
|
+
return match(rawSegment, route, segments).matched;
|
|
2985
|
+
}
|
|
2986
|
+
function noLeftoversInUrl(segmentGroup, segments, outlet) {
|
|
2987
|
+
return segments.length === 0 && !segmentGroup.children[outlet];
|
|
2988
|
+
}
|
|
2834
2989
|
|
|
2835
2990
|
var NoMatch = /** @class */ (function () {
|
|
2836
2991
|
function NoMatch(segmentGroup) {
|
|
@@ -2844,7 +2999,7 @@
|
|
|
2844
2999
|
}
|
|
2845
3000
|
return AbsoluteRedirect;
|
|
2846
3001
|
}());
|
|
2847
|
-
function noMatch(segmentGroup) {
|
|
3002
|
+
function noMatch$1(segmentGroup) {
|
|
2848
3003
|
return new rxjs.Observable(function (obs) { return obs.error(new NoMatch(segmentGroup)); });
|
|
2849
3004
|
}
|
|
2850
3005
|
function absoluteRedirect(newTree) {
|
|
@@ -2875,8 +3030,18 @@
|
|
|
2875
3030
|
}
|
|
2876
3031
|
ApplyRedirects.prototype.apply = function () {
|
|
2877
3032
|
var _this = this;
|
|
2878
|
-
var
|
|
2879
|
-
|
|
3033
|
+
var splitGroup = split(this.urlTree.root, [], [], this.config).segmentGroup;
|
|
3034
|
+
// TODO(atscott): creating a new segment removes the _sourceSegment _segmentIndexShift, which is
|
|
3035
|
+
// only necessary to prevent failures in tests which assert exact object matches. The `split` is
|
|
3036
|
+
// now shared between `applyRedirects` and `recognize` but only the `recognize` step needs these
|
|
3037
|
+
// properties. Before the implementations were merged, the `applyRedirects` would not assign
|
|
3038
|
+
// them. We should be able to remove this logic as a "breaking change" but should do some more
|
|
3039
|
+
// investigation into the failures first.
|
|
3040
|
+
var rootSegmentGroup = new UrlSegmentGroup(splitGroup.segments, splitGroup.children);
|
|
3041
|
+
var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, rootSegmentGroup, PRIMARY_OUTLET);
|
|
3042
|
+
var urlTrees$ = expanded$.pipe(operators.map(function (rootSegmentGroup) {
|
|
3043
|
+
return _this.createUrlTree(squashSegmentGroup(rootSegmentGroup), _this.urlTree.queryParams, _this.urlTree.fragment);
|
|
3044
|
+
}));
|
|
2880
3045
|
return urlTrees$.pipe(operators.catchError(function (e) {
|
|
2881
3046
|
if (e instanceof AbsoluteRedirect) {
|
|
2882
3047
|
// after an absolute redirect we do not apply any more redirects!
|
|
@@ -2893,7 +3058,9 @@
|
|
|
2893
3058
|
ApplyRedirects.prototype.match = function (tree) {
|
|
2894
3059
|
var _this = this;
|
|
2895
3060
|
var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, tree.root, PRIMARY_OUTLET);
|
|
2896
|
-
var mapped$ = expanded$.pipe(operators.map(function (rootSegmentGroup) {
|
|
3061
|
+
var mapped$ = expanded$.pipe(operators.map(function (rootSegmentGroup) {
|
|
3062
|
+
return _this.createUrlTree(squashSegmentGroup(rootSegmentGroup), tree.queryParams, tree.fragment);
|
|
3063
|
+
}));
|
|
2897
3064
|
return mapped$.pipe(operators.catchError(function (e) {
|
|
2898
3065
|
if (e instanceof NoMatch) {
|
|
2899
3066
|
throw _this.noMatchError(e);
|
|
@@ -2920,65 +3087,74 @@
|
|
|
2920
3087
|
};
|
|
2921
3088
|
// Recursively expand segment groups for all the child outlets
|
|
2922
3089
|
ApplyRedirects.prototype.expandChildren = function (ngModule, routes, segmentGroup) {
|
|
3090
|
+
var e_1, _a;
|
|
2923
3091
|
var _this = this;
|
|
2924
|
-
|
|
3092
|
+
// Expand outlets one at a time, starting with the primary outlet. We need to do it this way
|
|
3093
|
+
// because an absolute redirect from the primary outlet takes precedence.
|
|
3094
|
+
var childOutlets = [];
|
|
3095
|
+
try {
|
|
3096
|
+
for (var _b = __values(Object.keys(segmentGroup.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3097
|
+
var child = _c.value;
|
|
3098
|
+
if (child === 'primary') {
|
|
3099
|
+
childOutlets.unshift(child);
|
|
3100
|
+
}
|
|
3101
|
+
else {
|
|
3102
|
+
childOutlets.push(child);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3107
|
+
finally {
|
|
3108
|
+
try {
|
|
3109
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3110
|
+
}
|
|
3111
|
+
finally { if (e_1) throw e_1.error; }
|
|
3112
|
+
}
|
|
3113
|
+
return rxjs.from(childOutlets)
|
|
3114
|
+
.pipe(operators.concatMap(function (childOutlet) {
|
|
3115
|
+
var child = segmentGroup.children[childOutlet];
|
|
3116
|
+
// Sort the routes so routes with outlets that match the the segment appear
|
|
3117
|
+
// first, followed by routes for other outlets, which might match if they have an
|
|
3118
|
+
// empty path.
|
|
3119
|
+
var sortedRoutes = sortByMatchingOutlets(routes, childOutlet);
|
|
3120
|
+
return _this.expandSegmentGroup(ngModule, sortedRoutes, child, childOutlet)
|
|
3121
|
+
.pipe(operators.map(function (s) { return ({ segment: s, outlet: childOutlet }); }));
|
|
3122
|
+
}), operators.scan(function (children, expandedChild) {
|
|
3123
|
+
children[expandedChild.outlet] = expandedChild.segment;
|
|
3124
|
+
return children;
|
|
3125
|
+
}, {}), operators.last());
|
|
2925
3126
|
};
|
|
2926
3127
|
ApplyRedirects.prototype.expandSegment = function (ngModule, segmentGroup, routes, segments, outlet, allowRedirects) {
|
|
2927
3128
|
var _this = this;
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
routesByOutlet.set(outlet, []);
|
|
2934
|
-
}
|
|
2935
|
-
var expandRoutes = function (routes) {
|
|
2936
|
-
return rxjs.from(routes).pipe(operators.concatMap(function (r) {
|
|
2937
|
-
var expanded$ = _this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
|
|
2938
|
-
return expanded$.pipe(operators.catchError(function (e) {
|
|
2939
|
-
if (e instanceof NoMatch) {
|
|
2940
|
-
return rxjs.of(null);
|
|
2941
|
-
}
|
|
2942
|
-
throw e;
|
|
2943
|
-
}));
|
|
2944
|
-
}), operators.first(function (s) { return s !== null; }), operators.catchError(function (e) {
|
|
2945
|
-
if (e instanceof rxjs.EmptyError || e.name === 'EmptyError') {
|
|
2946
|
-
if (_this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
2947
|
-
return rxjs.of(new UrlSegmentGroup([], {}));
|
|
2948
|
-
}
|
|
2949
|
-
throw new NoMatch(segmentGroup);
|
|
3129
|
+
return rxjs.from(routes).pipe(operators.concatMap(function (r) {
|
|
3130
|
+
var expanded$ = _this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
|
|
3131
|
+
return expanded$.pipe(operators.catchError(function (e) {
|
|
3132
|
+
if (e instanceof NoMatch) {
|
|
3133
|
+
return rxjs.of(null);
|
|
2950
3134
|
}
|
|
2951
3135
|
throw e;
|
|
2952
3136
|
}));
|
|
2953
|
-
};
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
.pipe(operators.combineAll(), operators.first(),
|
|
2963
|
-
// Return only the expansion for the route outlet we are trying to activate.
|
|
2964
|
-
operators.map(function (results) { return results.find(function (result) { return result !== null; }); }));
|
|
2965
|
-
};
|
|
2966
|
-
ApplyRedirects.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
|
|
2967
|
-
return segments.length === 0 && !segmentGroup.children[outlet];
|
|
3137
|
+
}), operators.first(function (s) { return !!s; }), operators.catchError(function (e, _) {
|
|
3138
|
+
if (e instanceof rxjs.EmptyError || e.name === 'EmptyError') {
|
|
3139
|
+
if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
3140
|
+
return rxjs.of(new UrlSegmentGroup([], {}));
|
|
3141
|
+
}
|
|
3142
|
+
throw new NoMatch(segmentGroup);
|
|
3143
|
+
}
|
|
3144
|
+
throw e;
|
|
3145
|
+
}));
|
|
2968
3146
|
};
|
|
2969
3147
|
ApplyRedirects.prototype.expandSegmentAgainstRoute = function (ngModule, segmentGroup, routes, route, paths, outlet, allowRedirects) {
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
if (getOutlet(route) !== outlet && route.path !== '') {
|
|
2973
|
-
return noMatch(segmentGroup);
|
|
3148
|
+
if (!isImmediateMatch(route, segmentGroup, paths, outlet)) {
|
|
3149
|
+
return noMatch$1(segmentGroup);
|
|
2974
3150
|
}
|
|
2975
3151
|
if (route.redirectTo === undefined) {
|
|
2976
|
-
return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths);
|
|
3152
|
+
return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths, outlet);
|
|
2977
3153
|
}
|
|
2978
3154
|
if (allowRedirects && this.allowRedirects) {
|
|
2979
3155
|
return this.expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, paths, outlet);
|
|
2980
3156
|
}
|
|
2981
|
-
return noMatch(segmentGroup);
|
|
3157
|
+
return noMatch$1(segmentGroup);
|
|
2982
3158
|
};
|
|
2983
3159
|
ApplyRedirects.prototype.expandSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
|
|
2984
3160
|
if (route.path === '**') {
|
|
@@ -3001,7 +3177,7 @@
|
|
|
3001
3177
|
var _this = this;
|
|
3002
3178
|
var _a = match(segmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild, positionalParamSegments = _a.positionalParamSegments;
|
|
3003
3179
|
if (!matched)
|
|
3004
|
-
return noMatch(segmentGroup);
|
|
3180
|
+
return noMatch$1(segmentGroup);
|
|
3005
3181
|
var newTree = this.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments);
|
|
3006
3182
|
if (route.redirectTo.startsWith('/')) {
|
|
3007
3183
|
return absoluteRedirect(newTree);
|
|
@@ -3010,7 +3186,7 @@
|
|
|
3010
3186
|
return _this.expandSegment(ngModule, segmentGroup, routes, newSegments.concat(segments.slice(lastChild)), outlet, false);
|
|
3011
3187
|
}));
|
|
3012
3188
|
};
|
|
3013
|
-
ApplyRedirects.prototype.matchSegmentAgainstRoute = function (ngModule, rawSegmentGroup, route, segments) {
|
|
3189
|
+
ApplyRedirects.prototype.matchSegmentAgainstRoute = function (ngModule, rawSegmentGroup, route, segments, outlet) {
|
|
3014
3190
|
var _this = this;
|
|
3015
3191
|
if (route.path === '**') {
|
|
3016
3192
|
if (route.loadChildren) {
|
|
@@ -3024,13 +3200,15 @@
|
|
|
3024
3200
|
}
|
|
3025
3201
|
var _a = match(rawSegmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild;
|
|
3026
3202
|
if (!matched)
|
|
3027
|
-
return noMatch(rawSegmentGroup);
|
|
3203
|
+
return noMatch$1(rawSegmentGroup);
|
|
3028
3204
|
var rawSlicedSegments = segments.slice(lastChild);
|
|
3029
3205
|
var childConfig$ = this.getChildConfig(ngModule, route, segments);
|
|
3030
3206
|
return childConfig$.pipe(operators.mergeMap(function (routerConfig) {
|
|
3031
3207
|
var childModule = routerConfig.module;
|
|
3032
3208
|
var childConfig = routerConfig.routes;
|
|
3033
|
-
var _a = split(rawSegmentGroup, consumedSegments, rawSlicedSegments, childConfig),
|
|
3209
|
+
var _a = split(rawSegmentGroup, consumedSegments, rawSlicedSegments, childConfig), splitSegmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
|
|
3210
|
+
// See comment on the other call to `split` about why this is necessary.
|
|
3211
|
+
var segmentGroup = new UrlSegmentGroup(splitSegmentGroup.segments, splitSegmentGroup.children);
|
|
3034
3212
|
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
|
3035
3213
|
var expanded$_1 = _this.expandChildren(childModule, childConfig, segmentGroup);
|
|
3036
3214
|
return expanded$_1.pipe(operators.map(function (children) { return new UrlSegmentGroup(consumedSegments, children); }));
|
|
@@ -3038,7 +3216,8 @@
|
|
|
3038
3216
|
if (childConfig.length === 0 && slicedSegments.length === 0) {
|
|
3039
3217
|
return rxjs.of(new UrlSegmentGroup(consumedSegments, {}));
|
|
3040
3218
|
}
|
|
3041
|
-
var
|
|
3219
|
+
var matchedOnOutlet = getOutlet(route) === outlet;
|
|
3220
|
+
var expanded$ = _this.expandSegment(childModule, segmentGroup, childConfig, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true);
|
|
3042
3221
|
return expanded$.pipe(operators.map(function (cs) { return new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children); }));
|
|
3043
3222
|
}));
|
|
3044
3223
|
};
|
|
@@ -3151,7 +3330,7 @@
|
|
|
3151
3330
|
return pos;
|
|
3152
3331
|
};
|
|
3153
3332
|
ApplyRedirects.prototype.findOrReturn = function (redirectToUrlSegment, actualSegments) {
|
|
3154
|
-
var
|
|
3333
|
+
var e_2, _a;
|
|
3155
3334
|
var idx = 0;
|
|
3156
3335
|
try {
|
|
3157
3336
|
for (var actualSegments_1 = __values(actualSegments), actualSegments_1_1 = actualSegments_1.next(); !actualSegments_1_1.done; actualSegments_1_1 = actualSegments_1.next()) {
|
|
@@ -3163,54 +3342,25 @@
|
|
|
3163
3342
|
idx++;
|
|
3164
3343
|
}
|
|
3165
3344
|
}
|
|
3166
|
-
catch (
|
|
3345
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3167
3346
|
finally {
|
|
3168
3347
|
try {
|
|
3169
3348
|
if (actualSegments_1_1 && !actualSegments_1_1.done && (_a = actualSegments_1.return)) _a.call(actualSegments_1);
|
|
3170
3349
|
}
|
|
3171
|
-
finally { if (
|
|
3350
|
+
finally { if (e_2) throw e_2.error; }
|
|
3172
3351
|
}
|
|
3173
3352
|
return redirectToUrlSegment;
|
|
3174
3353
|
};
|
|
3175
3354
|
return ApplyRedirects;
|
|
3176
3355
|
}());
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
var res = matcher(segments, segmentGroup, route);
|
|
3186
|
-
if (!res) {
|
|
3187
|
-
return {
|
|
3188
|
-
matched: false,
|
|
3189
|
-
consumedSegments: [],
|
|
3190
|
-
lastChild: 0,
|
|
3191
|
-
positionalParamSegments: {},
|
|
3192
|
-
};
|
|
3193
|
-
}
|
|
3194
|
-
return {
|
|
3195
|
-
matched: true,
|
|
3196
|
-
consumedSegments: res.consumed,
|
|
3197
|
-
lastChild: res.consumed.length,
|
|
3198
|
-
positionalParamSegments: res.posParams,
|
|
3199
|
-
};
|
|
3200
|
-
}
|
|
3201
|
-
function split(segmentGroup, consumedSegments, slicedSegments, config) {
|
|
3202
|
-
if (slicedSegments.length > 0 &&
|
|
3203
|
-
containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
|
3204
|
-
var s = new UrlSegmentGroup(consumedSegments, createChildrenForEmptySegments(config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
|
3205
|
-
return { segmentGroup: mergeTrivialChildren(s), slicedSegments: [] };
|
|
3206
|
-
}
|
|
3207
|
-
if (slicedSegments.length === 0 &&
|
|
3208
|
-
containsEmptyPathRedirects(segmentGroup, slicedSegments, config)) {
|
|
3209
|
-
var s = new UrlSegmentGroup(segmentGroup.segments, addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
|
|
3210
|
-
return { segmentGroup: mergeTrivialChildren(s), slicedSegments: slicedSegments };
|
|
3211
|
-
}
|
|
3212
|
-
return { segmentGroup: segmentGroup, slicedSegments: slicedSegments };
|
|
3213
|
-
}
|
|
3356
|
+
/**
|
|
3357
|
+
* When possible, merges the primary outlet child into the parent `UrlSegmentGroup`.
|
|
3358
|
+
*
|
|
3359
|
+
* When a segment group has only one child which is a primary outlet, merges that child into the
|
|
3360
|
+
* parent. That is, the child segment group's segments are merged into the `s` and the child's
|
|
3361
|
+
* children become the children of `s`. Think of this like a 'squash', merging the child segment
|
|
3362
|
+
* group into the parent.
|
|
3363
|
+
*/
|
|
3214
3364
|
function mergeTrivialChildren(s) {
|
|
3215
3365
|
if (s.numberOfChildren === 1 && s.children[PRIMARY_OUTLET]) {
|
|
3216
3366
|
var c = s.children[PRIMARY_OUTLET];
|
|
@@ -3218,58 +3368,34 @@
|
|
|
3218
3368
|
}
|
|
3219
3369
|
return s;
|
|
3220
3370
|
}
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
if (isEmptyPathRedirect(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
|
|
3228
|
-
res[getOutlet(r)] = new UrlSegmentGroup([], {});
|
|
3229
|
-
}
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3233
|
-
finally {
|
|
3234
|
-
try {
|
|
3235
|
-
if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
|
3236
|
-
}
|
|
3237
|
-
finally { if (e_2) throw e_2.error; }
|
|
3238
|
-
}
|
|
3239
|
-
return Object.assign(Object.assign({}, children), res);
|
|
3240
|
-
}
|
|
3241
|
-
function createChildrenForEmptySegments(routes, primarySegmentGroup) {
|
|
3371
|
+
/**
|
|
3372
|
+
* Recursively merges primary segment children into their parents and also drops empty children
|
|
3373
|
+
* (those which have no segments and no children themselves). The latter prevents serializing a
|
|
3374
|
+
* group into something like `/a(aux:)`, where `aux` is an empty child segment.
|
|
3375
|
+
*/
|
|
3376
|
+
function squashSegmentGroup(segmentGroup) {
|
|
3242
3377
|
var e_3, _a;
|
|
3243
|
-
var
|
|
3244
|
-
res[PRIMARY_OUTLET] = primarySegmentGroup;
|
|
3378
|
+
var newChildren = {};
|
|
3245
3379
|
try {
|
|
3246
|
-
for (var
|
|
3247
|
-
var
|
|
3248
|
-
|
|
3249
|
-
|
|
3380
|
+
for (var _b = __values(Object.keys(segmentGroup.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3381
|
+
var childOutlet = _c.value;
|
|
3382
|
+
var child = segmentGroup.children[childOutlet];
|
|
3383
|
+
var childCandidate = squashSegmentGroup(child);
|
|
3384
|
+
// don't add empty children
|
|
3385
|
+
if (childCandidate.segments.length > 0 || childCandidate.hasChildren()) {
|
|
3386
|
+
newChildren[childOutlet] = childCandidate;
|
|
3250
3387
|
}
|
|
3251
3388
|
}
|
|
3252
3389
|
}
|
|
3253
3390
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3254
3391
|
finally {
|
|
3255
3392
|
try {
|
|
3256
|
-
if (
|
|
3393
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3257
3394
|
}
|
|
3258
3395
|
finally { if (e_3) throw e_3.error; }
|
|
3259
3396
|
}
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
function containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, segments, routes) {
|
|
3263
|
-
return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
|
|
3264
|
-
}
|
|
3265
|
-
function containsEmptyPathRedirects(segmentGroup, segments, routes) {
|
|
3266
|
-
return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r); });
|
|
3267
|
-
}
|
|
3268
|
-
function isEmptyPathRedirect(segmentGroup, segments, r) {
|
|
3269
|
-
if ((segmentGroup.hasChildren() || segments.length > 0) && r.pathMatch === 'full') {
|
|
3270
|
-
return false;
|
|
3271
|
-
}
|
|
3272
|
-
return r.path === '' && r.redirectTo !== undefined;
|
|
3397
|
+
var s = new UrlSegmentGroup(segmentGroup.segments, newChildren);
|
|
3398
|
+
return mergeTrivialChildren(s);
|
|
3273
3399
|
}
|
|
3274
3400
|
|
|
3275
3401
|
/**
|
|
@@ -3280,10 +3406,8 @@
|
|
|
3280
3406
|
* found in the LICENSE file at https://angular.io/license
|
|
3281
3407
|
*/
|
|
3282
3408
|
function applyRedirects$1(moduleInjector, configLoader, urlSerializer, config) {
|
|
3283
|
-
return function (
|
|
3284
|
-
|
|
3285
|
-
.pipe(operators.map(function (urlAfterRedirects) { return (Object.assign(Object.assign({}, t), { urlAfterRedirects: urlAfterRedirects })); })); }));
|
|
3286
|
-
};
|
|
3409
|
+
return operators.switchMap(function (t) { return applyRedirects(moduleInjector, configLoader, urlSerializer, t.extractedUrl, config)
|
|
3410
|
+
.pipe(operators.map(function (urlAfterRedirects) { return (Object.assign(Object.assign({}, t), { urlAfterRedirects: urlAfterRedirects })); })); });
|
|
3287
3411
|
}
|
|
3288
3412
|
|
|
3289
3413
|
/**
|
|
@@ -3448,20 +3572,18 @@
|
|
|
3448
3572
|
* found in the LICENSE file at https://angular.io/license
|
|
3449
3573
|
*/
|
|
3450
3574
|
function checkGuards(moduleInjector, forwardEvent) {
|
|
3451
|
-
return function (
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
}));
|
|
3464
|
-
};
|
|
3575
|
+
return operators.mergeMap(function (t) {
|
|
3576
|
+
var targetSnapshot = t.targetSnapshot, currentSnapshot = t.currentSnapshot, _a = t.guards, canActivateChecks = _a.canActivateChecks, canDeactivateChecks = _a.canDeactivateChecks;
|
|
3577
|
+
if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
|
|
3578
|
+
return rxjs.of(Object.assign(Object.assign({}, t), { guardsResult: true }));
|
|
3579
|
+
}
|
|
3580
|
+
return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, moduleInjector)
|
|
3581
|
+
.pipe(operators.mergeMap(function (canDeactivate) {
|
|
3582
|
+
return canDeactivate && isBoolean(canDeactivate) ?
|
|
3583
|
+
runCanActivateChecks(targetSnapshot, canActivateChecks, moduleInjector, forwardEvent) :
|
|
3584
|
+
rxjs.of(canDeactivate);
|
|
3585
|
+
}), operators.map(function (guardsResult) { return (Object.assign(Object.assign({}, t), { guardsResult: guardsResult })); }));
|
|
3586
|
+
});
|
|
3465
3587
|
}
|
|
3466
3588
|
function runCanDeactivateChecks(checks, futureRSS, currRSS, moduleInjector) {
|
|
3467
3589
|
return rxjs.from(checks).pipe(operators.mergeMap(function (check) { return runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector); }), operators.first(function (result) {
|
|
@@ -3470,15 +3592,7 @@
|
|
|
3470
3592
|
}
|
|
3471
3593
|
function runCanActivateChecks(futureSnapshot, checks, moduleInjector, forwardEvent) {
|
|
3472
3594
|
return rxjs.from(checks).pipe(operators.concatMap(function (check) {
|
|
3473
|
-
return rxjs.
|
|
3474
|
-
fireChildActivationStart(check.route.parent, forwardEvent),
|
|
3475
|
-
fireActivationStart(check.route, forwardEvent),
|
|
3476
|
-
runCanActivateChild(futureSnapshot, check.path, moduleInjector),
|
|
3477
|
-
runCanActivate(futureSnapshot, check.route, moduleInjector)
|
|
3478
|
-
])
|
|
3479
|
-
.pipe(operators.concatAll(), operators.first(function (result) {
|
|
3480
|
-
return result !== true;
|
|
3481
|
-
}, true));
|
|
3595
|
+
return rxjs.concat(fireChildActivationStart(check.route.parent, forwardEvent), fireActivationStart(check.route, forwardEvent), runCanActivateChild(futureSnapshot, check.path, moduleInjector), runCanActivate(futureSnapshot, check.route, moduleInjector));
|
|
3482
3596
|
}), operators.first(function (result) {
|
|
3483
3597
|
return result !== true;
|
|
3484
3598
|
}, true));
|
|
@@ -3586,11 +3700,28 @@
|
|
|
3586
3700
|
}
|
|
3587
3701
|
return NoMatch;
|
|
3588
3702
|
}());
|
|
3703
|
+
function newObservableError(e) {
|
|
3704
|
+
// TODO(atscott): This pattern is used throughout the router code and can be `throwError` instead.
|
|
3705
|
+
return new rxjs.Observable(function (obs) { return obs.error(e); });
|
|
3706
|
+
}
|
|
3589
3707
|
function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
|
|
3590
3708
|
if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
|
|
3591
3709
|
if (relativeLinkResolution === void 0) { relativeLinkResolution = 'legacy'; }
|
|
3592
|
-
|
|
3593
|
-
|
|
3710
|
+
try {
|
|
3711
|
+
var result = new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
|
|
3712
|
+
.recognize();
|
|
3713
|
+
if (result === null) {
|
|
3714
|
+
return newObservableError(new NoMatch$1());
|
|
3715
|
+
}
|
|
3716
|
+
else {
|
|
3717
|
+
return rxjs.of(result);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
catch (e) {
|
|
3721
|
+
// Catch the potential error from recognize due to duplicate outlet matches and return as an
|
|
3722
|
+
// `Observable` error instead.
|
|
3723
|
+
return newObservableError(e);
|
|
3724
|
+
}
|
|
3594
3725
|
}
|
|
3595
3726
|
var Recognizer = /** @class */ (function () {
|
|
3596
3727
|
function Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
|
|
@@ -3602,18 +3733,19 @@
|
|
|
3602
3733
|
this.relativeLinkResolution = relativeLinkResolution;
|
|
3603
3734
|
}
|
|
3604
3735
|
Recognizer.prototype.recognize = function () {
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
var routeState = new RouterStateSnapshot(this.url, rootNode);
|
|
3611
|
-
this.inheritParamsAndData(routeState._root);
|
|
3612
|
-
return rxjs.of(routeState);
|
|
3613
|
-
}
|
|
3614
|
-
catch (e) {
|
|
3615
|
-
return new rxjs.Observable(function (obs) { return obs.error(e); });
|
|
3736
|
+
var rootSegmentGroup = split(this.urlTree.root, [], [], this.config.filter(function (c) { return c.redirectTo === undefined; }), this.relativeLinkResolution)
|
|
3737
|
+
.segmentGroup;
|
|
3738
|
+
var children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
|
|
3739
|
+
if (children === null) {
|
|
3740
|
+
return null;
|
|
3616
3741
|
}
|
|
3742
|
+
// Use Object.freeze to prevent readers of the Router state from modifying it outside of a
|
|
3743
|
+
// navigation, resulting in the router being out of sync with the browser.
|
|
3744
|
+
var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
|
|
3745
|
+
var rootNode = new TreeNode(root, children);
|
|
3746
|
+
var routeState = new RouterStateSnapshot(this.url, rootNode);
|
|
3747
|
+
this.inheritParamsAndData(routeState._root);
|
|
3748
|
+
return routeState;
|
|
3617
3749
|
};
|
|
3618
3750
|
Recognizer.prototype.inheritParamsAndData = function (routeNode) {
|
|
3619
3751
|
var _this = this;
|
|
@@ -3629,70 +3761,123 @@
|
|
|
3629
3761
|
}
|
|
3630
3762
|
return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
|
|
3631
3763
|
};
|
|
3764
|
+
/**
|
|
3765
|
+
* Matches every child outlet in the `segmentGroup` to a `Route` in the config. Returns `null` if
|
|
3766
|
+
* we cannot find a match for _any_ of the children.
|
|
3767
|
+
*
|
|
3768
|
+
* @param config - The `Routes` to match against
|
|
3769
|
+
* @param segmentGroup - The `UrlSegmentGroup` whose children need to be matched against the
|
|
3770
|
+
* config.
|
|
3771
|
+
*/
|
|
3632
3772
|
Recognizer.prototype.processChildren = function (config, segmentGroup) {
|
|
3633
|
-
var
|
|
3634
|
-
var children =
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3773
|
+
var e_1, _a;
|
|
3774
|
+
var children = [];
|
|
3775
|
+
try {
|
|
3776
|
+
for (var _b = __values(Object.keys(segmentGroup.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3777
|
+
var childOutlet = _c.value;
|
|
3778
|
+
var child = segmentGroup.children[childOutlet];
|
|
3779
|
+
// Sort the config so that routes with outlets that match the one being activated appear
|
|
3780
|
+
// first, followed by routes for other outlets, which might match if they have an empty path.
|
|
3781
|
+
var sortedConfig = sortByMatchingOutlets(config, childOutlet);
|
|
3782
|
+
var outletChildren = this.processSegmentGroup(sortedConfig, child, childOutlet);
|
|
3783
|
+
if (outletChildren === null) {
|
|
3784
|
+
// Configs must match all segment children so because we did not find a match for this
|
|
3785
|
+
// outlet, return `null`.
|
|
3786
|
+
return null;
|
|
3787
|
+
}
|
|
3788
|
+
children.push.apply(children, __spread(outletChildren));
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3792
|
+
finally {
|
|
3793
|
+
try {
|
|
3794
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3795
|
+
}
|
|
3796
|
+
finally { if (e_1) throw e_1.error; }
|
|
3797
|
+
}
|
|
3798
|
+
// Because we may have matched two outlets to the same empty path segment, we can have multiple
|
|
3799
|
+
// activated results for the same outlet. We should merge the children of these results so the
|
|
3800
|
+
// final return value is only one `TreeNode` per outlet.
|
|
3801
|
+
var mergedChildren = mergeEmptyPathMatches(children);
|
|
3802
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
3803
|
+
// This should really never happen - we are only taking the first match for each outlet and
|
|
3804
|
+
// merge the empty path matches.
|
|
3805
|
+
checkOutletNameUniqueness(mergedChildren);
|
|
3806
|
+
}
|
|
3807
|
+
sortActivatedRouteSnapshots(mergedChildren);
|
|
3808
|
+
return mergedChildren;
|
|
3638
3809
|
};
|
|
3639
3810
|
Recognizer.prototype.processSegment = function (config, segmentGroup, segments, outlet) {
|
|
3640
|
-
var
|
|
3811
|
+
var e_2, _a;
|
|
3641
3812
|
try {
|
|
3642
3813
|
for (var config_1 = __values(config), config_1_1 = config_1.next(); !config_1_1.done; config_1_1 = config_1.next()) {
|
|
3643
3814
|
var r = config_1_1.value;
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
catch (e) {
|
|
3648
|
-
if (!(e instanceof NoMatch$1))
|
|
3649
|
-
throw e;
|
|
3815
|
+
var children = this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
|
|
3816
|
+
if (children !== null) {
|
|
3817
|
+
return children;
|
|
3650
3818
|
}
|
|
3651
3819
|
}
|
|
3652
3820
|
}
|
|
3653
|
-
catch (
|
|
3821
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3654
3822
|
finally {
|
|
3655
3823
|
try {
|
|
3656
3824
|
if (config_1_1 && !config_1_1.done && (_a = config_1.return)) _a.call(config_1);
|
|
3657
3825
|
}
|
|
3658
|
-
finally { if (
|
|
3826
|
+
finally { if (e_2) throw e_2.error; }
|
|
3659
3827
|
}
|
|
3660
|
-
if (
|
|
3828
|
+
if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
3661
3829
|
return [];
|
|
3662
3830
|
}
|
|
3663
|
-
|
|
3664
|
-
};
|
|
3665
|
-
Recognizer.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
|
|
3666
|
-
return segments.length === 0 && !segmentGroup.children[outlet];
|
|
3831
|
+
return null;
|
|
3667
3832
|
};
|
|
3668
3833
|
Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, segments, outlet) {
|
|
3669
|
-
if (route.redirectTo)
|
|
3670
|
-
|
|
3671
|
-
if ((route.outlet || PRIMARY_OUTLET) !== outlet)
|
|
3672
|
-
throw new NoMatch$1();
|
|
3834
|
+
if (route.redirectTo || !isImmediateMatch(route, rawSegment, segments, outlet))
|
|
3835
|
+
return null;
|
|
3673
3836
|
var snapshot;
|
|
3674
3837
|
var consumedSegments = [];
|
|
3675
3838
|
var rawSlicedSegments = [];
|
|
3676
3839
|
if (route.path === '**') {
|
|
3677
3840
|
var params = segments.length > 0 ? last(segments).parameters : {};
|
|
3678
|
-
snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route),
|
|
3841
|
+
snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, getResolve(route));
|
|
3679
3842
|
}
|
|
3680
3843
|
else {
|
|
3681
|
-
var result = match
|
|
3844
|
+
var result = match(rawSegment, route, segments);
|
|
3845
|
+
if (!result.matched) {
|
|
3846
|
+
return null;
|
|
3847
|
+
}
|
|
3682
3848
|
consumedSegments = result.consumedSegments;
|
|
3683
3849
|
rawSlicedSegments = segments.slice(result.lastChild);
|
|
3684
|
-
snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route),
|
|
3850
|
+
snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route));
|
|
3685
3851
|
}
|
|
3686
3852
|
var childConfig = getChildConfig(route);
|
|
3687
|
-
var _a = split
|
|
3853
|
+
var _a = split(rawSegment, consumedSegments, rawSlicedSegments,
|
|
3854
|
+
// Filter out routes with redirectTo because we are trying to create activated route
|
|
3855
|
+
// snapshots and don't handle redirects here. That should have been done in
|
|
3856
|
+
// `applyRedirects`.
|
|
3857
|
+
childConfig.filter(function (c) { return c.redirectTo === undefined; }), this.relativeLinkResolution), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
|
|
3688
3858
|
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
|
3689
3859
|
var children_1 = this.processChildren(childConfig, segmentGroup);
|
|
3860
|
+
if (children_1 === null) {
|
|
3861
|
+
return null;
|
|
3862
|
+
}
|
|
3690
3863
|
return [new TreeNode(snapshot, children_1)];
|
|
3691
3864
|
}
|
|
3692
3865
|
if (childConfig.length === 0 && slicedSegments.length === 0) {
|
|
3693
3866
|
return [new TreeNode(snapshot, [])];
|
|
3694
3867
|
}
|
|
3695
|
-
var
|
|
3868
|
+
var matchedOnOutlet = getOutlet(route) === outlet;
|
|
3869
|
+
// If we matched a config due to empty path match on a different outlet, we need to continue
|
|
3870
|
+
// passing the current outlet for the segment rather than switch to PRIMARY.
|
|
3871
|
+
// Note that we switch to primary when we have a match because outlet configs look like this:
|
|
3872
|
+
// {path: 'a', outlet: 'a', children: [
|
|
3873
|
+
// {path: 'b', component: B},
|
|
3874
|
+
// {path: 'c', component: C},
|
|
3875
|
+
// ]}
|
|
3876
|
+
// Notice that the children of the named outlet are configured with the primary outlet
|
|
3877
|
+
var children = this.processSegment(childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet);
|
|
3878
|
+
if (children === null) {
|
|
3879
|
+
return null;
|
|
3880
|
+
}
|
|
3696
3881
|
return [new TreeNode(snapshot, children)];
|
|
3697
3882
|
};
|
|
3698
3883
|
return Recognizer;
|
|
@@ -3715,24 +3900,46 @@
|
|
|
3715
3900
|
}
|
|
3716
3901
|
return [];
|
|
3717
3902
|
}
|
|
3718
|
-
function
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3903
|
+
function hasEmptyPathConfig(node) {
|
|
3904
|
+
var config = node.value.routeConfig;
|
|
3905
|
+
return config && config.path === '' && config.redirectTo === undefined;
|
|
3906
|
+
}
|
|
3907
|
+
/**
|
|
3908
|
+
* Finds `TreeNode`s with matching empty path route configs and merges them into `TreeNode` with the
|
|
3909
|
+
* children from each duplicate. This is necessary because different outlets can match a single
|
|
3910
|
+
* empty path route config and the results need to then be merged.
|
|
3911
|
+
*/
|
|
3912
|
+
function mergeEmptyPathMatches(nodes) {
|
|
3913
|
+
var e_3, _a;
|
|
3914
|
+
var result = [];
|
|
3915
|
+
var _loop_1 = function (node) {
|
|
3916
|
+
var _a;
|
|
3917
|
+
if (!hasEmptyPathConfig(node)) {
|
|
3918
|
+
result.push(node);
|
|
3919
|
+
return "continue";
|
|
3920
|
+
}
|
|
3921
|
+
var duplicateEmptyPathNode = result.find(function (resultNode) { return node.value.routeConfig === resultNode.value.routeConfig; });
|
|
3922
|
+
if (duplicateEmptyPathNode !== undefined) {
|
|
3923
|
+
(_a = duplicateEmptyPathNode.children).push.apply(_a, __spread(node.children));
|
|
3924
|
+
}
|
|
3925
|
+
else {
|
|
3926
|
+
result.push(node);
|
|
3927
|
+
}
|
|
3928
|
+
};
|
|
3929
|
+
try {
|
|
3930
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
3931
|
+
var node = nodes_1_1.value;
|
|
3932
|
+
_loop_1(node);
|
|
3722
3933
|
}
|
|
3723
|
-
return { consumedSegments: [], lastChild: 0, parameters: {} };
|
|
3724
3934
|
}
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
var parameters = res.consumed.length > 0 ? Object.assign(Object.assign({}, posParams), res.consumed[res.consumed.length - 1].parameters) :
|
|
3734
|
-
posParams;
|
|
3735
|
-
return { consumedSegments: res.consumed, lastChild: res.consumed.length, parameters: parameters };
|
|
3935
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3936
|
+
finally {
|
|
3937
|
+
try {
|
|
3938
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
3939
|
+
}
|
|
3940
|
+
finally { if (e_3) throw e_3.error; }
|
|
3941
|
+
}
|
|
3942
|
+
return result;
|
|
3736
3943
|
}
|
|
3737
3944
|
function checkOutletNameUniqueness(nodes) {
|
|
3738
3945
|
var names = {};
|
|
@@ -3762,92 +3969,6 @@
|
|
|
3762
3969
|
}
|
|
3763
3970
|
return res - 1;
|
|
3764
3971
|
}
|
|
3765
|
-
function split$1(segmentGroup, consumedSegments, slicedSegments, config, relativeLinkResolution) {
|
|
3766
|
-
if (slicedSegments.length > 0 &&
|
|
3767
|
-
containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
|
3768
|
-
var s_1 = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
|
3769
|
-
s_1._sourceSegment = segmentGroup;
|
|
3770
|
-
s_1._segmentIndexShift = consumedSegments.length;
|
|
3771
|
-
return { segmentGroup: s_1, slicedSegments: [] };
|
|
3772
|
-
}
|
|
3773
|
-
if (slicedSegments.length === 0 &&
|
|
3774
|
-
containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
|
|
3775
|
-
var s_2 = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, config, segmentGroup.children, relativeLinkResolution));
|
|
3776
|
-
s_2._sourceSegment = segmentGroup;
|
|
3777
|
-
s_2._segmentIndexShift = consumedSegments.length;
|
|
3778
|
-
return { segmentGroup: s_2, slicedSegments: slicedSegments };
|
|
3779
|
-
}
|
|
3780
|
-
var s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
|
|
3781
|
-
s._sourceSegment = segmentGroup;
|
|
3782
|
-
s._segmentIndexShift = consumedSegments.length;
|
|
3783
|
-
return { segmentGroup: s, slicedSegments: slicedSegments };
|
|
3784
|
-
}
|
|
3785
|
-
function addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, routes, children, relativeLinkResolution) {
|
|
3786
|
-
var e_2, _a;
|
|
3787
|
-
var res = {};
|
|
3788
|
-
try {
|
|
3789
|
-
for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
|
|
3790
|
-
var r = routes_1_1.value;
|
|
3791
|
-
if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
|
|
3792
|
-
var s = new UrlSegmentGroup([], {});
|
|
3793
|
-
s._sourceSegment = segmentGroup;
|
|
3794
|
-
if (relativeLinkResolution === 'legacy') {
|
|
3795
|
-
s._segmentIndexShift = segmentGroup.segments.length;
|
|
3796
|
-
}
|
|
3797
|
-
else {
|
|
3798
|
-
s._segmentIndexShift = consumedSegments.length;
|
|
3799
|
-
}
|
|
3800
|
-
res[getOutlet(r)] = s;
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3805
|
-
finally {
|
|
3806
|
-
try {
|
|
3807
|
-
if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
|
3808
|
-
}
|
|
3809
|
-
finally { if (e_2) throw e_2.error; }
|
|
3810
|
-
}
|
|
3811
|
-
return Object.assign(Object.assign({}, children), res);
|
|
3812
|
-
}
|
|
3813
|
-
function createChildrenForEmptyPaths(segmentGroup, consumedSegments, routes, primarySegment) {
|
|
3814
|
-
var e_3, _a;
|
|
3815
|
-
var res = {};
|
|
3816
|
-
res[PRIMARY_OUTLET] = primarySegment;
|
|
3817
|
-
primarySegment._sourceSegment = segmentGroup;
|
|
3818
|
-
primarySegment._segmentIndexShift = consumedSegments.length;
|
|
3819
|
-
try {
|
|
3820
|
-
for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
|
|
3821
|
-
var r = routes_2_1.value;
|
|
3822
|
-
if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
|
|
3823
|
-
var s = new UrlSegmentGroup([], {});
|
|
3824
|
-
s._sourceSegment = segmentGroup;
|
|
3825
|
-
s._segmentIndexShift = consumedSegments.length;
|
|
3826
|
-
res[getOutlet(r)] = s;
|
|
3827
|
-
}
|
|
3828
|
-
}
|
|
3829
|
-
}
|
|
3830
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3831
|
-
finally {
|
|
3832
|
-
try {
|
|
3833
|
-
if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
|
3834
|
-
}
|
|
3835
|
-
finally { if (e_3) throw e_3.error; }
|
|
3836
|
-
}
|
|
3837
|
-
return res;
|
|
3838
|
-
}
|
|
3839
|
-
function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
|
|
3840
|
-
return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
|
|
3841
|
-
}
|
|
3842
|
-
function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
|
|
3843
|
-
return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r); });
|
|
3844
|
-
}
|
|
3845
|
-
function emptyPathMatch(segmentGroup, slicedSegments, r) {
|
|
3846
|
-
if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
|
|
3847
|
-
return false;
|
|
3848
|
-
}
|
|
3849
|
-
return r.path === '' && r.redirectTo === undefined;
|
|
3850
|
-
}
|
|
3851
3972
|
function getData(route) {
|
|
3852
3973
|
return route.data || {};
|
|
3853
3974
|
}
|
|
@@ -3863,10 +3984,8 @@
|
|
|
3863
3984
|
* found in the LICENSE file at https://angular.io/license
|
|
3864
3985
|
*/
|
|
3865
3986
|
function recognize$1(rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
|
|
3866
|
-
return function (
|
|
3867
|
-
|
|
3868
|
-
.pipe(operators.map(function (targetSnapshot) { return (Object.assign(Object.assign({}, t), { targetSnapshot: targetSnapshot })); })); }));
|
|
3869
|
-
};
|
|
3987
|
+
return operators.mergeMap(function (t) { return recognize(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
|
|
3988
|
+
.pipe(operators.map(function (targetSnapshot) { return (Object.assign(Object.assign({}, t), { targetSnapshot: targetSnapshot })); })); });
|
|
3870
3989
|
}
|
|
3871
3990
|
|
|
3872
3991
|
/**
|
|
@@ -3877,17 +3996,15 @@
|
|
|
3877
3996
|
* found in the LICENSE file at https://angular.io/license
|
|
3878
3997
|
*/
|
|
3879
3998
|
function resolveData(paramsInheritanceStrategy, moduleInjector) {
|
|
3880
|
-
return function (
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
return rxjs.
|
|
3888
|
-
|
|
3889
|
-
}));
|
|
3890
|
-
};
|
|
3999
|
+
return operators.mergeMap(function (t) {
|
|
4000
|
+
var targetSnapshot = t.targetSnapshot, canActivateChecks = t.guards.canActivateChecks;
|
|
4001
|
+
if (!canActivateChecks.length) {
|
|
4002
|
+
return rxjs.of(t);
|
|
4003
|
+
}
|
|
4004
|
+
var canActivateChecksResolved = 0;
|
|
4005
|
+
return rxjs.from(canActivateChecks)
|
|
4006
|
+
.pipe(operators.concatMap(function (check) { return runResolve(check.route, targetSnapshot, paramsInheritanceStrategy, moduleInjector); }), operators.tap(function () { return canActivateChecksResolved++; }), operators.takeLast(1), operators.mergeMap(function (_) { return canActivateChecksResolved === canActivateChecks.length ? rxjs.of(t) : rxjs.EMPTY; }));
|
|
4007
|
+
});
|
|
3891
4008
|
}
|
|
3892
4009
|
function runResolve(futureARS, futureRSS, paramsInheritanceStrategy, moduleInjector) {
|
|
3893
4010
|
var resolve = futureARS._resolve;
|
|
@@ -3936,15 +4053,13 @@
|
|
|
3936
4053
|
* it will wait before continuing with the original value.
|
|
3937
4054
|
*/
|
|
3938
4055
|
function switchTap(next) {
|
|
3939
|
-
return function (
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
}));
|
|
3947
|
-
};
|
|
4056
|
+
return operators.switchMap(function (v) {
|
|
4057
|
+
var nextResult = next(v);
|
|
4058
|
+
if (nextResult) {
|
|
4059
|
+
return rxjs.from(nextResult).pipe(operators.map(function () { return v; }));
|
|
4060
|
+
}
|
|
4061
|
+
return rxjs.of(v);
|
|
4062
|
+
});
|
|
3948
4063
|
}
|
|
3949
4064
|
|
|
3950
4065
|
/**
|
|
@@ -4312,7 +4427,7 @@
|
|
|
4312
4427
|
this.ngModule = injector.get(core.NgModuleRef);
|
|
4313
4428
|
this.console = injector.get(core.ɵConsole);
|
|
4314
4429
|
var ngZone = injector.get(core.NgZone);
|
|
4315
|
-
this.isNgZoneEnabled = ngZone instanceof core.NgZone;
|
|
4430
|
+
this.isNgZoneEnabled = ngZone instanceof core.NgZone && core.NgZone.isInAngularZone();
|
|
4316
4431
|
this.resetConfig(config);
|
|
4317
4432
|
this.currentUrlTree = createEmptyUrlTree();
|
|
4318
4433
|
this.rawUrlTree = this.currentUrlTree;
|
|
@@ -4378,11 +4493,10 @@
|
|
|
4378
4493
|
if (transition !== _this.transitions.getValue()) {
|
|
4379
4494
|
return rxjs.EMPTY;
|
|
4380
4495
|
}
|
|
4381
|
-
|
|
4496
|
+
// This delay is required to match old behavior that forced
|
|
4497
|
+
// navigation to always be async
|
|
4498
|
+
return Promise.resolve(t);
|
|
4382
4499
|
}),
|
|
4383
|
-
// This delay is required to match old behavior that forced navigation
|
|
4384
|
-
// to always be async
|
|
4385
|
-
operators.switchMap(function (t) { return Promise.resolve(t); }),
|
|
4386
4500
|
// ApplyRedirects
|
|
4387
4501
|
applyRedirects$1(_this.ngModule.injector, _this.configLoader, _this.urlSerializer, _this.config),
|
|
4388
4502
|
// Update the currentNavigation
|
|
@@ -4399,9 +4513,7 @@
|
|
|
4399
4513
|
}
|
|
4400
4514
|
_this.browserUrlTree = t.urlAfterRedirects;
|
|
4401
4515
|
}
|
|
4402
|
-
|
|
4403
|
-
// Fire RoutesRecognized
|
|
4404
|
-
operators.tap(function (t) {
|
|
4516
|
+
// Fire RoutesRecognized
|
|
4405
4517
|
var routesRecognized = new RoutesRecognized(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
|
4406
4518
|
eventsSubject.next(routesRecognized);
|
|
4407
4519
|
}));
|
|
@@ -4453,7 +4565,6 @@
|
|
|
4453
4565
|
error.url = t.guardsResult;
|
|
4454
4566
|
throw error;
|
|
4455
4567
|
}
|
|
4456
|
-
}), operators.tap(function (t) {
|
|
4457
4568
|
var guardsEnd = new GuardsCheckEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
|
|
4458
4569
|
_this.triggerEvent(guardsEnd);
|
|
4459
4570
|
}), operators.filter(function (t) {
|
|
@@ -4542,7 +4653,7 @@
|
|
|
4542
4653
|
// navigation completes, there will be nothing in
|
|
4543
4654
|
// history.state.navigationId. This can cause sync problems with AngularJS
|
|
4544
4655
|
// sync code which looks for a value here in order to determine whether or
|
|
4545
|
-
// not to handle a given popstate event or to leave it to the
|
|
4656
|
+
// not to handle a given popstate event or to leave it to the Angular
|
|
4546
4657
|
// router.
|
|
4547
4658
|
_this.resetUrlToCurrentUrlTree();
|
|
4548
4659
|
var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), "Navigation ID " + t.id + " is not equal to the current navigation id " + _this.navigationId);
|
|
@@ -4586,7 +4697,7 @@
|
|
|
4586
4697
|
skipLocationChange: t.extras.skipLocationChange,
|
|
4587
4698
|
replaceUrl: _this.urlUpdateStrategy === 'eager'
|
|
4588
4699
|
};
|
|
4589
|
-
|
|
4700
|
+
_this.scheduleNavigation(mergedTree, 'imperative', null, extras, { resolve: t.resolve, reject: t.reject, promise: t.promise });
|
|
4590
4701
|
}, 0);
|
|
4591
4702
|
}
|
|
4592
4703
|
/* All other errors should reset to the router's internal URL reference to
|
|
@@ -5419,9 +5530,7 @@
|
|
|
5419
5530
|
RouterLinkActive.prototype.ngAfterContentInit = function () {
|
|
5420
5531
|
var _this = this;
|
|
5421
5532
|
// `of(null)` is used to force subscribe body to execute once immediately (like `startWith`).
|
|
5422
|
-
rxjs.
|
|
5423
|
-
.pipe(operators.mergeAll())
|
|
5424
|
-
.subscribe(function (_) {
|
|
5533
|
+
rxjs.of(this.links.changes, this.linksWithHrefs.changes, rxjs.of(null)).pipe(operators.mergeAll()).subscribe(function (_) {
|
|
5425
5534
|
_this.update();
|
|
5426
5535
|
_this.subscribeToEachLinkOnChanges();
|
|
5427
5536
|
});
|
|
@@ -6297,7 +6406,7 @@
|
|
|
6297
6406
|
/**
|
|
6298
6407
|
* @publicApi
|
|
6299
6408
|
*/
|
|
6300
|
-
var VERSION = new core.Version('11.0.
|
|
6409
|
+
var VERSION = new core.Version('11.0.9');
|
|
6301
6410
|
|
|
6302
6411
|
/**
|
|
6303
6412
|
* @license
|