source: trip-planner-front/node_modules/@angular/router/esm2015/src/recognize.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 41.7 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Observable, of } from 'rxjs';
9import { ActivatedRouteSnapshot, inheritedParamsDataResolve, RouterStateSnapshot } from './router_state';
10import { PRIMARY_OUTLET } from './shared';
11import { last } from './utils/collection';
12import { getOutlet, sortByMatchingOutlets } from './utils/config';
13import { isImmediateMatch, match, noLeftoversInUrl, split } from './utils/config_matching';
14import { TreeNode } from './utils/tree';
15class NoMatch {
16}
17function newObservableError(e) {
18 // TODO(atscott): This pattern is used throughout the router code and can be `throwError` instead.
19 return new Observable((obs) => obs.error(e));
20}
21export function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy = 'emptyOnly', relativeLinkResolution = 'legacy') {
22 try {
23 const result = new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
24 .recognize();
25 if (result === null) {
26 return newObservableError(new NoMatch());
27 }
28 else {
29 return of(result);
30 }
31 }
32 catch (e) {
33 // Catch the potential error from recognize due to duplicate outlet matches and return as an
34 // `Observable` error instead.
35 return newObservableError(e);
36 }
37}
38export class Recognizer {
39 constructor(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
40 this.rootComponentType = rootComponentType;
41 this.config = config;
42 this.urlTree = urlTree;
43 this.url = url;
44 this.paramsInheritanceStrategy = paramsInheritanceStrategy;
45 this.relativeLinkResolution = relativeLinkResolution;
46 }
47 recognize() {
48 const rootSegmentGroup = split(this.urlTree.root, [], [], this.config.filter(c => c.redirectTo === undefined), this.relativeLinkResolution)
49 .segmentGroup;
50 const children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
51 if (children === null) {
52 return null;
53 }
54 // Use Object.freeze to prevent readers of the Router state from modifying it outside of a
55 // navigation, resulting in the router being out of sync with the browser.
56 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, {});
57 const rootNode = new TreeNode(root, children);
58 const routeState = new RouterStateSnapshot(this.url, rootNode);
59 this.inheritParamsAndData(routeState._root);
60 return routeState;
61 }
62 inheritParamsAndData(routeNode) {
63 const route = routeNode.value;
64 const i = inheritedParamsDataResolve(route, this.paramsInheritanceStrategy);
65 route.params = Object.freeze(i.params);
66 route.data = Object.freeze(i.data);
67 routeNode.children.forEach(n => this.inheritParamsAndData(n));
68 }
69 processSegmentGroup(config, segmentGroup, outlet) {
70 if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
71 return this.processChildren(config, segmentGroup);
72 }
73 return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
74 }
75 /**
76 * Matches every child outlet in the `segmentGroup` to a `Route` in the config. Returns `null` if
77 * we cannot find a match for _any_ of the children.
78 *
79 * @param config - The `Routes` to match against
80 * @param segmentGroup - The `UrlSegmentGroup` whose children need to be matched against the
81 * config.
82 */
83 processChildren(config, segmentGroup) {
84 const children = [];
85 for (const childOutlet of Object.keys(segmentGroup.children)) {
86 const child = segmentGroup.children[childOutlet];
87 // Sort the config so that routes with outlets that match the one being activated appear
88 // first, followed by routes for other outlets, which might match if they have an empty path.
89 const sortedConfig = sortByMatchingOutlets(config, childOutlet);
90 const outletChildren = this.processSegmentGroup(sortedConfig, child, childOutlet);
91 if (outletChildren === null) {
92 // Configs must match all segment children so because we did not find a match for this
93 // outlet, return `null`.
94 return null;
95 }
96 children.push(...outletChildren);
97 }
98 // Because we may have matched two outlets to the same empty path segment, we can have multiple
99 // activated results for the same outlet. We should merge the children of these results so the
100 // final return value is only one `TreeNode` per outlet.
101 const mergedChildren = mergeEmptyPathMatches(children);
102 if (typeof ngDevMode === 'undefined' || ngDevMode) {
103 // This should really never happen - we are only taking the first match for each outlet and
104 // merge the empty path matches.
105 checkOutletNameUniqueness(mergedChildren);
106 }
107 sortActivatedRouteSnapshots(mergedChildren);
108 return mergedChildren;
109 }
110 processSegment(config, segmentGroup, segments, outlet) {
111 for (const r of config) {
112 const children = this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
113 if (children !== null) {
114 return children;
115 }
116 }
117 if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
118 return [];
119 }
120 return null;
121 }
122 processSegmentAgainstRoute(route, rawSegment, segments, outlet) {
123 if (route.redirectTo || !isImmediateMatch(route, rawSegment, segments, outlet))
124 return null;
125 let snapshot;
126 let consumedSegments = [];
127 let rawSlicedSegments = [];
128 if (route.path === '**') {
129 const params = segments.length > 0 ? last(segments).parameters : {};
130 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));
131 }
132 else {
133 const result = match(rawSegment, route, segments);
134 if (!result.matched) {
135 return null;
136 }
137 consumedSegments = result.consumedSegments;
138 rawSlicedSegments = segments.slice(result.lastChild);
139 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));
140 }
141 const childConfig = getChildConfig(route);
142 const { segmentGroup, slicedSegments } = split(rawSegment, consumedSegments, rawSlicedSegments,
143 // Filter out routes with redirectTo because we are trying to create activated route
144 // snapshots and don't handle redirects here. That should have been done in
145 // `applyRedirects`.
146 childConfig.filter(c => c.redirectTo === undefined), this.relativeLinkResolution);
147 if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
148 const children = this.processChildren(childConfig, segmentGroup);
149 if (children === null) {
150 return null;
151 }
152 return [new TreeNode(snapshot, children)];
153 }
154 if (childConfig.length === 0 && slicedSegments.length === 0) {
155 return [new TreeNode(snapshot, [])];
156 }
157 const matchedOnOutlet = getOutlet(route) === outlet;
158 // If we matched a config due to empty path match on a different outlet, we need to continue
159 // passing the current outlet for the segment rather than switch to PRIMARY.
160 // Note that we switch to primary when we have a match because outlet configs look like this:
161 // {path: 'a', outlet: 'a', children: [
162 // {path: 'b', component: B},
163 // {path: 'c', component: C},
164 // ]}
165 // Notice that the children of the named outlet are configured with the primary outlet
166 const children = this.processSegment(childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet);
167 if (children === null) {
168 return null;
169 }
170 return [new TreeNode(snapshot, children)];
171 }
172}
173function sortActivatedRouteSnapshots(nodes) {
174 nodes.sort((a, b) => {
175 if (a.value.outlet === PRIMARY_OUTLET)
176 return -1;
177 if (b.value.outlet === PRIMARY_OUTLET)
178 return 1;
179 return a.value.outlet.localeCompare(b.value.outlet);
180 });
181}
182function getChildConfig(route) {
183 if (route.children) {
184 return route.children;
185 }
186 if (route.loadChildren) {
187 return route._loadedConfig.routes;
188 }
189 return [];
190}
191function hasEmptyPathConfig(node) {
192 const config = node.value.routeConfig;
193 return config && config.path === '' && config.redirectTo === undefined;
194}
195/**
196 * Finds `TreeNode`s with matching empty path route configs and merges them into `TreeNode` with the
197 * children from each duplicate. This is necessary because different outlets can match a single
198 * empty path route config and the results need to then be merged.
199 */
200function mergeEmptyPathMatches(nodes) {
201 const result = [];
202 // The set of nodes which contain children that were merged from two duplicate empty path nodes.
203 const mergedNodes = new Set();
204 for (const node of nodes) {
205 if (!hasEmptyPathConfig(node)) {
206 result.push(node);
207 continue;
208 }
209 const duplicateEmptyPathNode = result.find(resultNode => node.value.routeConfig === resultNode.value.routeConfig);
210 if (duplicateEmptyPathNode !== undefined) {
211 duplicateEmptyPathNode.children.push(...node.children);
212 mergedNodes.add(duplicateEmptyPathNode);
213 }
214 else {
215 result.push(node);
216 }
217 }
218 // For each node which has children from multiple sources, we need to recompute a new `TreeNode`
219 // by also merging those children. This is necessary when there are multiple empty path configs in
220 // a row. Put another way: whenever we combine children of two nodes, we need to also check if any
221 // of those children can be combined into a single node as well.
222 for (const mergedNode of mergedNodes) {
223 const mergedChildren = mergeEmptyPathMatches(mergedNode.children);
224 result.push(new TreeNode(mergedNode.value, mergedChildren));
225 }
226 return result.filter(n => !mergedNodes.has(n));
227}
228function checkOutletNameUniqueness(nodes) {
229 const names = {};
230 nodes.forEach(n => {
231 const routeWithSameOutletName = names[n.value.outlet];
232 if (routeWithSameOutletName) {
233 const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
234 const c = n.value.url.map(s => s.toString()).join('/');
235 throw new Error(`Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
236 }
237 names[n.value.outlet] = n.value;
238 });
239}
240function getSourceSegmentGroup(segmentGroup) {
241 let s = segmentGroup;
242 while (s._sourceSegment) {
243 s = s._sourceSegment;
244 }
245 return s;
246}
247function getPathIndexShift(segmentGroup) {
248 let s = segmentGroup;
249 let res = (s._segmentIndexShift ? s._segmentIndexShift : 0);
250 while (s._sourceSegment) {
251 s = s._sourceSegment;
252 res += (s._segmentIndexShift ? s._segmentIndexShift : 0);
253 }
254 return res - 1;
255}
256function getData(route) {
257 return route.data || {};
258}
259function getResolve(route) {
260 return route.resolve || {};
261}
262//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjb2duaXplLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvcm91dGVyL3NyYy9yZWNvZ25pemUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBR0gsT0FBTyxFQUFDLFVBQVUsRUFBWSxFQUFFLEVBQUMsTUFBTSxNQUFNLENBQ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XG4gIHJldHVybiByZXMgLSAxO1xufVxuXG5mdW5jdGlvbiBnZXREYXRhKHJvdXRlOiBSb3V0ZSk6IERhdGEge1xuICByZXR1cm4gcm91dGUuZGF0YSB8fCB7fTtcbn1cblxuZnVuY3Rpb24gZ2V0UmVzb2x2ZShyb3V0ZTogUm91dGUpOiBSZXNvbHZlRGF0YSB7XG4gIHJldHVybiByb3V0ZS5yZXNvbHZlIHx8IHt9O1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.