1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { __extends, __decorate, __assign, __values, __spread, __metadata, __param } from 'tslib';
|
8 | import { LocationStrategy, Location, PlatformLocation, APP_BASE_HREF, ViewportScroller, HashLocationStrategy, PathLocationStrategy, ɵgetDOM, LOCATION_INITIALIZED } from '@angular/common';
|
9 | import { Component, ɵisObservable, ɵisPromise, NgModuleRef, InjectionToken, NgModuleFactory, ɵConsole, NgZone, isDevMode, Input, HostListener, Directive, Attribute, Renderer2, ElementRef, HostBinding, ContentChildren, QueryList, Optional, EventEmitter, Output, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef, Injectable, NgModuleFactoryLoader, Compiler, Injector, SystemJsNgModuleLoader, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
|
10 | import { of, from, BehaviorSubject, Observable, EmptyError, combineLatest, defer, Subject, EMPTY } from 'rxjs';
|
11 | import { map, concatAll, last as last$1, catchError, first, mergeMap, every, switchMap, take, startWith, scan, filter, concatMap, reduce, tap, finalize, mergeAll } from 'rxjs/operators';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | var RouterEvent = (function () {
|
42 | function RouterEvent(
|
43 | /** A unique ID that the router assigns to every router navigation. */
|
44 | id,
|
45 | /** The URL that is the destination for this navigation. */
|
46 | url) {
|
47 | this.id = id;
|
48 | this.url = url;
|
49 | }
|
50 | return RouterEvent;
|
51 | }());
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | var NavigationStart = (function (_super) {
|
58 | __extends(NavigationStart, _super);
|
59 | function NavigationStart(
|
60 | /** @docsNotRequired */
|
61 | id,
|
62 | /** @docsNotRequired */
|
63 | url,
|
64 | /** @docsNotRequired */
|
65 | navigationTrigger,
|
66 | /** @docsNotRequired */
|
67 | restoredState) {
|
68 | if (navigationTrigger === void 0) { navigationTrigger = 'imperative'; }
|
69 | if (restoredState === void 0) { restoredState = null; }
|
70 | var _this = _super.call(this, id, url) || this;
|
71 | _this.navigationTrigger = navigationTrigger;
|
72 | _this.restoredState = restoredState;
|
73 | return _this;
|
74 | }
|
75 |
|
76 | NavigationStart.prototype.toString = function () { return "NavigationStart(id: " + this.id + ", url: '" + this.url + "')"; };
|
77 | return NavigationStart;
|
78 | }(RouterEvent));
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | var NavigationEnd = (function (_super) {
|
85 | __extends(NavigationEnd, _super);
|
86 | function NavigationEnd(
|
87 | /** @docsNotRequired */
|
88 | id,
|
89 | /** @docsNotRequired */
|
90 | url,
|
91 | /** @docsNotRequired */
|
92 | urlAfterRedirects) {
|
93 | var _this = _super.call(this, id, url) || this;
|
94 | _this.urlAfterRedirects = urlAfterRedirects;
|
95 | return _this;
|
96 | }
|
97 |
|
98 | NavigationEnd.prototype.toString = function () {
|
99 | return "NavigationEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "')";
|
100 | };
|
101 | return NavigationEnd;
|
102 | }(RouterEvent));
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | var NavigationCancel = (function (_super) {
|
112 | __extends(NavigationCancel, _super);
|
113 | function NavigationCancel(
|
114 | /** @docsNotRequired */
|
115 | id,
|
116 | /** @docsNotRequired */
|
117 | url,
|
118 | /** @docsNotRequired */
|
119 | reason) {
|
120 | var _this = _super.call(this, id, url) || this;
|
121 | _this.reason = reason;
|
122 | return _this;
|
123 | }
|
124 |
|
125 | NavigationCancel.prototype.toString = function () { return "NavigationCancel(id: " + this.id + ", url: '" + this.url + "')"; };
|
126 | return NavigationCancel;
|
127 | }(RouterEvent));
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | var NavigationError = (function (_super) {
|
134 | __extends(NavigationError, _super);
|
135 | function NavigationError(
|
136 | /** @docsNotRequired */
|
137 | id,
|
138 | /** @docsNotRequired */
|
139 | url,
|
140 | /** @docsNotRequired */
|
141 | error) {
|
142 | var _this = _super.call(this, id, url) || this;
|
143 | _this.error = error;
|
144 | return _this;
|
145 | }
|
146 |
|
147 | NavigationError.prototype.toString = function () {
|
148 | return "NavigationError(id: " + this.id + ", url: '" + this.url + "', error: " + this.error + ")";
|
149 | };
|
150 | return NavigationError;
|
151 | }(RouterEvent));
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | var RoutesRecognized = (function (_super) {
|
158 | __extends(RoutesRecognized, _super);
|
159 | function RoutesRecognized(
|
160 | /** @docsNotRequired */
|
161 | id,
|
162 | /** @docsNotRequired */
|
163 | url,
|
164 | /** @docsNotRequired */
|
165 | urlAfterRedirects,
|
166 | /** @docsNotRequired */
|
167 | state) {
|
168 | var _this = _super.call(this, id, url) || this;
|
169 | _this.urlAfterRedirects = urlAfterRedirects;
|
170 | _this.state = state;
|
171 | return _this;
|
172 | }
|
173 |
|
174 | RoutesRecognized.prototype.toString = function () {
|
175 | return "RoutesRecognized(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
|
176 | };
|
177 | return RoutesRecognized;
|
178 | }(RouterEvent));
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | var GuardsCheckStart = (function (_super) {
|
185 | __extends(GuardsCheckStart, _super);
|
186 | function GuardsCheckStart(
|
187 | /** @docsNotRequired */
|
188 | id,
|
189 | /** @docsNotRequired */
|
190 | url,
|
191 | /** @docsNotRequired */
|
192 | urlAfterRedirects,
|
193 | /** @docsNotRequired */
|
194 | state) {
|
195 | var _this = _super.call(this, id, url) || this;
|
196 | _this.urlAfterRedirects = urlAfterRedirects;
|
197 | _this.state = state;
|
198 | return _this;
|
199 | }
|
200 | GuardsCheckStart.prototype.toString = function () {
|
201 | return "GuardsCheckStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
|
202 | };
|
203 | return GuardsCheckStart;
|
204 | }(RouterEvent));
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | var GuardsCheckEnd = (function (_super) {
|
211 | __extends(GuardsCheckEnd, _super);
|
212 | function GuardsCheckEnd(
|
213 | /** @docsNotRequired */
|
214 | id,
|
215 | /** @docsNotRequired */
|
216 | url,
|
217 | /** @docsNotRequired */
|
218 | urlAfterRedirects,
|
219 | /** @docsNotRequired */
|
220 | state,
|
221 | /** @docsNotRequired */
|
222 | shouldActivate) {
|
223 | var _this = _super.call(this, id, url) || this;
|
224 | _this.urlAfterRedirects = urlAfterRedirects;
|
225 | _this.state = state;
|
226 | _this.shouldActivate = shouldActivate;
|
227 | return _this;
|
228 | }
|
229 | GuardsCheckEnd.prototype.toString = function () {
|
230 | return "GuardsCheckEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ", shouldActivate: " + this.shouldActivate + ")";
|
231 | };
|
232 | return GuardsCheckEnd;
|
233 | }(RouterEvent));
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 | var ResolveStart = (function (_super) {
|
243 | __extends(ResolveStart, _super);
|
244 | function ResolveStart(
|
245 | /** @docsNotRequired */
|
246 | id,
|
247 | /** @docsNotRequired */
|
248 | url,
|
249 | /** @docsNotRequired */
|
250 | urlAfterRedirects,
|
251 | /** @docsNotRequired */
|
252 | state) {
|
253 | var _this = _super.call(this, id, url) || this;
|
254 | _this.urlAfterRedirects = urlAfterRedirects;
|
255 | _this.state = state;
|
256 | return _this;
|
257 | }
|
258 | ResolveStart.prototype.toString = function () {
|
259 | return "ResolveStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
|
260 | };
|
261 | return ResolveStart;
|
262 | }(RouterEvent));
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | var ResolveEnd = (function (_super) {
|
270 | __extends(ResolveEnd, _super);
|
271 | function ResolveEnd(
|
272 | /** @docsNotRequired */
|
273 | id,
|
274 | /** @docsNotRequired */
|
275 | url,
|
276 | /** @docsNotRequired */
|
277 | urlAfterRedirects,
|
278 | /** @docsNotRequired */
|
279 | state) {
|
280 | var _this = _super.call(this, id, url) || this;
|
281 | _this.urlAfterRedirects = urlAfterRedirects;
|
282 | _this.state = state;
|
283 | return _this;
|
284 | }
|
285 | ResolveEnd.prototype.toString = function () {
|
286 | return "ResolveEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
|
287 | };
|
288 | return ResolveEnd;
|
289 | }(RouterEvent));
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | var RouteConfigLoadStart = (function () {
|
296 | function RouteConfigLoadStart(
|
297 | /** @docsNotRequired */
|
298 | route) {
|
299 | this.route = route;
|
300 | }
|
301 | RouteConfigLoadStart.prototype.toString = function () { return "RouteConfigLoadStart(path: " + this.route.path + ")"; };
|
302 | return RouteConfigLoadStart;
|
303 | }());
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 | var RouteConfigLoadEnd = (function () {
|
310 | function RouteConfigLoadEnd(
|
311 | /** @docsNotRequired */
|
312 | route) {
|
313 | this.route = route;
|
314 | }
|
315 | RouteConfigLoadEnd.prototype.toString = function () { return "RouteConfigLoadEnd(path: " + this.route.path + ")"; };
|
316 | return RouteConfigLoadEnd;
|
317 | }());
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 | var ChildActivationStart = (function () {
|
327 | function ChildActivationStart(
|
328 | /** @docsNotRequired */
|
329 | snapshot) {
|
330 | this.snapshot = snapshot;
|
331 | }
|
332 | ChildActivationStart.prototype.toString = function () {
|
333 | var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
334 | return "ChildActivationStart(path: '" + path + "')";
|
335 | };
|
336 | return ChildActivationStart;
|
337 | }());
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | var ChildActivationEnd = (function () {
|
346 | function ChildActivationEnd(
|
347 | /** @docsNotRequired */
|
348 | snapshot) {
|
349 | this.snapshot = snapshot;
|
350 | }
|
351 | ChildActivationEnd.prototype.toString = function () {
|
352 | var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
353 | return "ChildActivationEnd(path: '" + path + "')";
|
354 | };
|
355 | return ChildActivationEnd;
|
356 | }());
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | var ActivationStart = (function () {
|
366 | function ActivationStart(
|
367 | /** @docsNotRequired */
|
368 | snapshot) {
|
369 | this.snapshot = snapshot;
|
370 | }
|
371 | ActivationStart.prototype.toString = function () {
|
372 | var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
373 | return "ActivationStart(path: '" + path + "')";
|
374 | };
|
375 | return ActivationStart;
|
376 | }());
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 | var ActivationEnd = (function () {
|
386 | function ActivationEnd(
|
387 | /** @docsNotRequired */
|
388 | snapshot) {
|
389 | this.snapshot = snapshot;
|
390 | }
|
391 | ActivationEnd.prototype.toString = function () {
|
392 | var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
393 | return "ActivationEnd(path: '" + path + "')";
|
394 | };
|
395 | return ActivationEnd;
|
396 | }());
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 | var Scroll = (function () {
|
403 | function Scroll(
|
404 | /** @docsNotRequired */
|
405 | routerEvent,
|
406 | /** @docsNotRequired */
|
407 | position,
|
408 | /** @docsNotRequired */
|
409 | anchor) {
|
410 | this.routerEvent = routerEvent;
|
411 | this.position = position;
|
412 | this.anchor = anchor;
|
413 | }
|
414 | Scroll.prototype.toString = function () {
|
415 | var pos = this.position ? this.position[0] + ", " + this.position[1] : null;
|
416 | return "Scroll(anchor: '" + this.anchor + "', position: '" + pos + "')";
|
417 | };
|
418 | return Scroll;
|
419 | }());
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 | var ɵEmptyOutletComponent = (function () {
|
438 | function ɵEmptyOutletComponent() {
|
439 | }
|
440 | ɵEmptyOutletComponent = __decorate([
|
441 | Component({ template: "<router-outlet></router-outlet>" })
|
442 | ], ɵEmptyOutletComponent);
|
443 | return ɵEmptyOutletComponent;
|
444 | }());
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | var PRIMARY_OUTLET = 'primary';
|
459 | var ParamsAsMap = (function () {
|
460 | function ParamsAsMap(params) {
|
461 | this.params = params || {};
|
462 | }
|
463 | ParamsAsMap.prototype.has = function (name) { return this.params.hasOwnProperty(name); };
|
464 | ParamsAsMap.prototype.get = function (name) {
|
465 | if (this.has(name)) {
|
466 | var v = this.params[name];
|
467 | return Array.isArray(v) ? v[0] : v;
|
468 | }
|
469 | return null;
|
470 | };
|
471 | ParamsAsMap.prototype.getAll = function (name) {
|
472 | if (this.has(name)) {
|
473 | var v = this.params[name];
|
474 | return Array.isArray(v) ? v : [v];
|
475 | }
|
476 | return [];
|
477 | };
|
478 | Object.defineProperty(ParamsAsMap.prototype, "keys", {
|
479 | get: function () { return Object.keys(this.params); },
|
480 | enumerable: true,
|
481 | configurable: true
|
482 | });
|
483 | return ParamsAsMap;
|
484 | }());
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 | function convertToParamMap(params) {
|
493 | return new ParamsAsMap(params);
|
494 | }
|
495 | var NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
|
496 | function navigationCancelingError(message) {
|
497 | var error = Error('NavigationCancelingError: ' + message);
|
498 | error[NAVIGATION_CANCELING_ERROR] = true;
|
499 | return error;
|
500 | }
|
501 | function isNavigationCancelingError(error) {
|
502 | return error && error[NAVIGATION_CANCELING_ERROR];
|
503 | }
|
504 |
|
505 | function defaultUrlMatcher(segments, segmentGroup, route) {
|
506 | var parts = route.path.split('/');
|
507 | if (parts.length > segments.length) {
|
508 |
|
509 | return null;
|
510 | }
|
511 | if (route.pathMatch === 'full' &&
|
512 | (segmentGroup.hasChildren() || parts.length < segments.length)) {
|
513 |
|
514 | return null;
|
515 | }
|
516 | var posParams = {};
|
517 |
|
518 | for (var index = 0; index < parts.length; index++) {
|
519 | var part = parts[index];
|
520 | var segment = segments[index];
|
521 | var isParameter = part.startsWith(':');
|
522 | if (isParameter) {
|
523 | posParams[part.substring(1)] = segment;
|
524 | }
|
525 | else if (part !== segment.path) {
|
526 |
|
527 | return null;
|
528 | }
|
529 | }
|
530 | return { consumed: segments.slice(0, parts.length), posParams: posParams };
|
531 | }
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | var LoadedRouterConfig = (function () {
|
541 | function LoadedRouterConfig(routes, module) {
|
542 | this.routes = routes;
|
543 | this.module = module;
|
544 | }
|
545 | return LoadedRouterConfig;
|
546 | }());
|
547 | function validateConfig(config, parentPath) {
|
548 | if (parentPath === void 0) { parentPath = ''; }
|
549 |
|
550 | for (var i = 0; i < config.length; i++) {
|
551 | var route = config[i];
|
552 | var fullPath = getFullPath(parentPath, route);
|
553 | validateNode(route, fullPath);
|
554 | }
|
555 | }
|
556 | function validateNode(route, fullPath) {
|
557 | if (!route) {
|
558 | throw new Error("\n Invalid configuration of route '" + fullPath + "': Encountered undefined route.\n The reason might be an extra comma.\n\n Example:\n const routes: Routes = [\n { path: '', redirectTo: '/dashboard', pathMatch: 'full' },\n { path: 'dashboard', component: DashboardComponent },, << two commas\n { path: 'detail/:id', component: HeroDetailComponent }\n ];\n ");
|
559 | }
|
560 | if (Array.isArray(route)) {
|
561 | throw new Error("Invalid configuration of route '" + fullPath + "': Array cannot be specified");
|
562 | }
|
563 | if (!route.component && !route.children && !route.loadChildren &&
|
564 | (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
|
565 | throw new Error("Invalid configuration of route '" + fullPath + "': a componentless route without children or loadChildren cannot have a named outlet set");
|
566 | }
|
567 | if (route.redirectTo && route.children) {
|
568 | throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and children cannot be used together");
|
569 | }
|
570 | if (route.redirectTo && route.loadChildren) {
|
571 | throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and loadChildren cannot be used together");
|
572 | }
|
573 | if (route.children && route.loadChildren) {
|
574 | throw new Error("Invalid configuration of route '" + fullPath + "': children and loadChildren cannot be used together");
|
575 | }
|
576 | if (route.redirectTo && route.component) {
|
577 | throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and component cannot be used together");
|
578 | }
|
579 | if (route.path && route.matcher) {
|
580 | throw new Error("Invalid configuration of route '" + fullPath + "': path and matcher cannot be used together");
|
581 | }
|
582 | if (route.redirectTo === void 0 && !route.component && !route.children && !route.loadChildren) {
|
583 | throw new Error("Invalid configuration of route '" + fullPath + "'. One of the following must be provided: component, redirectTo, children or loadChildren");
|
584 | }
|
585 | if (route.path === void 0 && route.matcher === void 0) {
|
586 | throw new Error("Invalid configuration of route '" + fullPath + "': routes must have either a path or a matcher specified");
|
587 | }
|
588 | if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
|
589 | throw new Error("Invalid configuration of route '" + fullPath + "': path cannot start with a slash");
|
590 | }
|
591 | if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
|
592 | var exp = "The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.";
|
593 | throw new Error("Invalid configuration of route '{path: \"" + fullPath + "\", redirectTo: \"" + route.redirectTo + "\"}': please provide 'pathMatch'. " + exp);
|
594 | }
|
595 | if (route.pathMatch !== void 0 && route.pathMatch !== 'full' && route.pathMatch !== 'prefix') {
|
596 | throw new Error("Invalid configuration of route '" + fullPath + "': pathMatch can only be set to 'prefix' or 'full'");
|
597 | }
|
598 | if (route.children) {
|
599 | validateConfig(route.children, fullPath);
|
600 | }
|
601 | }
|
602 | function getFullPath(parentPath, currentRoute) {
|
603 | if (!currentRoute) {
|
604 | return parentPath;
|
605 | }
|
606 | if (!parentPath && !currentRoute.path) {
|
607 | return '';
|
608 | }
|
609 | else if (parentPath && !currentRoute.path) {
|
610 | return parentPath + "/";
|
611 | }
|
612 | else if (!parentPath && currentRoute.path) {
|
613 | return currentRoute.path;
|
614 | }
|
615 | else {
|
616 | return parentPath + "/" + currentRoute.path;
|
617 | }
|
618 | }
|
619 |
|
620 |
|
621 |
|
622 | function standardizeConfig(r) {
|
623 | var children = r.children && r.children.map(standardizeConfig);
|
624 | var c = children ? __assign(__assign({}, r), { children: children }) : __assign({}, r);
|
625 | if (!c.component && (children || c.loadChildren) && (c.outlet && c.outlet !== PRIMARY_OUTLET)) {
|
626 | c.component = ɵEmptyOutletComponent;
|
627 | }
|
628 | return c;
|
629 | }
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 | function shallowEqualArrays(a, b) {
|
639 | if (a.length !== b.length)
|
640 | return false;
|
641 | for (var i = 0; i < a.length; ++i) {
|
642 | if (!shallowEqual(a[i], b[i]))
|
643 | return false;
|
644 | }
|
645 | return true;
|
646 | }
|
647 | function shallowEqual(a, b) {
|
648 |
|
649 |
|
650 |
|
651 |
|
652 | var k1 = Object.keys(a);
|
653 | var k2 = Object.keys(b);
|
654 | if (!k1 || !k2 || k1.length != k2.length) {
|
655 | return false;
|
656 | }
|
657 | var key;
|
658 | for (var i = 0; i < k1.length; i++) {
|
659 | key = k1[i];
|
660 | if (!equalArraysOrString(a[key], b[key])) {
|
661 | return false;
|
662 | }
|
663 | }
|
664 | return true;
|
665 | }
|
666 |
|
667 |
|
668 |
|
669 | function equalArraysOrString(a, b) {
|
670 | if (Array.isArray(a) && Array.isArray(b)) {
|
671 | if (a.length != b.length)
|
672 | return false;
|
673 | return a.every(function (aItem) { return b.indexOf(aItem) > -1; });
|
674 | }
|
675 | else {
|
676 | return a === b;
|
677 | }
|
678 | }
|
679 |
|
680 |
|
681 |
|
682 | function flatten(arr) {
|
683 | return Array.prototype.concat.apply([], arr);
|
684 | }
|
685 |
|
686 |
|
687 |
|
688 | function last(a) {
|
689 | return a.length > 0 ? a[a.length - 1] : null;
|
690 | }
|
691 |
|
692 |
|
693 |
|
694 | function and(bools) {
|
695 | return !bools.some(function (v) { return !v; });
|
696 | }
|
697 | function forEach(map, callback) {
|
698 | for (var prop in map) {
|
699 | if (map.hasOwnProperty(prop)) {
|
700 | callback(map[prop], prop);
|
701 | }
|
702 | }
|
703 | }
|
704 | function waitForMap(obj, fn) {
|
705 | if (Object.keys(obj).length === 0) {
|
706 | return of({});
|
707 | }
|
708 | var waitHead = [];
|
709 | var waitTail = [];
|
710 | var res = {};
|
711 | forEach(obj, function (a, k) {
|
712 | var mapped = fn(k, a).pipe(map(function (r) { return res[k] = r; }));
|
713 | if (k === PRIMARY_OUTLET) {
|
714 | waitHead.push(mapped);
|
715 | }
|
716 | else {
|
717 | waitTail.push(mapped);
|
718 | }
|
719 | });
|
720 |
|
721 |
|
722 |
|
723 | return of.apply(null, waitHead.concat(waitTail))
|
724 | .pipe(concatAll(), last$1(), map(function () { return res; }));
|
725 | }
|
726 | function wrapIntoObservable(value) {
|
727 | if (ɵisObservable(value)) {
|
728 | return value;
|
729 | }
|
730 | if (ɵisPromise(value)) {
|
731 |
|
732 |
|
733 |
|
734 | return from(Promise.resolve(value));
|
735 | }
|
736 | return of(value);
|
737 | }
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 | function createEmptyUrlTree() {
|
747 | return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
|
748 | }
|
749 | function containsTree(container, containee, exact) {
|
750 | if (exact) {
|
751 | return equalQueryParams(container.queryParams, containee.queryParams) &&
|
752 | equalSegmentGroups(container.root, containee.root);
|
753 | }
|
754 | return containsQueryParams(container.queryParams, containee.queryParams) &&
|
755 | containsSegmentGroup(container.root, containee.root);
|
756 | }
|
757 | function equalQueryParams(container, containee) {
|
758 |
|
759 | return shallowEqual(container, containee);
|
760 | }
|
761 | function equalSegmentGroups(container, containee) {
|
762 | if (!equalPath(container.segments, containee.segments))
|
763 | return false;
|
764 | if (container.numberOfChildren !== containee.numberOfChildren)
|
765 | return false;
|
766 | for (var c in containee.children) {
|
767 | if (!container.children[c])
|
768 | return false;
|
769 | if (!equalSegmentGroups(container.children[c], containee.children[c]))
|
770 | return false;
|
771 | }
|
772 | return true;
|
773 | }
|
774 | function containsQueryParams(container, containee) {
|
775 |
|
776 | return Object.keys(containee).length <= Object.keys(container).length &&
|
777 | Object.keys(containee).every(function (key) { return equalArraysOrString(container[key], containee[key]); });
|
778 | }
|
779 | function containsSegmentGroup(container, containee) {
|
780 | return containsSegmentGroupHelper(container, containee, containee.segments);
|
781 | }
|
782 | function containsSegmentGroupHelper(container, containee, containeePaths) {
|
783 | if (container.segments.length > containeePaths.length) {
|
784 | var current = container.segments.slice(0, containeePaths.length);
|
785 | if (!equalPath(current, containeePaths))
|
786 | return false;
|
787 | if (containee.hasChildren())
|
788 | return false;
|
789 | return true;
|
790 | }
|
791 | else if (container.segments.length === containeePaths.length) {
|
792 | if (!equalPath(container.segments, containeePaths))
|
793 | return false;
|
794 | for (var c in containee.children) {
|
795 | if (!container.children[c])
|
796 | return false;
|
797 | if (!containsSegmentGroup(container.children[c], containee.children[c]))
|
798 | return false;
|
799 | }
|
800 | return true;
|
801 | }
|
802 | else {
|
803 | var current = containeePaths.slice(0, container.segments.length);
|
804 | var next = containeePaths.slice(container.segments.length);
|
805 | if (!equalPath(container.segments, current))
|
806 | return false;
|
807 | if (!container.children[PRIMARY_OUTLET])
|
808 | return false;
|
809 | return containsSegmentGroupHelper(container.children[PRIMARY_OUTLET], containee, next);
|
810 | }
|
811 | }
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 | var UrlTree = (function () {
|
843 |
|
844 | function UrlTree(
|
845 | /** The root segment group of the URL tree */
|
846 | root,
|
847 | /** The query params of the URL */
|
848 | queryParams,
|
849 | /** The fragment of the URL */
|
850 | fragment) {
|
851 | this.root = root;
|
852 | this.queryParams = queryParams;
|
853 | this.fragment = fragment;
|
854 | }
|
855 | Object.defineProperty(UrlTree.prototype, "queryParamMap", {
|
856 | get: function () {
|
857 | if (!this._queryParamMap) {
|
858 | this._queryParamMap = convertToParamMap(this.queryParams);
|
859 | }
|
860 | return this._queryParamMap;
|
861 | },
|
862 | enumerable: true,
|
863 | configurable: true
|
864 | });
|
865 |
|
866 | UrlTree.prototype.toString = function () { return DEFAULT_SERIALIZER.serialize(this); };
|
867 | return UrlTree;
|
868 | }());
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 | var UrlSegmentGroup = (function () {
|
879 | function UrlSegmentGroup(
|
880 | /** The URL segments of this group. See `UrlSegment` for more information */
|
881 | segments,
|
882 | /** The list of children of this group */
|
883 | children) {
|
884 | var _this = this;
|
885 | this.segments = segments;
|
886 | this.children = children;
|
887 |
|
888 | this.parent = null;
|
889 | forEach(children, function (v, k) { return v.parent = _this; });
|
890 | }
|
891 |
|
892 | UrlSegmentGroup.prototype.hasChildren = function () { return this.numberOfChildren > 0; };
|
893 | Object.defineProperty(UrlSegmentGroup.prototype, "numberOfChildren", {
|
894 |
|
895 | get: function () { return Object.keys(this.children).length; },
|
896 | enumerable: true,
|
897 | configurable: true
|
898 | });
|
899 |
|
900 | UrlSegmentGroup.prototype.toString = function () { return serializePaths(this); };
|
901 | return UrlSegmentGroup;
|
902 | }());
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 | var UrlSegment = (function () {
|
930 | function UrlSegment(
|
931 | /** The path part of a URL segment */
|
932 | path,
|
933 | /** The matrix parameters associated with a segment */
|
934 | parameters) {
|
935 | this.path = path;
|
936 | this.parameters = parameters;
|
937 | }
|
938 | Object.defineProperty(UrlSegment.prototype, "parameterMap", {
|
939 | get: function () {
|
940 | if (!this._parameterMap) {
|
941 | this._parameterMap = convertToParamMap(this.parameters);
|
942 | }
|
943 | return this._parameterMap;
|
944 | },
|
945 | enumerable: true,
|
946 | configurable: true
|
947 | });
|
948 |
|
949 | UrlSegment.prototype.toString = function () { return serializePath(this); };
|
950 | return UrlSegment;
|
951 | }());
|
952 | function equalSegments(as, bs) {
|
953 | return equalPath(as, bs) && as.every(function (a, i) { return shallowEqual(a.parameters, bs[i].parameters); });
|
954 | }
|
955 | function equalPath(as, bs) {
|
956 | if (as.length !== bs.length)
|
957 | return false;
|
958 | return as.every(function (a, i) { return a.path === bs[i].path; });
|
959 | }
|
960 | function mapChildrenIntoArray(segment, fn) {
|
961 | var res = [];
|
962 | forEach(segment.children, function (child, childOutlet) {
|
963 | if (childOutlet === PRIMARY_OUTLET) {
|
964 | res = res.concat(fn(child, childOutlet));
|
965 | }
|
966 | });
|
967 | forEach(segment.children, function (child, childOutlet) {
|
968 | if (childOutlet !== PRIMARY_OUTLET) {
|
969 | res = res.concat(fn(child, childOutlet));
|
970 | }
|
971 | });
|
972 | return res;
|
973 | }
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 | var UrlSerializer = (function () {
|
987 | function UrlSerializer() {
|
988 | }
|
989 | return UrlSerializer;
|
990 | }());
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 | var DefaultUrlSerializer = (function () {
|
1010 | function DefaultUrlSerializer() {
|
1011 | }
|
1012 |
|
1013 | DefaultUrlSerializer.prototype.parse = function (url) {
|
1014 | var p = new UrlParser(url);
|
1015 | return new UrlTree(p.parseRootSegment(), p.parseQueryParams(), p.parseFragment());
|
1016 | };
|
1017 |
|
1018 | DefaultUrlSerializer.prototype.serialize = function (tree) {
|
1019 | var segment = "/" + serializeSegment(tree.root, true);
|
1020 | var query = serializeQueryParams(tree.queryParams);
|
1021 | var fragment = typeof tree.fragment === "string" ? "#" + encodeUriFragment(tree.fragment) : '';
|
1022 | return "" + segment + query + fragment;
|
1023 | };
|
1024 | return DefaultUrlSerializer;
|
1025 | }());
|
1026 | var DEFAULT_SERIALIZER = new DefaultUrlSerializer();
|
1027 | function serializePaths(segment) {
|
1028 | return segment.segments.map(function (p) { return serializePath(p); }).join('/');
|
1029 | }
|
1030 | function serializeSegment(segment, root) {
|
1031 | if (!segment.hasChildren()) {
|
1032 | return serializePaths(segment);
|
1033 | }
|
1034 | if (root) {
|
1035 | var primary = segment.children[PRIMARY_OUTLET] ?
|
1036 | serializeSegment(segment.children[PRIMARY_OUTLET], false) :
|
1037 | '';
|
1038 | var children_1 = [];
|
1039 | forEach(segment.children, function (v, k) {
|
1040 | if (k !== PRIMARY_OUTLET) {
|
1041 | children_1.push(k + ":" + serializeSegment(v, false));
|
1042 | }
|
1043 | });
|
1044 | return children_1.length > 0 ? primary + "(" + children_1.join('//') + ")" : primary;
|
1045 | }
|
1046 | else {
|
1047 | var children = mapChildrenIntoArray(segment, function (v, k) {
|
1048 | if (k === PRIMARY_OUTLET) {
|
1049 | return [serializeSegment(segment.children[PRIMARY_OUTLET], false)];
|
1050 | }
|
1051 | return [k + ":" + serializeSegment(v, false)];
|
1052 | });
|
1053 | return serializePaths(segment) + "/(" + children.join('//') + ")";
|
1054 | }
|
1055 | }
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 | function encodeUriString(s) {
|
1063 | return encodeURIComponent(s)
|
1064 | .replace(/%40/g, '@')
|
1065 | .replace(/%3A/gi, ':')
|
1066 | .replace(/%24/g, '$')
|
1067 | .replace(/%2C/gi, ',');
|
1068 | }
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 | function encodeUriQuery(s) {
|
1076 | return encodeUriString(s).replace(/%3B/gi, ';');
|
1077 | }
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 | function encodeUriFragment(s) {
|
1085 | return encodeURI(s);
|
1086 | }
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 | function encodeUriSegment(s) {
|
1095 | return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
|
1096 | }
|
1097 | function decode(s) {
|
1098 | return decodeURIComponent(s);
|
1099 | }
|
1100 |
|
1101 |
|
1102 | function decodeQuery(s) {
|
1103 | return decode(s.replace(/\+/g, '%20'));
|
1104 | }
|
1105 | function serializePath(path) {
|
1106 | return "" + encodeUriSegment(path.path) + serializeMatrixParams(path.parameters);
|
1107 | }
|
1108 | function serializeMatrixParams(params) {
|
1109 | return Object.keys(params)
|
1110 | .map(function (key) { return ";" + encodeUriSegment(key) + "=" + encodeUriSegment(params[key]); })
|
1111 | .join('');
|
1112 | }
|
1113 | function serializeQueryParams(params) {
|
1114 | var strParams = Object.keys(params).map(function (name) {
|
1115 | var value = params[name];
|
1116 | return Array.isArray(value) ?
|
1117 | value.map(function (v) { return encodeUriQuery(name) + "=" + encodeUriQuery(v); }).join('&') :
|
1118 | encodeUriQuery(name) + "=" + encodeUriQuery(value);
|
1119 | });
|
1120 | return strParams.length ? "?" + strParams.join("&") : '';
|
1121 | }
|
1122 | var SEGMENT_RE = /^[^\/()?;=#]+/;
|
1123 | function matchSegments(str) {
|
1124 | var match = str.match(SEGMENT_RE);
|
1125 | return match ? match[0] : '';
|
1126 | }
|
1127 | var QUERY_PARAM_RE = /^[^=?&#]+/;
|
1128 |
|
1129 | function matchQueryParams(str) {
|
1130 | var match = str.match(QUERY_PARAM_RE);
|
1131 | return match ? match[0] : '';
|
1132 | }
|
1133 | var QUERY_PARAM_VALUE_RE = /^[^?&#]+/;
|
1134 |
|
1135 | function matchUrlQueryParamValue(str) {
|
1136 | var match = str.match(QUERY_PARAM_VALUE_RE);
|
1137 | return match ? match[0] : '';
|
1138 | }
|
1139 | var UrlParser = (function () {
|
1140 | function UrlParser(url) {
|
1141 | this.url = url;
|
1142 | this.remaining = url;
|
1143 | }
|
1144 | UrlParser.prototype.parseRootSegment = function () {
|
1145 | this.consumeOptional('/');
|
1146 | if (this.remaining === '' || this.peekStartsWith('?') || this.peekStartsWith('#')) {
|
1147 | return new UrlSegmentGroup([], {});
|
1148 | }
|
1149 |
|
1150 | return new UrlSegmentGroup([], this.parseChildren());
|
1151 | };
|
1152 | UrlParser.prototype.parseQueryParams = function () {
|
1153 | var params = {};
|
1154 | if (this.consumeOptional('?')) {
|
1155 | do {
|
1156 | this.parseQueryParam(params);
|
1157 | } while (this.consumeOptional('&'));
|
1158 | }
|
1159 | return params;
|
1160 | };
|
1161 | UrlParser.prototype.parseFragment = function () {
|
1162 | return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
|
1163 | };
|
1164 | UrlParser.prototype.parseChildren = function () {
|
1165 | if (this.remaining === '') {
|
1166 | return {};
|
1167 | }
|
1168 | this.consumeOptional('/');
|
1169 | var segments = [];
|
1170 | if (!this.peekStartsWith('(')) {
|
1171 | segments.push(this.parseSegment());
|
1172 | }
|
1173 | while (this.peekStartsWith('/') && !this.peekStartsWith('//') && !this.peekStartsWith('/(')) {
|
1174 | this.capture('/');
|
1175 | segments.push(this.parseSegment());
|
1176 | }
|
1177 | var children = {};
|
1178 | if (this.peekStartsWith('/(')) {
|
1179 | this.capture('/');
|
1180 | children = this.parseParens(true);
|
1181 | }
|
1182 | var res = {};
|
1183 | if (this.peekStartsWith('(')) {
|
1184 | res = this.parseParens(false);
|
1185 | }
|
1186 | if (segments.length > 0 || Object.keys(children).length > 0) {
|
1187 | res[PRIMARY_OUTLET] = new UrlSegmentGroup(segments, children);
|
1188 | }
|
1189 | return res;
|
1190 | };
|
1191 |
|
1192 |
|
1193 | UrlParser.prototype.parseSegment = function () {
|
1194 | var path = matchSegments(this.remaining);
|
1195 | if (path === '' && this.peekStartsWith(';')) {
|
1196 | throw new Error("Empty path url segment cannot have parameters: '" + this.remaining + "'.");
|
1197 | }
|
1198 | this.capture(path);
|
1199 | return new UrlSegment(decode(path), this.parseMatrixParams());
|
1200 | };
|
1201 | UrlParser.prototype.parseMatrixParams = function () {
|
1202 | var params = {};
|
1203 | while (this.consumeOptional(';')) {
|
1204 | this.parseParam(params);
|
1205 | }
|
1206 | return params;
|
1207 | };
|
1208 | UrlParser.prototype.parseParam = function (params) {
|
1209 | var key = matchSegments(this.remaining);
|
1210 | if (!key) {
|
1211 | return;
|
1212 | }
|
1213 | this.capture(key);
|
1214 | var value = '';
|
1215 | if (this.consumeOptional('=')) {
|
1216 | var valueMatch = matchSegments(this.remaining);
|
1217 | if (valueMatch) {
|
1218 | value = valueMatch;
|
1219 | this.capture(value);
|
1220 | }
|
1221 | }
|
1222 | params[decode(key)] = decode(value);
|
1223 | };
|
1224 |
|
1225 | UrlParser.prototype.parseQueryParam = function (params) {
|
1226 | var key = matchQueryParams(this.remaining);
|
1227 | if (!key) {
|
1228 | return;
|
1229 | }
|
1230 | this.capture(key);
|
1231 | var value = '';
|
1232 | if (this.consumeOptional('=')) {
|
1233 | var valueMatch = matchUrlQueryParamValue(this.remaining);
|
1234 | if (valueMatch) {
|
1235 | value = valueMatch;
|
1236 | this.capture(value);
|
1237 | }
|
1238 | }
|
1239 | var decodedKey = decodeQuery(key);
|
1240 | var decodedVal = decodeQuery(value);
|
1241 | if (params.hasOwnProperty(decodedKey)) {
|
1242 |
|
1243 | var currentVal = params[decodedKey];
|
1244 | if (!Array.isArray(currentVal)) {
|
1245 | currentVal = [currentVal];
|
1246 | params[decodedKey] = currentVal;
|
1247 | }
|
1248 | currentVal.push(decodedVal);
|
1249 | }
|
1250 | else {
|
1251 |
|
1252 | params[decodedKey] = decodedVal;
|
1253 | }
|
1254 | };
|
1255 |
|
1256 | UrlParser.prototype.parseParens = function (allowPrimary) {
|
1257 | var segments = {};
|
1258 | this.capture('(');
|
1259 | while (!this.consumeOptional(')') && this.remaining.length > 0) {
|
1260 | var path = matchSegments(this.remaining);
|
1261 | var next = this.remaining[path.length];
|
1262 |
|
1263 |
|
1264 | if (next !== '/' && next !== ')' && next !== ';') {
|
1265 | throw new Error("Cannot parse url '" + this.url + "'");
|
1266 | }
|
1267 | var outletName = undefined;
|
1268 | if (path.indexOf(':') > -1) {
|
1269 | outletName = path.substr(0, path.indexOf(':'));
|
1270 | this.capture(outletName);
|
1271 | this.capture(':');
|
1272 | }
|
1273 | else if (allowPrimary) {
|
1274 | outletName = PRIMARY_OUTLET;
|
1275 | }
|
1276 | var children = this.parseChildren();
|
1277 | segments[outletName] = Object.keys(children).length === 1 ? children[PRIMARY_OUTLET] :
|
1278 | new UrlSegmentGroup([], children);
|
1279 | this.consumeOptional('//');
|
1280 | }
|
1281 | return segments;
|
1282 | };
|
1283 | UrlParser.prototype.peekStartsWith = function (str) { return this.remaining.startsWith(str); };
|
1284 |
|
1285 | UrlParser.prototype.consumeOptional = function (str) {
|
1286 | if (this.peekStartsWith(str)) {
|
1287 | this.remaining = this.remaining.substring(str.length);
|
1288 | return true;
|
1289 | }
|
1290 | return false;
|
1291 | };
|
1292 | UrlParser.prototype.capture = function (str) {
|
1293 | if (!this.consumeOptional(str)) {
|
1294 | throw new Error("Expected \"" + str + "\".");
|
1295 | }
|
1296 | };
|
1297 | return UrlParser;
|
1298 | }());
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 | var Tree = (function () {
|
1308 | function Tree(root) {
|
1309 | this._root = root;
|
1310 | }
|
1311 | Object.defineProperty(Tree.prototype, "root", {
|
1312 | get: function () { return this._root.value; },
|
1313 | enumerable: true,
|
1314 | configurable: true
|
1315 | });
|
1316 | |
1317 |
|
1318 |
|
1319 | Tree.prototype.parent = function (t) {
|
1320 | var p = this.pathFromRoot(t);
|
1321 | return p.length > 1 ? p[p.length - 2] : null;
|
1322 | };
|
1323 | |
1324 |
|
1325 |
|
1326 | Tree.prototype.children = function (t) {
|
1327 | var n = findNode(t, this._root);
|
1328 | return n ? n.children.map(function (t) { return t.value; }) : [];
|
1329 | };
|
1330 | |
1331 |
|
1332 |
|
1333 | Tree.prototype.firstChild = function (t) {
|
1334 | var n = findNode(t, this._root);
|
1335 | return n && n.children.length > 0 ? n.children[0].value : null;
|
1336 | };
|
1337 | |
1338 |
|
1339 |
|
1340 | Tree.prototype.siblings = function (t) {
|
1341 | var p = findPath(t, this._root);
|
1342 | if (p.length < 2)
|
1343 | return [];
|
1344 | var c = p[p.length - 2].children.map(function (c) { return c.value; });
|
1345 | return c.filter(function (cc) { return cc !== t; });
|
1346 | };
|
1347 | |
1348 |
|
1349 |
|
1350 | Tree.prototype.pathFromRoot = function (t) { return findPath(t, this._root).map(function (s) { return s.value; }); };
|
1351 | return Tree;
|
1352 | }());
|
1353 |
|
1354 | function findNode(value, node) {
|
1355 | var e_1, _a;
|
1356 | if (value === node.value)
|
1357 | return node;
|
1358 | try {
|
1359 | for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
1360 | var child = _c.value;
|
1361 | var node_1 = findNode(value, child);
|
1362 | if (node_1)
|
1363 | return node_1;
|
1364 | }
|
1365 | }
|
1366 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
1367 | finally {
|
1368 | try {
|
1369 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
1370 | }
|
1371 | finally { if (e_1) throw e_1.error; }
|
1372 | }
|
1373 | return null;
|
1374 | }
|
1375 |
|
1376 | function findPath(value, node) {
|
1377 | var e_2, _a;
|
1378 | if (value === node.value)
|
1379 | return [node];
|
1380 | try {
|
1381 | for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
1382 | var child = _c.value;
|
1383 | var path = findPath(value, child);
|
1384 | if (path.length) {
|
1385 | path.unshift(node);
|
1386 | return path;
|
1387 | }
|
1388 | }
|
1389 | }
|
1390 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
1391 | finally {
|
1392 | try {
|
1393 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
1394 | }
|
1395 | finally { if (e_2) throw e_2.error; }
|
1396 | }
|
1397 | return [];
|
1398 | }
|
1399 | var TreeNode = (function () {
|
1400 | function TreeNode(value, children) {
|
1401 | this.value = value;
|
1402 | this.children = children;
|
1403 | }
|
1404 | TreeNode.prototype.toString = function () { return "TreeNode(" + this.value + ")"; };
|
1405 | return TreeNode;
|
1406 | }());
|
1407 |
|
1408 | function nodeChildrenAsMap(node) {
|
1409 | var map = {};
|
1410 | if (node) {
|
1411 | node.children.forEach(function (child) { return map[child.value.outlet] = child; });
|
1412 | }
|
1413 | return map;
|
1414 | }
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 | var RouterState = (function (_super) {
|
1453 | __extends(RouterState, _super);
|
1454 |
|
1455 | function RouterState(root,
|
1456 | /** The current snapshot of the router state */
|
1457 | snapshot) {
|
1458 | var _this = _super.call(this, root) || this;
|
1459 | _this.snapshot = snapshot;
|
1460 | setRouterState(_this, root);
|
1461 | return _this;
|
1462 | }
|
1463 | RouterState.prototype.toString = function () { return this.snapshot.toString(); };
|
1464 | return RouterState;
|
1465 | }(Tree));
|
1466 | function createEmptyState(urlTree, rootComponent) {
|
1467 | var snapshot = createEmptyStateSnapshot(urlTree, rootComponent);
|
1468 | var emptyUrl = new BehaviorSubject([new UrlSegment('', {})]);
|
1469 | var emptyParams = new BehaviorSubject({});
|
1470 | var emptyData = new BehaviorSubject({});
|
1471 | var emptyQueryParams = new BehaviorSubject({});
|
1472 | var fragment = new BehaviorSubject('');
|
1473 | var activated = new ActivatedRoute(emptyUrl, emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, snapshot.root);
|
1474 | activated.snapshot = snapshot.root;
|
1475 | return new RouterState(new TreeNode(activated, []), snapshot);
|
1476 | }
|
1477 | function createEmptyStateSnapshot(urlTree, rootComponent) {
|
1478 | var emptyParams = {};
|
1479 | var emptyData = {};
|
1480 | var emptyQueryParams = {};
|
1481 | var fragment = '';
|
1482 | var activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, urlTree.root, -1, {});
|
1483 | return new RouterStateSnapshot('', new TreeNode(activated, []));
|
1484 | }
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 | var ActivatedRoute = (function () {
|
1496 |
|
1497 | function ActivatedRoute(
|
1498 | /** An observable of the URL segments matched by this route. */
|
1499 | url,
|
1500 | /** An observable of the matrix parameters scoped to this route. */
|
1501 | params,
|
1502 | /** An observable of the query parameters shared by all the routes. */
|
1503 | queryParams,
|
1504 | /** An observable of the URL fragment shared by all the routes. */
|
1505 | fragment,
|
1506 | /** An observable of the static and resolved data of this route. */
|
1507 | data,
|
1508 | /** The outlet name of the route, a constant. */
|
1509 | outlet,
|
1510 | /** The component of the route, a constant. */
|
1511 | // TODO(vsavkin): remove |string
|
1512 | component, futureSnapshot) {
|
1513 | this.url = url;
|
1514 | this.params = params;
|
1515 | this.queryParams = queryParams;
|
1516 | this.fragment = fragment;
|
1517 | this.data = data;
|
1518 | this.outlet = outlet;
|
1519 | this.component = component;
|
1520 | this._futureSnapshot = futureSnapshot;
|
1521 | }
|
1522 | Object.defineProperty(ActivatedRoute.prototype, "routeConfig", {
|
1523 |
|
1524 | get: function () { return this._futureSnapshot.routeConfig; },
|
1525 | enumerable: true,
|
1526 | configurable: true
|
1527 | });
|
1528 | Object.defineProperty(ActivatedRoute.prototype, "root", {
|
1529 |
|
1530 | get: function () { return this._routerState.root; },
|
1531 | enumerable: true,
|
1532 | configurable: true
|
1533 | });
|
1534 | Object.defineProperty(ActivatedRoute.prototype, "parent", {
|
1535 |
|
1536 | get: function () { return this._routerState.parent(this); },
|
1537 | enumerable: true,
|
1538 | configurable: true
|
1539 | });
|
1540 | Object.defineProperty(ActivatedRoute.prototype, "firstChild", {
|
1541 |
|
1542 | get: function () { return this._routerState.firstChild(this); },
|
1543 | enumerable: true,
|
1544 | configurable: true
|
1545 | });
|
1546 | Object.defineProperty(ActivatedRoute.prototype, "children", {
|
1547 |
|
1548 | get: function () { return this._routerState.children(this); },
|
1549 | enumerable: true,
|
1550 | configurable: true
|
1551 | });
|
1552 | Object.defineProperty(ActivatedRoute.prototype, "pathFromRoot", {
|
1553 |
|
1554 | get: function () { return this._routerState.pathFromRoot(this); },
|
1555 | enumerable: true,
|
1556 | configurable: true
|
1557 | });
|
1558 | Object.defineProperty(ActivatedRoute.prototype, "paramMap", {
|
1559 | |
1560 |
|
1561 |
|
1562 | get: function () {
|
1563 | if (!this._paramMap) {
|
1564 | this._paramMap = this.params.pipe(map(function (p) { return convertToParamMap(p); }));
|
1565 | }
|
1566 | return this._paramMap;
|
1567 | },
|
1568 | enumerable: true,
|
1569 | configurable: true
|
1570 | });
|
1571 | Object.defineProperty(ActivatedRoute.prototype, "queryParamMap", {
|
1572 | |
1573 |
|
1574 |
|
1575 |
|
1576 | get: function () {
|
1577 | if (!this._queryParamMap) {
|
1578 | this._queryParamMap =
|
1579 | this.queryParams.pipe(map(function (p) { return convertToParamMap(p); }));
|
1580 | }
|
1581 | return this._queryParamMap;
|
1582 | },
|
1583 | enumerable: true,
|
1584 | configurable: true
|
1585 | });
|
1586 | ActivatedRoute.prototype.toString = function () {
|
1587 | return this.snapshot ? this.snapshot.toString() : "Future(" + this._futureSnapshot + ")";
|
1588 | };
|
1589 | return ActivatedRoute;
|
1590 | }());
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 | function inheritedParamsDataResolve(route, paramsInheritanceStrategy) {
|
1597 | if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
|
1598 | var pathFromRoot = route.pathFromRoot;
|
1599 | var inheritingStartingFrom = 0;
|
1600 | if (paramsInheritanceStrategy !== 'always') {
|
1601 | inheritingStartingFrom = pathFromRoot.length - 1;
|
1602 | while (inheritingStartingFrom >= 1) {
|
1603 | var current = pathFromRoot[inheritingStartingFrom];
|
1604 | var parent_1 = pathFromRoot[inheritingStartingFrom - 1];
|
1605 |
|
1606 | if (current.routeConfig && current.routeConfig.path === '') {
|
1607 | inheritingStartingFrom--;
|
1608 |
|
1609 | }
|
1610 | else if (!parent_1.component) {
|
1611 | inheritingStartingFrom--;
|
1612 | }
|
1613 | else {
|
1614 | break;
|
1615 | }
|
1616 | }
|
1617 | }
|
1618 | return flattenInherited(pathFromRoot.slice(inheritingStartingFrom));
|
1619 | }
|
1620 |
|
1621 | function flattenInherited(pathFromRoot) {
|
1622 | return pathFromRoot.reduce(function (res, curr) {
|
1623 | var params = __assign(__assign({}, res.params), curr.params);
|
1624 | var data = __assign(__assign({}, res.data), curr.data);
|
1625 | var resolve = __assign(__assign({}, res.resolve), curr._resolvedData);
|
1626 | return { params: params, data: data, resolve: resolve };
|
1627 | }, { params: {}, data: {}, resolve: {} });
|
1628 | }
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 |
|
1649 | var ActivatedRouteSnapshot = (function () {
|
1650 |
|
1651 | function ActivatedRouteSnapshot(
|
1652 | /** The URL segments matched by this route */
|
1653 | url,
|
1654 | /** The matrix parameters scoped to this route */
|
1655 | params,
|
1656 | /** The query parameters shared by all the routes */
|
1657 | queryParams,
|
1658 | /** The URL fragment shared by all the routes */
|
1659 | fragment,
|
1660 | /** The static and resolved data of this route */
|
1661 | data,
|
1662 | /** The outlet name of the route */
|
1663 | outlet,
|
1664 | /** The component of the route */
|
1665 | component, routeConfig, urlSegment, lastPathIndex, resolve) {
|
1666 | this.url = url;
|
1667 | this.params = params;
|
1668 | this.queryParams = queryParams;
|
1669 | this.fragment = fragment;
|
1670 | this.data = data;
|
1671 | this.outlet = outlet;
|
1672 | this.component = component;
|
1673 | this.routeConfig = routeConfig;
|
1674 | this._urlSegment = urlSegment;
|
1675 | this._lastPathIndex = lastPathIndex;
|
1676 | this._resolve = resolve;
|
1677 | }
|
1678 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "root", {
|
1679 |
|
1680 | get: function () { return this._routerState.root; },
|
1681 | enumerable: true,
|
1682 | configurable: true
|
1683 | });
|
1684 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "parent", {
|
1685 |
|
1686 | get: function () { return this._routerState.parent(this); },
|
1687 | enumerable: true,
|
1688 | configurable: true
|
1689 | });
|
1690 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "firstChild", {
|
1691 |
|
1692 | get: function () { return this._routerState.firstChild(this); },
|
1693 | enumerable: true,
|
1694 | configurable: true
|
1695 | });
|
1696 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "children", {
|
1697 |
|
1698 | get: function () { return this._routerState.children(this); },
|
1699 | enumerable: true,
|
1700 | configurable: true
|
1701 | });
|
1702 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "pathFromRoot", {
|
1703 |
|
1704 | get: function () { return this._routerState.pathFromRoot(this); },
|
1705 | enumerable: true,
|
1706 | configurable: true
|
1707 | });
|
1708 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "paramMap", {
|
1709 | get: function () {
|
1710 | if (!this._paramMap) {
|
1711 | this._paramMap = convertToParamMap(this.params);
|
1712 | }
|
1713 | return this._paramMap;
|
1714 | },
|
1715 | enumerable: true,
|
1716 | configurable: true
|
1717 | });
|
1718 | Object.defineProperty(ActivatedRouteSnapshot.prototype, "queryParamMap", {
|
1719 | get: function () {
|
1720 | if (!this._queryParamMap) {
|
1721 | this._queryParamMap = convertToParamMap(this.queryParams);
|
1722 | }
|
1723 | return this._queryParamMap;
|
1724 | },
|
1725 | enumerable: true,
|
1726 | configurable: true
|
1727 | });
|
1728 | ActivatedRouteSnapshot.prototype.toString = function () {
|
1729 | var url = this.url.map(function (segment) { return segment.toString(); }).join('/');
|
1730 | var matched = this.routeConfig ? this.routeConfig.path : '';
|
1731 | return "Route(url:'" + url + "', path:'" + matched + "')";
|
1732 | };
|
1733 | return ActivatedRouteSnapshot;
|
1734 | }());
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 | var RouterStateSnapshot = (function (_super) {
|
1763 | __extends(RouterStateSnapshot, _super);
|
1764 |
|
1765 | function RouterStateSnapshot(
|
1766 | /** The url from which this snapshot was created */
|
1767 | url, root) {
|
1768 | var _this = _super.call(this, root) || this;
|
1769 | _this.url = url;
|
1770 | setRouterState(_this, root);
|
1771 | return _this;
|
1772 | }
|
1773 | RouterStateSnapshot.prototype.toString = function () { return serializeNode(this._root); };
|
1774 | return RouterStateSnapshot;
|
1775 | }(Tree));
|
1776 | function setRouterState(state, node) {
|
1777 | node.value._routerState = state;
|
1778 | node.children.forEach(function (c) { return setRouterState(state, c); });
|
1779 | }
|
1780 | function serializeNode(node) {
|
1781 | var c = node.children.length > 0 ? " { " + node.children.map(serializeNode).join(', ') + " } " : '';
|
1782 | return "" + node.value + c;
|
1783 | }
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 | function advanceActivatedRoute(route) {
|
1790 | if (route.snapshot) {
|
1791 | var currentSnapshot = route.snapshot;
|
1792 | var nextSnapshot = route._futureSnapshot;
|
1793 | route.snapshot = nextSnapshot;
|
1794 | if (!shallowEqual(currentSnapshot.queryParams, nextSnapshot.queryParams)) {
|
1795 | route.queryParams.next(nextSnapshot.queryParams);
|
1796 | }
|
1797 | if (currentSnapshot.fragment !== nextSnapshot.fragment) {
|
1798 | route.fragment.next(nextSnapshot.fragment);
|
1799 | }
|
1800 | if (!shallowEqual(currentSnapshot.params, nextSnapshot.params)) {
|
1801 | route.params.next(nextSnapshot.params);
|
1802 | }
|
1803 | if (!shallowEqualArrays(currentSnapshot.url, nextSnapshot.url)) {
|
1804 | route.url.next(nextSnapshot.url);
|
1805 | }
|
1806 | if (!shallowEqual(currentSnapshot.data, nextSnapshot.data)) {
|
1807 | route.data.next(nextSnapshot.data);
|
1808 | }
|
1809 | }
|
1810 | else {
|
1811 | route.snapshot = route._futureSnapshot;
|
1812 |
|
1813 | route.data.next(route._futureSnapshot.data);
|
1814 | }
|
1815 | }
|
1816 | function equalParamsAndUrlSegments(a, b) {
|
1817 | var equalUrlParams = shallowEqual(a.params, b.params) && equalSegments(a.url, b.url);
|
1818 | var parentsMismatch = !a.parent !== !b.parent;
|
1819 | return equalUrlParams && !parentsMismatch &&
|
1820 | (!a.parent || equalParamsAndUrlSegments(a.parent, b.parent));
|
1821 | }
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 | function createRouterState(routeReuseStrategy, curr, prevState) {
|
1831 | var root = createNode(routeReuseStrategy, curr._root, prevState ? prevState._root : undefined);
|
1832 | return new RouterState(root, curr);
|
1833 | }
|
1834 | function createNode(routeReuseStrategy, curr, prevState) {
|
1835 |
|
1836 | if (prevState && routeReuseStrategy.shouldReuseRoute(curr.value, prevState.value.snapshot)) {
|
1837 | var value = prevState.value;
|
1838 | value._futureSnapshot = curr.value;
|
1839 | var children = createOrReuseChildren(routeReuseStrategy, curr, prevState);
|
1840 | return new TreeNode(value, children);
|
1841 |
|
1842 | }
|
1843 | else {
|
1844 | var detachedRouteHandle = routeReuseStrategy.retrieve(curr.value);
|
1845 | if (detachedRouteHandle) {
|
1846 | var tree = detachedRouteHandle.route;
|
1847 | setFutureSnapshotsOfActivatedRoutes(curr, tree);
|
1848 | return tree;
|
1849 | }
|
1850 | else {
|
1851 | var value = createActivatedRoute(curr.value);
|
1852 | var children = curr.children.map(function (c) { return createNode(routeReuseStrategy, c); });
|
1853 | return new TreeNode(value, children);
|
1854 | }
|
1855 | }
|
1856 | }
|
1857 | function setFutureSnapshotsOfActivatedRoutes(curr, result) {
|
1858 | if (curr.value.routeConfig !== result.value.routeConfig) {
|
1859 | throw new Error('Cannot reattach ActivatedRouteSnapshot created from a different route');
|
1860 | }
|
1861 | if (curr.children.length !== result.children.length) {
|
1862 | throw new Error('Cannot reattach ActivatedRouteSnapshot with a different number of children');
|
1863 | }
|
1864 | result.value._futureSnapshot = curr.value;
|
1865 | for (var i = 0; i < curr.children.length; ++i) {
|
1866 | setFutureSnapshotsOfActivatedRoutes(curr.children[i], result.children[i]);
|
1867 | }
|
1868 | }
|
1869 | function createOrReuseChildren(routeReuseStrategy, curr, prevState) {
|
1870 | return curr.children.map(function (child) {
|
1871 | var e_1, _a;
|
1872 | try {
|
1873 | for (var _b = __values(prevState.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
1874 | var p = _c.value;
|
1875 | if (routeReuseStrategy.shouldReuseRoute(p.value.snapshot, child.value)) {
|
1876 | return createNode(routeReuseStrategy, child, p);
|
1877 | }
|
1878 | }
|
1879 | }
|
1880 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
1881 | finally {
|
1882 | try {
|
1883 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
1884 | }
|
1885 | finally { if (e_1) throw e_1.error; }
|
1886 | }
|
1887 | return createNode(routeReuseStrategy, child);
|
1888 | });
|
1889 | }
|
1890 | function createActivatedRoute(c) {
|
1891 | return new ActivatedRoute(new BehaviorSubject(c.url), new BehaviorSubject(c.params), new BehaviorSubject(c.queryParams), new BehaviorSubject(c.fragment), new BehaviorSubject(c.data), c.outlet, c.component, c);
|
1892 | }
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 | function createUrlTree(route, urlTree, commands, queryParams, fragment) {
|
1902 | if (commands.length === 0) {
|
1903 | return tree(urlTree.root, urlTree.root, urlTree, queryParams, fragment);
|
1904 | }
|
1905 | var nav = computeNavigation(commands);
|
1906 | if (nav.toRoot()) {
|
1907 | return tree(urlTree.root, new UrlSegmentGroup([], {}), urlTree, queryParams, fragment);
|
1908 | }
|
1909 | var startingPosition = findStartingPosition(nav, urlTree, route);
|
1910 | var segmentGroup = startingPosition.processChildren ?
|
1911 | updateSegmentGroupChildren(startingPosition.segmentGroup, startingPosition.index, nav.commands) :
|
1912 | updateSegmentGroup(startingPosition.segmentGroup, startingPosition.index, nav.commands);
|
1913 | return tree(startingPosition.segmentGroup, segmentGroup, urlTree, queryParams, fragment);
|
1914 | }
|
1915 | function isMatrixParams(command) {
|
1916 | return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath;
|
1917 | }
|
1918 | function tree(oldSegmentGroup, newSegmentGroup, urlTree, queryParams, fragment) {
|
1919 | var qp = {};
|
1920 | if (queryParams) {
|
1921 | forEach(queryParams, function (value, name) {
|
1922 | qp[name] = Array.isArray(value) ? value.map(function (v) { return "" + v; }) : "" + value;
|
1923 | });
|
1924 | }
|
1925 | if (urlTree.root === oldSegmentGroup) {
|
1926 | return new UrlTree(newSegmentGroup, qp, fragment);
|
1927 | }
|
1928 | return new UrlTree(replaceSegment(urlTree.root, oldSegmentGroup, newSegmentGroup), qp, fragment);
|
1929 | }
|
1930 | function replaceSegment(current, oldSegment, newSegment) {
|
1931 | var children = {};
|
1932 | forEach(current.children, function (c, outletName) {
|
1933 | if (c === oldSegment) {
|
1934 | children[outletName] = newSegment;
|
1935 | }
|
1936 | else {
|
1937 | children[outletName] = replaceSegment(c, oldSegment, newSegment);
|
1938 | }
|
1939 | });
|
1940 | return new UrlSegmentGroup(current.segments, children);
|
1941 | }
|
1942 | var Navigation = (function () {
|
1943 | function Navigation(isAbsolute, numberOfDoubleDots, commands) {
|
1944 | this.isAbsolute = isAbsolute;
|
1945 | this.numberOfDoubleDots = numberOfDoubleDots;
|
1946 | this.commands = commands;
|
1947 | if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
|
1948 | throw new Error('Root segment cannot have matrix parameters');
|
1949 | }
|
1950 | var cmdWithOutlet = commands.find(function (c) { return typeof c === 'object' && c != null && c.outlets; });
|
1951 | if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
|
1952 | throw new Error('{outlets:{}} has to be the last command');
|
1953 | }
|
1954 | }
|
1955 | Navigation.prototype.toRoot = function () {
|
1956 | return this.isAbsolute && this.commands.length === 1 && this.commands[0] == '/';
|
1957 | };
|
1958 | return Navigation;
|
1959 | }());
|
1960 |
|
1961 | function computeNavigation(commands) {
|
1962 | if ((typeof commands[0] === 'string') && commands.length === 1 && commands[0] === '/') {
|
1963 | return new Navigation(true, 0, commands);
|
1964 | }
|
1965 | var numberOfDoubleDots = 0;
|
1966 | var isAbsolute = false;
|
1967 | var res = commands.reduce(function (res, cmd, cmdIdx) {
|
1968 | if (typeof cmd === 'object' && cmd != null) {
|
1969 | if (cmd.outlets) {
|
1970 | var outlets_1 = {};
|
1971 | forEach(cmd.outlets, function (commands, name) {
|
1972 | outlets_1[name] = typeof commands === 'string' ? commands.split('/') : commands;
|
1973 | });
|
1974 | return __spread(res, [{ outlets: outlets_1 }]);
|
1975 | }
|
1976 | if (cmd.segmentPath) {
|
1977 | return __spread(res, [cmd.segmentPath]);
|
1978 | }
|
1979 | }
|
1980 | if (!(typeof cmd === 'string')) {
|
1981 | return __spread(res, [cmd]);
|
1982 | }
|
1983 | if (cmdIdx === 0) {
|
1984 | cmd.split('/').forEach(function (urlPart, partIndex) {
|
1985 | if (partIndex == 0 && urlPart === '.') {
|
1986 |
|
1987 | }
|
1988 | else if (partIndex == 0 && urlPart === '') {
|
1989 | isAbsolute = true;
|
1990 | }
|
1991 | else if (urlPart === '..') {
|
1992 | numberOfDoubleDots++;
|
1993 | }
|
1994 | else if (urlPart != '') {
|
1995 | res.push(urlPart);
|
1996 | }
|
1997 | });
|
1998 | return res;
|
1999 | }
|
2000 | return __spread(res, [cmd]);
|
2001 | }, []);
|
2002 | return new Navigation(isAbsolute, numberOfDoubleDots, res);
|
2003 | }
|
2004 | var Position = (function () {
|
2005 | function Position(segmentGroup, processChildren, index) {
|
2006 | this.segmentGroup = segmentGroup;
|
2007 | this.processChildren = processChildren;
|
2008 | this.index = index;
|
2009 | }
|
2010 | return Position;
|
2011 | }());
|
2012 | function findStartingPosition(nav, tree, route) {
|
2013 | if (nav.isAbsolute) {
|
2014 | return new Position(tree.root, true, 0);
|
2015 | }
|
2016 | if (route.snapshot._lastPathIndex === -1) {
|
2017 | return new Position(route.snapshot._urlSegment, true, 0);
|
2018 | }
|
2019 | var modifier = isMatrixParams(nav.commands[0]) ? 0 : 1;
|
2020 | var index = route.snapshot._lastPathIndex + modifier;
|
2021 | return createPositionApplyingDoubleDots(route.snapshot._urlSegment, index, nav.numberOfDoubleDots);
|
2022 | }
|
2023 | function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
|
2024 | var g = group;
|
2025 | var ci = index;
|
2026 | var dd = numberOfDoubleDots;
|
2027 | while (dd > ci) {
|
2028 | dd -= ci;
|
2029 | g = g.parent;
|
2030 | if (!g) {
|
2031 | throw new Error('Invalid number of \'../\'');
|
2032 | }
|
2033 | ci = g.segments.length;
|
2034 | }
|
2035 | return new Position(g, false, ci - dd);
|
2036 | }
|
2037 | function getPath(command) {
|
2038 | if (typeof command === 'object' && command != null && command.outlets) {
|
2039 | return command.outlets[PRIMARY_OUTLET];
|
2040 | }
|
2041 | return "" + command;
|
2042 | }
|
2043 | function getOutlets(commands) {
|
2044 | var _a, _b;
|
2045 | if (!(typeof commands[0] === 'object'))
|
2046 | return _a = {}, _a[PRIMARY_OUTLET] = commands, _a;
|
2047 | if (commands[0].outlets === undefined)
|
2048 | return _b = {}, _b[PRIMARY_OUTLET] = commands, _b;
|
2049 | return commands[0].outlets;
|
2050 | }
|
2051 | function updateSegmentGroup(segmentGroup, startIndex, commands) {
|
2052 | if (!segmentGroup) {
|
2053 | segmentGroup = new UrlSegmentGroup([], {});
|
2054 | }
|
2055 | if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
|
2056 | return updateSegmentGroupChildren(segmentGroup, startIndex, commands);
|
2057 | }
|
2058 | var m = prefixedWith(segmentGroup, startIndex, commands);
|
2059 | var slicedCommands = commands.slice(m.commandIndex);
|
2060 | if (m.match && m.pathIndex < segmentGroup.segments.length) {
|
2061 | var g = new UrlSegmentGroup(segmentGroup.segments.slice(0, m.pathIndex), {});
|
2062 | g.children[PRIMARY_OUTLET] =
|
2063 | new UrlSegmentGroup(segmentGroup.segments.slice(m.pathIndex), segmentGroup.children);
|
2064 | return updateSegmentGroupChildren(g, 0, slicedCommands);
|
2065 | }
|
2066 | else if (m.match && slicedCommands.length === 0) {
|
2067 | return new UrlSegmentGroup(segmentGroup.segments, {});
|
2068 | }
|
2069 | else if (m.match && !segmentGroup.hasChildren()) {
|
2070 | return createNewSegmentGroup(segmentGroup, startIndex, commands);
|
2071 | }
|
2072 | else if (m.match) {
|
2073 | return updateSegmentGroupChildren(segmentGroup, 0, slicedCommands);
|
2074 | }
|
2075 | else {
|
2076 | return createNewSegmentGroup(segmentGroup, startIndex, commands);
|
2077 | }
|
2078 | }
|
2079 | function updateSegmentGroupChildren(segmentGroup, startIndex, commands) {
|
2080 | if (commands.length === 0) {
|
2081 | return new UrlSegmentGroup(segmentGroup.segments, {});
|
2082 | }
|
2083 | else {
|
2084 | var outlets_2 = getOutlets(commands);
|
2085 | var children_1 = {};
|
2086 | forEach(outlets_2, function (commands, outlet) {
|
2087 | if (commands !== null) {
|
2088 | children_1[outlet] = updateSegmentGroup(segmentGroup.children[outlet], startIndex, commands);
|
2089 | }
|
2090 | });
|
2091 | forEach(segmentGroup.children, function (child, childOutlet) {
|
2092 | if (outlets_2[childOutlet] === undefined) {
|
2093 | children_1[childOutlet] = child;
|
2094 | }
|
2095 | });
|
2096 | return new UrlSegmentGroup(segmentGroup.segments, children_1);
|
2097 | }
|
2098 | }
|
2099 | function prefixedWith(segmentGroup, startIndex, commands) {
|
2100 | var currentCommandIndex = 0;
|
2101 | var currentPathIndex = startIndex;
|
2102 | var noMatch = { match: false, pathIndex: 0, commandIndex: 0 };
|
2103 | while (currentPathIndex < segmentGroup.segments.length) {
|
2104 | if (currentCommandIndex >= commands.length)
|
2105 | return noMatch;
|
2106 | var path = segmentGroup.segments[currentPathIndex];
|
2107 | var curr = getPath(commands[currentCommandIndex]);
|
2108 | var next = currentCommandIndex < commands.length - 1 ? commands[currentCommandIndex + 1] : null;
|
2109 | if (currentPathIndex > 0 && curr === undefined)
|
2110 | break;
|
2111 | if (curr && next && (typeof next === 'object') && next.outlets === undefined) {
|
2112 | if (!compare(curr, next, path))
|
2113 | return noMatch;
|
2114 | currentCommandIndex += 2;
|
2115 | }
|
2116 | else {
|
2117 | if (!compare(curr, {}, path))
|
2118 | return noMatch;
|
2119 | currentCommandIndex++;
|
2120 | }
|
2121 | currentPathIndex++;
|
2122 | }
|
2123 | return { match: true, pathIndex: currentPathIndex, commandIndex: currentCommandIndex };
|
2124 | }
|
2125 | function createNewSegmentGroup(segmentGroup, startIndex, commands) {
|
2126 | var paths = segmentGroup.segments.slice(0, startIndex);
|
2127 | var i = 0;
|
2128 | while (i < commands.length) {
|
2129 | if (typeof commands[i] === 'object' && commands[i].outlets !== undefined) {
|
2130 | var children = createNewSegmentChildren(commands[i].outlets);
|
2131 | return new UrlSegmentGroup(paths, children);
|
2132 | }
|
2133 |
|
2134 | if (i === 0 && isMatrixParams(commands[0])) {
|
2135 | var p = segmentGroup.segments[startIndex];
|
2136 | paths.push(new UrlSegment(p.path, commands[0]));
|
2137 | i++;
|
2138 | continue;
|
2139 | }
|
2140 | var curr = getPath(commands[i]);
|
2141 | var next = (i < commands.length - 1) ? commands[i + 1] : null;
|
2142 | if (curr && next && isMatrixParams(next)) {
|
2143 | paths.push(new UrlSegment(curr, stringify(next)));
|
2144 | i += 2;
|
2145 | }
|
2146 | else {
|
2147 | paths.push(new UrlSegment(curr, {}));
|
2148 | i++;
|
2149 | }
|
2150 | }
|
2151 | return new UrlSegmentGroup(paths, {});
|
2152 | }
|
2153 | function createNewSegmentChildren(outlets) {
|
2154 | var children = {};
|
2155 | forEach(outlets, function (commands, outlet) {
|
2156 | if (commands !== null) {
|
2157 | children[outlet] = createNewSegmentGroup(new UrlSegmentGroup([], {}), 0, commands);
|
2158 | }
|
2159 | });
|
2160 | return children;
|
2161 | }
|
2162 | function stringify(params) {
|
2163 | var res = {};
|
2164 | forEach(params, function (v, k) { return res[k] = "" + v; });
|
2165 | return res;
|
2166 | }
|
2167 | function compare(path, params, segment) {
|
2168 | return path == segment.path && shallowEqual(params, segment.parameters);
|
2169 | }
|
2170 |
|
2171 |
|
2172 |
|
2173 |
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 | var activateRoutes = function (rootContexts, routeReuseStrategy, forwardEvent) {
|
2179 | return map(function (t) {
|
2180 | new ActivateRoutes(routeReuseStrategy, t.targetRouterState, t.currentRouterState, forwardEvent)
|
2181 | .activate(rootContexts);
|
2182 | return t;
|
2183 | });
|
2184 | };
|
2185 | var ActivateRoutes = (function () {
|
2186 | function ActivateRoutes(routeReuseStrategy, futureState, currState, forwardEvent) {
|
2187 | this.routeReuseStrategy = routeReuseStrategy;
|
2188 | this.futureState = futureState;
|
2189 | this.currState = currState;
|
2190 | this.forwardEvent = forwardEvent;
|
2191 | }
|
2192 | ActivateRoutes.prototype.activate = function (parentContexts) {
|
2193 | var futureRoot = this.futureState._root;
|
2194 | var currRoot = this.currState ? this.currState._root : null;
|
2195 | this.deactivateChildRoutes(futureRoot, currRoot, parentContexts);
|
2196 | advanceActivatedRoute(this.futureState.root);
|
2197 | this.activateChildRoutes(futureRoot, currRoot, parentContexts);
|
2198 | };
|
2199 |
|
2200 | ActivateRoutes.prototype.deactivateChildRoutes = function (futureNode, currNode, contexts) {
|
2201 | var _this = this;
|
2202 | var children = nodeChildrenAsMap(currNode);
|
2203 |
|
2204 | futureNode.children.forEach(function (futureChild) {
|
2205 | var childOutletName = futureChild.value.outlet;
|
2206 | _this.deactivateRoutes(futureChild, children[childOutletName], contexts);
|
2207 | delete children[childOutletName];
|
2208 | });
|
2209 |
|
2210 | forEach(children, function (v, childName) {
|
2211 | _this.deactivateRouteAndItsChildren(v, contexts);
|
2212 | });
|
2213 | };
|
2214 | ActivateRoutes.prototype.deactivateRoutes = function (futureNode, currNode, parentContext) {
|
2215 | var future = futureNode.value;
|
2216 | var curr = currNode ? currNode.value : null;
|
2217 | if (future === curr) {
|
2218 |
|
2219 | if (future.component) {
|
2220 |
|
2221 | var context = parentContext.getContext(future.outlet);
|
2222 | if (context) {
|
2223 | this.deactivateChildRoutes(futureNode, currNode, context.children);
|
2224 | }
|
2225 | }
|
2226 | else {
|
2227 |
|
2228 | this.deactivateChildRoutes(futureNode, currNode, parentContext);
|
2229 | }
|
2230 | }
|
2231 | else {
|
2232 | if (curr) {
|
2233 |
|
2234 | this.deactivateRouteAndItsChildren(currNode, parentContext);
|
2235 | }
|
2236 | }
|
2237 | };
|
2238 | ActivateRoutes.prototype.deactivateRouteAndItsChildren = function (route, parentContexts) {
|
2239 | if (this.routeReuseStrategy.shouldDetach(route.value.snapshot)) {
|
2240 | this.detachAndStoreRouteSubtree(route, parentContexts);
|
2241 | }
|
2242 | else {
|
2243 | this.deactivateRouteAndOutlet(route, parentContexts);
|
2244 | }
|
2245 | };
|
2246 | ActivateRoutes.prototype.detachAndStoreRouteSubtree = function (route, parentContexts) {
|
2247 | var context = parentContexts.getContext(route.value.outlet);
|
2248 | if (context && context.outlet) {
|
2249 | var componentRef = context.outlet.detach();
|
2250 | var contexts = context.children.onOutletDeactivated();
|
2251 | this.routeReuseStrategy.store(route.value.snapshot, { componentRef: componentRef, route: route, contexts: contexts });
|
2252 | }
|
2253 | };
|
2254 | ActivateRoutes.prototype.deactivateRouteAndOutlet = function (route, parentContexts) {
|
2255 | var _this = this;
|
2256 | var context = parentContexts.getContext(route.value.outlet);
|
2257 | if (context) {
|
2258 | var children = nodeChildrenAsMap(route);
|
2259 | var contexts_1 = route.value.component ? context.children : parentContexts;
|
2260 | forEach(children, function (v, k) { return _this.deactivateRouteAndItsChildren(v, contexts_1); });
|
2261 | if (context.outlet) {
|
2262 |
|
2263 | context.outlet.deactivate();
|
2264 |
|
2265 | context.children.onOutletDeactivated();
|
2266 | }
|
2267 | }
|
2268 | };
|
2269 | ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, contexts) {
|
2270 | var _this = this;
|
2271 | var children = nodeChildrenAsMap(currNode);
|
2272 | futureNode.children.forEach(function (c) {
|
2273 | _this.activateRoutes(c, children[c.value.outlet], contexts);
|
2274 | _this.forwardEvent(new ActivationEnd(c.value.snapshot));
|
2275 | });
|
2276 | if (futureNode.children.length) {
|
2277 | this.forwardEvent(new ChildActivationEnd(futureNode.value.snapshot));
|
2278 | }
|
2279 | };
|
2280 | ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentContexts) {
|
2281 | var future = futureNode.value;
|
2282 | var curr = currNode ? currNode.value : null;
|
2283 | advanceActivatedRoute(future);
|
2284 |
|
2285 | if (future === curr) {
|
2286 | if (future.component) {
|
2287 |
|
2288 | var context = parentContexts.getOrCreateContext(future.outlet);
|
2289 | this.activateChildRoutes(futureNode, currNode, context.children);
|
2290 | }
|
2291 | else {
|
2292 |
|
2293 | this.activateChildRoutes(futureNode, currNode, parentContexts);
|
2294 | }
|
2295 | }
|
2296 | else {
|
2297 | if (future.component) {
|
2298 |
|
2299 | var context = parentContexts.getOrCreateContext(future.outlet);
|
2300 | if (this.routeReuseStrategy.shouldAttach(future.snapshot)) {
|
2301 | var stored = this.routeReuseStrategy.retrieve(future.snapshot);
|
2302 | this.routeReuseStrategy.store(future.snapshot, null);
|
2303 | context.children.onOutletReAttached(stored.contexts);
|
2304 | context.attachRef = stored.componentRef;
|
2305 | context.route = stored.route.value;
|
2306 | if (context.outlet) {
|
2307 |
|
2308 |
|
2309 | context.outlet.attach(stored.componentRef, stored.route.value);
|
2310 | }
|
2311 | advanceActivatedRouteNodeAndItsChildren(stored.route);
|
2312 | }
|
2313 | else {
|
2314 | var config = parentLoadedConfig(future.snapshot);
|
2315 | var cmpFactoryResolver = config ? config.module.componentFactoryResolver : null;
|
2316 | context.attachRef = null;
|
2317 | context.route = future;
|
2318 | context.resolver = cmpFactoryResolver;
|
2319 | if (context.outlet) {
|
2320 |
|
2321 |
|
2322 | context.outlet.activateWith(future, cmpFactoryResolver);
|
2323 | }
|
2324 | this.activateChildRoutes(futureNode, null, context.children);
|
2325 | }
|
2326 | }
|
2327 | else {
|
2328 |
|
2329 | this.activateChildRoutes(futureNode, null, parentContexts);
|
2330 | }
|
2331 | }
|
2332 | };
|
2333 | return ActivateRoutes;
|
2334 | }());
|
2335 | function advanceActivatedRouteNodeAndItsChildren(node) {
|
2336 | advanceActivatedRoute(node.value);
|
2337 | node.children.forEach(advanceActivatedRouteNodeAndItsChildren);
|
2338 | }
|
2339 | function parentLoadedConfig(snapshot) {
|
2340 | for (var s = snapshot.parent; s; s = s.parent) {
|
2341 | var route = s.routeConfig;
|
2342 | if (route && route._loadedConfig)
|
2343 | return route._loadedConfig;
|
2344 | if (route && route.component)
|
2345 | return null;
|
2346 | }
|
2347 | return null;
|
2348 | }
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 | function isFunction(v) {
|
2371 | return typeof v === 'function';
|
2372 | }
|
2373 | function isBoolean(v) {
|
2374 | return typeof v === 'boolean';
|
2375 | }
|
2376 | function isUrlTree(v) {
|
2377 | return v instanceof UrlTree;
|
2378 | }
|
2379 | function isCanLoad(guard) {
|
2380 | return guard && isFunction(guard.canLoad);
|
2381 | }
|
2382 | function isCanActivate(guard) {
|
2383 | return guard && isFunction(guard.canActivate);
|
2384 | }
|
2385 | function isCanActivateChild(guard) {
|
2386 | return guard && isFunction(guard.canActivateChild);
|
2387 | }
|
2388 | function isCanDeactivate(guard) {
|
2389 | return guard && isFunction(guard.canDeactivate);
|
2390 | }
|
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 |
|
2398 |
|
2399 | var NoMatch = (function () {
|
2400 | function NoMatch(segmentGroup) {
|
2401 | this.segmentGroup = segmentGroup || null;
|
2402 | }
|
2403 | return NoMatch;
|
2404 | }());
|
2405 | var AbsoluteRedirect = (function () {
|
2406 | function AbsoluteRedirect(urlTree) {
|
2407 | this.urlTree = urlTree;
|
2408 | }
|
2409 | return AbsoluteRedirect;
|
2410 | }());
|
2411 | function noMatch(segmentGroup) {
|
2412 | return new Observable(function (obs) { return obs.error(new NoMatch(segmentGroup)); });
|
2413 | }
|
2414 | function absoluteRedirect(newTree) {
|
2415 | return new Observable(function (obs) { return obs.error(new AbsoluteRedirect(newTree)); });
|
2416 | }
|
2417 | function namedOutletsRedirect(redirectTo) {
|
2418 | return new Observable(function (obs) { return obs.error(new Error("Only absolute redirects can have named outlets. redirectTo: '" + redirectTo + "'")); });
|
2419 | }
|
2420 | function canLoadFails(route) {
|
2421 | return new Observable(function (obs) { return obs.error(navigationCancelingError("Cannot load children because the guard of the route \"path: '" + route.path + "'\" returned false")); });
|
2422 | }
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 | function applyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
|
2429 | return new ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config).apply();
|
2430 | }
|
2431 | var ApplyRedirects = (function () {
|
2432 | function ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
|
2433 | this.configLoader = configLoader;
|
2434 | this.urlSerializer = urlSerializer;
|
2435 | this.urlTree = urlTree;
|
2436 | this.config = config;
|
2437 | this.allowRedirects = true;
|
2438 | this.ngModule = moduleInjector.get(NgModuleRef);
|
2439 | }
|
2440 | ApplyRedirects.prototype.apply = function () {
|
2441 | var _this = this;
|
2442 | var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, this.urlTree.root, PRIMARY_OUTLET);
|
2443 | var urlTrees$ = expanded$.pipe(map(function (rootSegmentGroup) { return _this.createUrlTree(rootSegmentGroup, _this.urlTree.queryParams, _this.urlTree.fragment); }));
|
2444 | return urlTrees$.pipe(catchError(function (e) {
|
2445 | if (e instanceof AbsoluteRedirect) {
|
2446 |
|
2447 | _this.allowRedirects = false;
|
2448 |
|
2449 | return _this.match(e.urlTree);
|
2450 | }
|
2451 | if (e instanceof NoMatch) {
|
2452 | throw _this.noMatchError(e);
|
2453 | }
|
2454 | throw e;
|
2455 | }));
|
2456 | };
|
2457 | ApplyRedirects.prototype.match = function (tree) {
|
2458 | var _this = this;
|
2459 | var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, tree.root, PRIMARY_OUTLET);
|
2460 | var mapped$ = expanded$.pipe(map(function (rootSegmentGroup) {
|
2461 | return _this.createUrlTree(rootSegmentGroup, tree.queryParams, tree.fragment);
|
2462 | }));
|
2463 | return mapped$.pipe(catchError(function (e) {
|
2464 | if (e instanceof NoMatch) {
|
2465 | throw _this.noMatchError(e);
|
2466 | }
|
2467 | throw e;
|
2468 | }));
|
2469 | };
|
2470 | ApplyRedirects.prototype.noMatchError = function (e) {
|
2471 | return new Error("Cannot match any routes. URL Segment: '" + e.segmentGroup + "'");
|
2472 | };
|
2473 | ApplyRedirects.prototype.createUrlTree = function (rootCandidate, queryParams, fragment) {
|
2474 | var _a;
|
2475 | var root = rootCandidate.segments.length > 0 ?
|
2476 | new UrlSegmentGroup([], (_a = {}, _a[PRIMARY_OUTLET] = rootCandidate, _a)) :
|
2477 | rootCandidate;
|
2478 | return new UrlTree(root, queryParams, fragment);
|
2479 | };
|
2480 | ApplyRedirects.prototype.expandSegmentGroup = function (ngModule, routes, segmentGroup, outlet) {
|
2481 | if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
|
2482 | return this.expandChildren(ngModule, routes, segmentGroup)
|
2483 | .pipe(map(function (children) { return new UrlSegmentGroup([], children); }));
|
2484 | }
|
2485 | return this.expandSegment(ngModule, segmentGroup, routes, segmentGroup.segments, outlet, true);
|
2486 | };
|
2487 |
|
2488 | ApplyRedirects.prototype.expandChildren = function (ngModule, routes, segmentGroup) {
|
2489 | var _this = this;
|
2490 | return waitForMap(segmentGroup.children, function (childOutlet, child) { return _this.expandSegmentGroup(ngModule, routes, child, childOutlet); });
|
2491 | };
|
2492 | ApplyRedirects.prototype.expandSegment = function (ngModule, segmentGroup, routes, segments, outlet, allowRedirects) {
|
2493 | var _this = this;
|
2494 | return of.apply(void 0, __spread(routes)).pipe(map(function (r) {
|
2495 | var expanded$ = _this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
|
2496 | return expanded$.pipe(catchError(function (e) {
|
2497 | if (e instanceof NoMatch) {
|
2498 |
|
2499 |
|
2500 | return of(null);
|
2501 | }
|
2502 | throw e;
|
2503 | }));
|
2504 | }), concatAll(), first(function (s) { return !!s; }), catchError(function (e, _) {
|
2505 | if (e instanceof EmptyError || e.name === 'EmptyError') {
|
2506 | if (_this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
2507 | return of(new UrlSegmentGroup([], {}));
|
2508 | }
|
2509 | throw new NoMatch(segmentGroup);
|
2510 | }
|
2511 | throw e;
|
2512 | }));
|
2513 | };
|
2514 | ApplyRedirects.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
|
2515 | return segments.length === 0 && !segmentGroup.children[outlet];
|
2516 | };
|
2517 | ApplyRedirects.prototype.expandSegmentAgainstRoute = function (ngModule, segmentGroup, routes, route, paths, outlet, allowRedirects) {
|
2518 | if (getOutlet(route) !== outlet) {
|
2519 | return noMatch(segmentGroup);
|
2520 | }
|
2521 | if (route.redirectTo === undefined) {
|
2522 | return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths);
|
2523 | }
|
2524 | if (allowRedirects && this.allowRedirects) {
|
2525 | return this.expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, paths, outlet);
|
2526 | }
|
2527 | return noMatch(segmentGroup);
|
2528 | };
|
2529 | ApplyRedirects.prototype.expandSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
|
2530 | if (route.path === '**') {
|
2531 | return this.expandWildCardWithParamsAgainstRouteUsingRedirect(ngModule, routes, route, outlet);
|
2532 | }
|
2533 | return this.expandRegularSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, segments, outlet);
|
2534 | };
|
2535 | ApplyRedirects.prototype.expandWildCardWithParamsAgainstRouteUsingRedirect = function (ngModule, routes, route, outlet) {
|
2536 | var _this = this;
|
2537 | var newTree = this.applyRedirectCommands([], route.redirectTo, {});
|
2538 | if (route.redirectTo.startsWith('/')) {
|
2539 | return absoluteRedirect(newTree);
|
2540 | }
|
2541 | return this.lineralizeSegments(route, newTree).pipe(mergeMap(function (newSegments) {
|
2542 | var group = new UrlSegmentGroup(newSegments, {});
|
2543 | return _this.expandSegment(ngModule, group, routes, newSegments, outlet, false);
|
2544 | }));
|
2545 | };
|
2546 | ApplyRedirects.prototype.expandRegularSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
|
2547 | var _this = this;
|
2548 | var _a = match(segmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild, positionalParamSegments = _a.positionalParamSegments;
|
2549 | if (!matched)
|
2550 | return noMatch(segmentGroup);
|
2551 | var newTree = this.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments);
|
2552 | if (route.redirectTo.startsWith('/')) {
|
2553 | return absoluteRedirect(newTree);
|
2554 | }
|
2555 | return this.lineralizeSegments(route, newTree).pipe(mergeMap(function (newSegments) {
|
2556 | return _this.expandSegment(ngModule, segmentGroup, routes, newSegments.concat(segments.slice(lastChild)), outlet, false);
|
2557 | }));
|
2558 | };
|
2559 | ApplyRedirects.prototype.matchSegmentAgainstRoute = function (ngModule, rawSegmentGroup, route, segments) {
|
2560 | var _this = this;
|
2561 | if (route.path === '**') {
|
2562 | if (route.loadChildren) {
|
2563 | return this.configLoader.load(ngModule.injector, route)
|
2564 | .pipe(map(function (cfg) {
|
2565 | route._loadedConfig = cfg;
|
2566 | return new UrlSegmentGroup(segments, {});
|
2567 | }));
|
2568 | }
|
2569 | return of(new UrlSegmentGroup(segments, {}));
|
2570 | }
|
2571 | var _a = match(rawSegmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild;
|
2572 | if (!matched)
|
2573 | return noMatch(rawSegmentGroup);
|
2574 | var rawSlicedSegments = segments.slice(lastChild);
|
2575 | var childConfig$ = this.getChildConfig(ngModule, route, segments);
|
2576 | return childConfig$.pipe(mergeMap(function (routerConfig) {
|
2577 | var childModule = routerConfig.module;
|
2578 | var childConfig = routerConfig.routes;
|
2579 | var _a = split(rawSegmentGroup, consumedSegments, rawSlicedSegments, childConfig), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
|
2580 | if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
2581 | var expanded$_1 = _this.expandChildren(childModule, childConfig, segmentGroup);
|
2582 | return expanded$_1.pipe(map(function (children) { return new UrlSegmentGroup(consumedSegments, children); }));
|
2583 | }
|
2584 | if (childConfig.length === 0 && slicedSegments.length === 0) {
|
2585 | return of(new UrlSegmentGroup(consumedSegments, {}));
|
2586 | }
|
2587 | var expanded$ = _this.expandSegment(childModule, segmentGroup, childConfig, slicedSegments, PRIMARY_OUTLET, true);
|
2588 | return expanded$.pipe(map(function (cs) {
|
2589 | return new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children);
|
2590 | }));
|
2591 | }));
|
2592 | };
|
2593 | ApplyRedirects.prototype.getChildConfig = function (ngModule, route, segments) {
|
2594 | var _this = this;
|
2595 | if (route.children) {
|
2596 |
|
2597 | return of(new LoadedRouterConfig(route.children, ngModule));
|
2598 | }
|
2599 | if (route.loadChildren) {
|
2600 |
|
2601 | if (route._loadedConfig !== undefined) {
|
2602 | return of(route._loadedConfig);
|
2603 | }
|
2604 | return runCanLoadGuard(ngModule.injector, route, segments)
|
2605 | .pipe(mergeMap(function (shouldLoad) {
|
2606 | if (shouldLoad) {
|
2607 | return _this.configLoader.load(ngModule.injector, route)
|
2608 | .pipe(map(function (cfg) {
|
2609 | route._loadedConfig = cfg;
|
2610 | return cfg;
|
2611 | }));
|
2612 | }
|
2613 | return canLoadFails(route);
|
2614 | }));
|
2615 | }
|
2616 | return of(new LoadedRouterConfig([], ngModule));
|
2617 | };
|
2618 | ApplyRedirects.prototype.lineralizeSegments = function (route, urlTree) {
|
2619 | var res = [];
|
2620 | var c = urlTree.root;
|
2621 | while (true) {
|
2622 | res = res.concat(c.segments);
|
2623 | if (c.numberOfChildren === 0) {
|
2624 | return of(res);
|
2625 | }
|
2626 | if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
|
2627 | return namedOutletsRedirect(route.redirectTo);
|
2628 | }
|
2629 | c = c.children[PRIMARY_OUTLET];
|
2630 | }
|
2631 | };
|
2632 | ApplyRedirects.prototype.applyRedirectCommands = function (segments, redirectTo, posParams) {
|
2633 | return this.applyRedirectCreatreUrlTree(redirectTo, this.urlSerializer.parse(redirectTo), segments, posParams);
|
2634 | };
|
2635 | ApplyRedirects.prototype.applyRedirectCreatreUrlTree = function (redirectTo, urlTree, segments, posParams) {
|
2636 | var newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
|
2637 | return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
|
2638 | };
|
2639 | ApplyRedirects.prototype.createQueryParams = function (redirectToParams, actualParams) {
|
2640 | var res = {};
|
2641 | forEach(redirectToParams, function (v, k) {
|
2642 | var copySourceValue = typeof v === 'string' && v.startsWith(':');
|
2643 | if (copySourceValue) {
|
2644 | var sourceName = v.substring(1);
|
2645 | res[k] = actualParams[sourceName];
|
2646 | }
|
2647 | else {
|
2648 | res[k] = v;
|
2649 | }
|
2650 | });
|
2651 | return res;
|
2652 | };
|
2653 | ApplyRedirects.prototype.createSegmentGroup = function (redirectTo, group, segments, posParams) {
|
2654 | var _this = this;
|
2655 | var updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
|
2656 | var children = {};
|
2657 | forEach(group.children, function (child, name) {
|
2658 | children[name] = _this.createSegmentGroup(redirectTo, child, segments, posParams);
|
2659 | });
|
2660 | return new UrlSegmentGroup(updatedSegments, children);
|
2661 | };
|
2662 | ApplyRedirects.prototype.createSegments = function (redirectTo, redirectToSegments, actualSegments, posParams) {
|
2663 | var _this = this;
|
2664 | return redirectToSegments.map(function (s) { return s.path.startsWith(':') ? _this.findPosParam(redirectTo, s, posParams) :
|
2665 | _this.findOrReturn(s, actualSegments); });
|
2666 | };
|
2667 | ApplyRedirects.prototype.findPosParam = function (redirectTo, redirectToUrlSegment, posParams) {
|
2668 | var pos = posParams[redirectToUrlSegment.path.substring(1)];
|
2669 | if (!pos)
|
2670 | throw new Error("Cannot redirect to '" + redirectTo + "'. Cannot find '" + redirectToUrlSegment.path + "'.");
|
2671 | return pos;
|
2672 | };
|
2673 | ApplyRedirects.prototype.findOrReturn = function (redirectToUrlSegment, actualSegments) {
|
2674 | var e_1, _a;
|
2675 | var idx = 0;
|
2676 | try {
|
2677 | for (var actualSegments_1 = __values(actualSegments), actualSegments_1_1 = actualSegments_1.next(); !actualSegments_1_1.done; actualSegments_1_1 = actualSegments_1.next()) {
|
2678 | var s = actualSegments_1_1.value;
|
2679 | if (s.path === redirectToUrlSegment.path) {
|
2680 | actualSegments.splice(idx);
|
2681 | return s;
|
2682 | }
|
2683 | idx++;
|
2684 | }
|
2685 | }
|
2686 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
2687 | finally {
|
2688 | try {
|
2689 | if (actualSegments_1_1 && !actualSegments_1_1.done && (_a = actualSegments_1.return)) _a.call(actualSegments_1);
|
2690 | }
|
2691 | finally { if (e_1) throw e_1.error; }
|
2692 | }
|
2693 | return redirectToUrlSegment;
|
2694 | };
|
2695 | return ApplyRedirects;
|
2696 | }());
|
2697 | function runCanLoadGuard(moduleInjector, route, segments) {
|
2698 | var canLoad = route.canLoad;
|
2699 | if (!canLoad || canLoad.length === 0)
|
2700 | return of(true);
|
2701 | var obs = from(canLoad).pipe(map(function (injectionToken) {
|
2702 | var guard = moduleInjector.get(injectionToken);
|
2703 | var guardVal;
|
2704 | if (isCanLoad(guard)) {
|
2705 | guardVal = guard.canLoad(route, segments);
|
2706 | }
|
2707 | else if (isFunction(guard)) {
|
2708 | guardVal = guard(route, segments);
|
2709 | }
|
2710 | else {
|
2711 | throw new Error('Invalid CanLoad guard');
|
2712 | }
|
2713 | return wrapIntoObservable(guardVal);
|
2714 | }));
|
2715 | return obs.pipe(concatAll(), every(function (result) { return result === true; }));
|
2716 | }
|
2717 | function match(segmentGroup, route, segments) {
|
2718 | if (route.path === '') {
|
2719 | if ((route.pathMatch === 'full') && (segmentGroup.hasChildren() || segments.length > 0)) {
|
2720 | return { matched: false, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
|
2721 | }
|
2722 | return { matched: true, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
|
2723 | }
|
2724 | var matcher = route.matcher || defaultUrlMatcher;
|
2725 | var res = matcher(segments, segmentGroup, route);
|
2726 | if (!res) {
|
2727 | return {
|
2728 | matched: false,
|
2729 | consumedSegments: [],
|
2730 | lastChild: 0,
|
2731 | positionalParamSegments: {},
|
2732 | };
|
2733 | }
|
2734 | return {
|
2735 | matched: true,
|
2736 | consumedSegments: res.consumed,
|
2737 | lastChild: res.consumed.length,
|
2738 | positionalParamSegments: res.posParams,
|
2739 | };
|
2740 | }
|
2741 | function split(segmentGroup, consumedSegments, slicedSegments, config) {
|
2742 | if (slicedSegments.length > 0 &&
|
2743 | containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
2744 | var s = new UrlSegmentGroup(consumedSegments, createChildrenForEmptySegments(config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
2745 | return { segmentGroup: mergeTrivialChildren(s), slicedSegments: [] };
|
2746 | }
|
2747 | if (slicedSegments.length === 0 &&
|
2748 | containsEmptyPathRedirects(segmentGroup, slicedSegments, config)) {
|
2749 | var s = new UrlSegmentGroup(segmentGroup.segments, addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
|
2750 | return { segmentGroup: mergeTrivialChildren(s), slicedSegments: slicedSegments };
|
2751 | }
|
2752 | return { segmentGroup: segmentGroup, slicedSegments: slicedSegments };
|
2753 | }
|
2754 | function mergeTrivialChildren(s) {
|
2755 | if (s.numberOfChildren === 1 && s.children[PRIMARY_OUTLET]) {
|
2756 | var c = s.children[PRIMARY_OUTLET];
|
2757 | return new UrlSegmentGroup(s.segments.concat(c.segments), c.children);
|
2758 | }
|
2759 | return s;
|
2760 | }
|
2761 | function addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, routes, children) {
|
2762 | var e_2, _a;
|
2763 | var res = {};
|
2764 | try {
|
2765 | for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
|
2766 | var r = routes_1_1.value;
|
2767 | if (isEmptyPathRedirect(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
|
2768 | res[getOutlet(r)] = new UrlSegmentGroup([], {});
|
2769 | }
|
2770 | }
|
2771 | }
|
2772 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
2773 | finally {
|
2774 | try {
|
2775 | if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
2776 | }
|
2777 | finally { if (e_2) throw e_2.error; }
|
2778 | }
|
2779 | return __assign(__assign({}, children), res);
|
2780 | }
|
2781 | function createChildrenForEmptySegments(routes, primarySegmentGroup) {
|
2782 | var e_3, _a;
|
2783 | var res = {};
|
2784 | res[PRIMARY_OUTLET] = primarySegmentGroup;
|
2785 | try {
|
2786 | for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
|
2787 | var r = routes_2_1.value;
|
2788 | if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
|
2789 | res[getOutlet(r)] = new UrlSegmentGroup([], {});
|
2790 | }
|
2791 | }
|
2792 | }
|
2793 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
2794 | finally {
|
2795 | try {
|
2796 | if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
2797 | }
|
2798 | finally { if (e_3) throw e_3.error; }
|
2799 | }
|
2800 | return res;
|
2801 | }
|
2802 | function containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, segments, routes) {
|
2803 | return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
|
2804 | }
|
2805 | function containsEmptyPathRedirects(segmentGroup, segments, routes) {
|
2806 | return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r); });
|
2807 | }
|
2808 | function isEmptyPathRedirect(segmentGroup, segments, r) {
|
2809 | if ((segmentGroup.hasChildren() || segments.length > 0) && r.pathMatch === 'full') {
|
2810 | return false;
|
2811 | }
|
2812 | return r.path === '' && r.redirectTo !== undefined;
|
2813 | }
|
2814 | function getOutlet(route) {
|
2815 | return route.outlet || PRIMARY_OUTLET;
|
2816 | }
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 | function applyRedirects$1(moduleInjector, configLoader, urlSerializer, config) {
|
2826 | return function (source) {
|
2827 | return source.pipe(switchMap(function (t) { return applyRedirects(moduleInjector, configLoader, urlSerializer, t.extractedUrl, config)
|
2828 | .pipe(map(function (urlAfterRedirects) { return (__assign(__assign({}, t), { urlAfterRedirects: urlAfterRedirects })); })); }));
|
2829 | };
|
2830 | }
|
2831 |
|
2832 |
|
2833 |
|
2834 |
|
2835 |
|
2836 |
|
2837 |
|
2838 |
|
2839 | var CanActivate = (function () {
|
2840 | function CanActivate(path) {
|
2841 | this.path = path;
|
2842 | this.route = this.path[this.path.length - 1];
|
2843 | }
|
2844 | return CanActivate;
|
2845 | }());
|
2846 | var CanDeactivate = (function () {
|
2847 | function CanDeactivate(component, route) {
|
2848 | this.component = component;
|
2849 | this.route = route;
|
2850 | }
|
2851 | return CanDeactivate;
|
2852 | }());
|
2853 | function getAllRouteGuards(future, curr, parentContexts) {
|
2854 | var futureRoot = future._root;
|
2855 | var currRoot = curr ? curr._root : null;
|
2856 | return getChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
|
2857 | }
|
2858 | function getCanActivateChild(p) {
|
2859 | var canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
|
2860 | if (!canActivateChild || canActivateChild.length === 0)
|
2861 | return null;
|
2862 | return { node: p, guards: canActivateChild };
|
2863 | }
|
2864 | function getToken(token, snapshot, moduleInjector) {
|
2865 | var config = getClosestLoadedConfig(snapshot);
|
2866 | var injector = config ? config.module.injector : moduleInjector;
|
2867 | return injector.get(token);
|
2868 | }
|
2869 | function getClosestLoadedConfig(snapshot) {
|
2870 | if (!snapshot)
|
2871 | return null;
|
2872 | for (var s = snapshot.parent; s; s = s.parent) {
|
2873 | var route = s.routeConfig;
|
2874 | if (route && route._loadedConfig)
|
2875 | return route._loadedConfig;
|
2876 | }
|
2877 | return null;
|
2878 | }
|
2879 | function getChildRouteGuards(futureNode, currNode, contexts, futurePath, checks) {
|
2880 | if (checks === void 0) { checks = {
|
2881 | canDeactivateChecks: [],
|
2882 | canActivateChecks: []
|
2883 | }; }
|
2884 | var prevChildren = nodeChildrenAsMap(currNode);
|
2885 |
|
2886 | futureNode.children.forEach(function (c) {
|
2887 | getRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]), checks);
|
2888 | delete prevChildren[c.value.outlet];
|
2889 | });
|
2890 |
|
2891 | forEach(prevChildren, function (v, k) {
|
2892 | return deactivateRouteAndItsChildren(v, contexts.getContext(k), checks);
|
2893 | });
|
2894 | return checks;
|
2895 | }
|
2896 | function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks) {
|
2897 | if (checks === void 0) { checks = {
|
2898 | canDeactivateChecks: [],
|
2899 | canActivateChecks: []
|
2900 | }; }
|
2901 | var future = futureNode.value;
|
2902 | var curr = currNode ? currNode.value : null;
|
2903 | var context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
|
2904 |
|
2905 | if (curr && future.routeConfig === curr.routeConfig) {
|
2906 | var shouldRun = shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
|
2907 | if (shouldRun) {
|
2908 | checks.canActivateChecks.push(new CanActivate(futurePath));
|
2909 | }
|
2910 | else {
|
2911 |
|
2912 | future.data = curr.data;
|
2913 | future._resolvedData = curr._resolvedData;
|
2914 | }
|
2915 |
|
2916 | if (future.component) {
|
2917 | getChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath, checks);
|
2918 |
|
2919 | }
|
2920 | else {
|
2921 | getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks);
|
2922 | }
|
2923 | if (shouldRun) {
|
2924 | var component = context && context.outlet && context.outlet.component || null;
|
2925 | checks.canDeactivateChecks.push(new CanDeactivate(component, curr));
|
2926 | }
|
2927 | }
|
2928 | else {
|
2929 | if (curr) {
|
2930 | deactivateRouteAndItsChildren(currNode, context, checks);
|
2931 | }
|
2932 | checks.canActivateChecks.push(new CanActivate(futurePath));
|
2933 |
|
2934 | if (future.component) {
|
2935 | getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks);
|
2936 |
|
2937 | }
|
2938 | else {
|
2939 | getChildRouteGuards(futureNode, null, parentContexts, futurePath, checks);
|
2940 | }
|
2941 | }
|
2942 | return checks;
|
2943 | }
|
2944 | function shouldRunGuardsAndResolvers(curr, future, mode) {
|
2945 | if (typeof mode === 'function') {
|
2946 | return mode(curr, future);
|
2947 | }
|
2948 | switch (mode) {
|
2949 | case 'pathParamsChange':
|
2950 | return !equalPath(curr.url, future.url);
|
2951 | case 'pathParamsOrQueryParamsChange':
|
2952 | return !equalPath(curr.url, future.url) ||
|
2953 | !shallowEqual(curr.queryParams, future.queryParams);
|
2954 | case 'always':
|
2955 | return true;
|
2956 | case 'paramsOrQueryParamsChange':
|
2957 | return !equalParamsAndUrlSegments(curr, future) ||
|
2958 | !shallowEqual(curr.queryParams, future.queryParams);
|
2959 | case 'paramsChange':
|
2960 | default:
|
2961 | return !equalParamsAndUrlSegments(curr, future);
|
2962 | }
|
2963 | }
|
2964 | function deactivateRouteAndItsChildren(route, context, checks) {
|
2965 | var children = nodeChildrenAsMap(route);
|
2966 | var r = route.value;
|
2967 | forEach(children, function (node, childName) {
|
2968 | if (!r.component) {
|
2969 | deactivateRouteAndItsChildren(node, context, checks);
|
2970 | }
|
2971 | else if (context) {
|
2972 | deactivateRouteAndItsChildren(node, context.children.getContext(childName), checks);
|
2973 | }
|
2974 | else {
|
2975 | deactivateRouteAndItsChildren(node, null, checks);
|
2976 | }
|
2977 | });
|
2978 | if (!r.component) {
|
2979 | checks.canDeactivateChecks.push(new CanDeactivate(null, r));
|
2980 | }
|
2981 | else if (context && context.outlet && context.outlet.isActivated) {
|
2982 | checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
|
2983 | }
|
2984 | else {
|
2985 | checks.canDeactivateChecks.push(new CanDeactivate(null, r));
|
2986 | }
|
2987 | }
|
2988 |
|
2989 |
|
2990 |
|
2991 |
|
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 | var INITIAL_VALUE = Symbol('INITIAL_VALUE');
|
2997 | function prioritizedGuardValue() {
|
2998 | return switchMap(function (obs) {
|
2999 | return combineLatest.apply(void 0, __spread(obs.map(function (o) { return o.pipe(take(1), startWith(INITIAL_VALUE)); }))).pipe(scan(function (acc, list) {
|
3000 | var isPending = false;
|
3001 | return list.reduce(function (innerAcc, val, i) {
|
3002 | if (innerAcc !== INITIAL_VALUE)
|
3003 | return innerAcc;
|
3004 |
|
3005 | if (val === INITIAL_VALUE)
|
3006 | isPending = true;
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 | if (!isPending) {
|
3012 |
|
3013 |
|
3014 | if (val === false)
|
3015 | return val;
|
3016 | if (i === list.length - 1 || isUrlTree(val)) {
|
3017 | return val;
|
3018 | }
|
3019 | }
|
3020 | return innerAcc;
|
3021 | }, acc);
|
3022 | }, INITIAL_VALUE), filter(function (item) { return item !== INITIAL_VALUE; }), map(function (item) { return isUrlTree(item) ? item : item === true; }),
|
3023 | take(1));
|
3024 | });
|
3025 | }
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 |
|
3034 | function checkGuards(moduleInjector, forwardEvent) {
|
3035 | return function (source) {
|
3036 | return source.pipe(mergeMap(function (t) {
|
3037 | var targetSnapshot = t.targetSnapshot, currentSnapshot = t.currentSnapshot, _a = t.guards, canActivateChecks = _a.canActivateChecks, canDeactivateChecks = _a.canDeactivateChecks;
|
3038 | if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
|
3039 | return of(__assign(__assign({}, t), { guardsResult: true }));
|
3040 | }
|
3041 | return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, moduleInjector)
|
3042 | .pipe(mergeMap(function (canDeactivate) {
|
3043 | return canDeactivate && isBoolean(canDeactivate) ?
|
3044 | runCanActivateChecks(targetSnapshot, canActivateChecks, moduleInjector, forwardEvent) :
|
3045 | of(canDeactivate);
|
3046 | }), map(function (guardsResult) { return (__assign(__assign({}, t), { guardsResult: guardsResult })); }));
|
3047 | }));
|
3048 | };
|
3049 | }
|
3050 | function runCanDeactivateChecks(checks, futureRSS, currRSS, moduleInjector) {
|
3051 | return from(checks).pipe(mergeMap(function (check) {
|
3052 | return runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector);
|
3053 | }), first(function (result) { return result !== true; }, true));
|
3054 | }
|
3055 | function runCanActivateChecks(futureSnapshot, checks, moduleInjector, forwardEvent) {
|
3056 | return from(checks).pipe(concatMap(function (check) {
|
3057 | return from([
|
3058 | fireChildActivationStart(check.route.parent, forwardEvent),
|
3059 | fireActivationStart(check.route, forwardEvent),
|
3060 | runCanActivateChild(futureSnapshot, check.path, moduleInjector),
|
3061 | runCanActivate(futureSnapshot, check.route, moduleInjector)
|
3062 | ])
|
3063 | .pipe(concatAll(), first(function (result) {
|
3064 | return result !== true;
|
3065 | }, true));
|
3066 | }), first(function (result) { return result !== true; }, true));
|
3067 | }
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 | function fireActivationStart(snapshot, forwardEvent) {
|
3077 | if (snapshot !== null && forwardEvent) {
|
3078 | forwardEvent(new ActivationStart(snapshot));
|
3079 | }
|
3080 | return of(true);
|
3081 | }
|
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 | function fireChildActivationStart(snapshot, forwardEvent) {
|
3091 | if (snapshot !== null && forwardEvent) {
|
3092 | forwardEvent(new ChildActivationStart(snapshot));
|
3093 | }
|
3094 | return of(true);
|
3095 | }
|
3096 | function runCanActivate(futureRSS, futureARS, moduleInjector) {
|
3097 | var canActivate = futureARS.routeConfig ? futureARS.routeConfig.canActivate : null;
|
3098 | if (!canActivate || canActivate.length === 0)
|
3099 | return of(true);
|
3100 | var canActivateObservables = canActivate.map(function (c) {
|
3101 | return defer(function () {
|
3102 | var guard = getToken(c, futureARS, moduleInjector);
|
3103 | var observable;
|
3104 | if (isCanActivate(guard)) {
|
3105 | observable = wrapIntoObservable(guard.canActivate(futureARS, futureRSS));
|
3106 | }
|
3107 | else if (isFunction(guard)) {
|
3108 | observable = wrapIntoObservable(guard(futureARS, futureRSS));
|
3109 | }
|
3110 | else {
|
3111 | throw new Error('Invalid CanActivate guard');
|
3112 | }
|
3113 | return observable.pipe(first());
|
3114 | });
|
3115 | });
|
3116 | return of(canActivateObservables).pipe(prioritizedGuardValue());
|
3117 | }
|
3118 | function runCanActivateChild(futureRSS, path, moduleInjector) {
|
3119 | var futureARS = path[path.length - 1];
|
3120 | var canActivateChildGuards = path.slice(0, path.length - 1)
|
3121 | .reverse()
|
3122 | .map(function (p) { return getCanActivateChild(p); })
|
3123 | .filter(function (_) { return _ !== null; });
|
3124 | var canActivateChildGuardsMapped = canActivateChildGuards.map(function (d) {
|
3125 | return defer(function () {
|
3126 | var guardsMapped = d.guards.map(function (c) {
|
3127 | var guard = getToken(c, d.node, moduleInjector);
|
3128 | var observable;
|
3129 | if (isCanActivateChild(guard)) {
|
3130 | observable = wrapIntoObservable(guard.canActivateChild(futureARS, futureRSS));
|
3131 | }
|
3132 | else if (isFunction(guard)) {
|
3133 | observable = wrapIntoObservable(guard(futureARS, futureRSS));
|
3134 | }
|
3135 | else {
|
3136 | throw new Error('Invalid CanActivateChild guard');
|
3137 | }
|
3138 | return observable.pipe(first());
|
3139 | });
|
3140 | return of(guardsMapped).pipe(prioritizedGuardValue());
|
3141 | });
|
3142 | });
|
3143 | return of(canActivateChildGuardsMapped).pipe(prioritizedGuardValue());
|
3144 | }
|
3145 | function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector) {
|
3146 | var canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
|
3147 | if (!canDeactivate || canDeactivate.length === 0)
|
3148 | return of(true);
|
3149 | var canDeactivateObservables = canDeactivate.map(function (c) {
|
3150 | var guard = getToken(c, currARS, moduleInjector);
|
3151 | var observable;
|
3152 | if (isCanDeactivate(guard)) {
|
3153 | observable =
|
3154 | wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
|
3155 | }
|
3156 | else if (isFunction(guard)) {
|
3157 | observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
|
3158 | }
|
3159 | else {
|
3160 | throw new Error('Invalid CanDeactivate guard');
|
3161 | }
|
3162 | return observable.pipe(first());
|
3163 | });
|
3164 | return of(canDeactivateObservables).pipe(prioritizedGuardValue());
|
3165 | }
|
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 |
|
3171 |
|
3172 |
|
3173 |
|
3174 | var NoMatch$1 = (function () {
|
3175 | function NoMatch() {
|
3176 | }
|
3177 | return NoMatch;
|
3178 | }());
|
3179 | function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
|
3180 | if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
|
3181 | if (relativeLinkResolution === void 0) { relativeLinkResolution = 'legacy'; }
|
3182 | return new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
|
3183 | .recognize();
|
3184 | }
|
3185 | var Recognizer = (function () {
|
3186 | function Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
|
3187 | this.rootComponentType = rootComponentType;
|
3188 | this.config = config;
|
3189 | this.urlTree = urlTree;
|
3190 | this.url = url;
|
3191 | this.paramsInheritanceStrategy = paramsInheritanceStrategy;
|
3192 | this.relativeLinkResolution = relativeLinkResolution;
|
3193 | }
|
3194 | Recognizer.prototype.recognize = function () {
|
3195 | try {
|
3196 | var rootSegmentGroup = split$1(this.urlTree.root, [], [], this.config, this.relativeLinkResolution).segmentGroup;
|
3197 | var children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
|
3198 | var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
|
3199 | var rootNode = new TreeNode(root, children);
|
3200 | var routeState = new RouterStateSnapshot(this.url, rootNode);
|
3201 | this.inheritParamsAndData(routeState._root);
|
3202 | return of(routeState);
|
3203 | }
|
3204 | catch (e) {
|
3205 | return new Observable(function (obs) { return obs.error(e); });
|
3206 | }
|
3207 | };
|
3208 | Recognizer.prototype.inheritParamsAndData = function (routeNode) {
|
3209 | var _this = this;
|
3210 | var route = routeNode.value;
|
3211 | var i = inheritedParamsDataResolve(route, this.paramsInheritanceStrategy);
|
3212 | route.params = Object.freeze(i.params);
|
3213 | route.data = Object.freeze(i.data);
|
3214 | routeNode.children.forEach(function (n) { return _this.inheritParamsAndData(n); });
|
3215 | };
|
3216 | Recognizer.prototype.processSegmentGroup = function (config, segmentGroup, outlet) {
|
3217 | if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
|
3218 | return this.processChildren(config, segmentGroup);
|
3219 | }
|
3220 | return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
|
3221 | };
|
3222 | Recognizer.prototype.processChildren = function (config, segmentGroup) {
|
3223 | var _this = this;
|
3224 | var children = mapChildrenIntoArray(segmentGroup, function (child, childOutlet) { return _this.processSegmentGroup(config, child, childOutlet); });
|
3225 | checkOutletNameUniqueness(children);
|
3226 | sortActivatedRouteSnapshots(children);
|
3227 | return children;
|
3228 | };
|
3229 | Recognizer.prototype.processSegment = function (config, segmentGroup, segments, outlet) {
|
3230 | var e_1, _a;
|
3231 | try {
|
3232 | for (var config_1 = __values(config), config_1_1 = config_1.next(); !config_1_1.done; config_1_1 = config_1.next()) {
|
3233 | var r = config_1_1.value;
|
3234 | try {
|
3235 | return this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
|
3236 | }
|
3237 | catch (e) {
|
3238 | if (!(e instanceof NoMatch$1))
|
3239 | throw e;
|
3240 | }
|
3241 | }
|
3242 | }
|
3243 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
3244 | finally {
|
3245 | try {
|
3246 | if (config_1_1 && !config_1_1.done && (_a = config_1.return)) _a.call(config_1);
|
3247 | }
|
3248 | finally { if (e_1) throw e_1.error; }
|
3249 | }
|
3250 | if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
3251 | return [];
|
3252 | }
|
3253 | throw new NoMatch$1();
|
3254 | };
|
3255 | Recognizer.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
|
3256 | return segments.length === 0 && !segmentGroup.children[outlet];
|
3257 | };
|
3258 | Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, segments, outlet) {
|
3259 | if (route.redirectTo)
|
3260 | throw new NoMatch$1();
|
3261 | if ((route.outlet || PRIMARY_OUTLET) !== outlet)
|
3262 | throw new NoMatch$1();
|
3263 | var snapshot;
|
3264 | var consumedSegments = [];
|
3265 | var rawSlicedSegments = [];
|
3266 | if (route.path === '**') {
|
3267 | var params = segments.length > 0 ? last(segments).parameters : {};
|
3268 | snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, getResolve(route));
|
3269 | }
|
3270 | else {
|
3271 | var result = match$1(rawSegment, route, segments);
|
3272 | consumedSegments = result.consumedSegments;
|
3273 | rawSlicedSegments = segments.slice(result.lastChild);
|
3274 | snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route));
|
3275 | }
|
3276 | var childConfig = getChildConfig(route);
|
3277 | var _a = split$1(rawSegment, consumedSegments, rawSlicedSegments, childConfig, this.relativeLinkResolution), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
|
3278 | if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
3279 | var children_1 = this.processChildren(childConfig, segmentGroup);
|
3280 | return [new TreeNode(snapshot, children_1)];
|
3281 | }
|
3282 | if (childConfig.length === 0 && slicedSegments.length === 0) {
|
3283 | return [new TreeNode(snapshot, [])];
|
3284 | }
|
3285 | var children = this.processSegment(childConfig, segmentGroup, slicedSegments, PRIMARY_OUTLET);
|
3286 | return [new TreeNode(snapshot, children)];
|
3287 | };
|
3288 | return Recognizer;
|
3289 | }());
|
3290 | function sortActivatedRouteSnapshots(nodes) {
|
3291 | nodes.sort(function (a, b) {
|
3292 | if (a.value.outlet === PRIMARY_OUTLET)
|
3293 | return -1;
|
3294 | if (b.value.outlet === PRIMARY_OUTLET)
|
3295 | return 1;
|
3296 | return a.value.outlet.localeCompare(b.value.outlet);
|
3297 | });
|
3298 | }
|
3299 | function getChildConfig(route) {
|
3300 | if (route.children) {
|
3301 | return route.children;
|
3302 | }
|
3303 | if (route.loadChildren) {
|
3304 | return route._loadedConfig.routes;
|
3305 | }
|
3306 | return [];
|
3307 | }
|
3308 | function match$1(segmentGroup, route, segments) {
|
3309 | if (route.path === '') {
|
3310 | if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
|
3311 | throw new NoMatch$1();
|
3312 | }
|
3313 | return { consumedSegments: [], lastChild: 0, parameters: {} };
|
3314 | }
|
3315 | var matcher = route.matcher || defaultUrlMatcher;
|
3316 | var res = matcher(segments, segmentGroup, route);
|
3317 | if (!res)
|
3318 | throw new NoMatch$1();
|
3319 | var posParams = {};
|
3320 | forEach(res.posParams, function (v, k) { posParams[k] = v.path; });
|
3321 | var parameters = res.consumed.length > 0 ? __assign(__assign({}, posParams), res.consumed[res.consumed.length - 1].parameters) :
|
3322 | posParams;
|
3323 | return { consumedSegments: res.consumed, lastChild: res.consumed.length, parameters: parameters };
|
3324 | }
|
3325 | function checkOutletNameUniqueness(nodes) {
|
3326 | var names = {};
|
3327 | nodes.forEach(function (n) {
|
3328 | var routeWithSameOutletName = names[n.value.outlet];
|
3329 | if (routeWithSameOutletName) {
|
3330 | var p = routeWithSameOutletName.url.map(function (s) { return s.toString(); }).join('/');
|
3331 | var c = n.value.url.map(function (s) { return s.toString(); }).join('/');
|
3332 | throw new Error("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
|
3333 | }
|
3334 | names[n.value.outlet] = n.value;
|
3335 | });
|
3336 | }
|
3337 | function getSourceSegmentGroup(segmentGroup) {
|
3338 | var s = segmentGroup;
|
3339 | while (s._sourceSegment) {
|
3340 | s = s._sourceSegment;
|
3341 | }
|
3342 | return s;
|
3343 | }
|
3344 | function getPathIndexShift(segmentGroup) {
|
3345 | var s = segmentGroup;
|
3346 | var res = (s._segmentIndexShift ? s._segmentIndexShift : 0);
|
3347 | while (s._sourceSegment) {
|
3348 | s = s._sourceSegment;
|
3349 | res += (s._segmentIndexShift ? s._segmentIndexShift : 0);
|
3350 | }
|
3351 | return res - 1;
|
3352 | }
|
3353 | function split$1(segmentGroup, consumedSegments, slicedSegments, config, relativeLinkResolution) {
|
3354 | if (slicedSegments.length > 0 &&
|
3355 | containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
3356 | var s_1 = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
3357 | s_1._sourceSegment = segmentGroup;
|
3358 | s_1._segmentIndexShift = consumedSegments.length;
|
3359 | return { segmentGroup: s_1, slicedSegments: [] };
|
3360 | }
|
3361 | if (slicedSegments.length === 0 &&
|
3362 | containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
|
3363 | var s_2 = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, config, segmentGroup.children, relativeLinkResolution));
|
3364 | s_2._sourceSegment = segmentGroup;
|
3365 | s_2._segmentIndexShift = consumedSegments.length;
|
3366 | return { segmentGroup: s_2, slicedSegments: slicedSegments };
|
3367 | }
|
3368 | var s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
|
3369 | s._sourceSegment = segmentGroup;
|
3370 | s._segmentIndexShift = consumedSegments.length;
|
3371 | return { segmentGroup: s, slicedSegments: slicedSegments };
|
3372 | }
|
3373 | function addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, routes, children, relativeLinkResolution) {
|
3374 | var e_2, _a;
|
3375 | var res = {};
|
3376 | try {
|
3377 | for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
|
3378 | var r = routes_1_1.value;
|
3379 | if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet$1(r)]) {
|
3380 | var s = new UrlSegmentGroup([], {});
|
3381 | s._sourceSegment = segmentGroup;
|
3382 | if (relativeLinkResolution === 'legacy') {
|
3383 | s._segmentIndexShift = segmentGroup.segments.length;
|
3384 | }
|
3385 | else {
|
3386 | s._segmentIndexShift = consumedSegments.length;
|
3387 | }
|
3388 | res[getOutlet$1(r)] = s;
|
3389 | }
|
3390 | }
|
3391 | }
|
3392 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
3393 | finally {
|
3394 | try {
|
3395 | if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
3396 | }
|
3397 | finally { if (e_2) throw e_2.error; }
|
3398 | }
|
3399 | return __assign(__assign({}, children), res);
|
3400 | }
|
3401 | function createChildrenForEmptyPaths(segmentGroup, consumedSegments, routes, primarySegment) {
|
3402 | var e_3, _a;
|
3403 | var res = {};
|
3404 | res[PRIMARY_OUTLET] = primarySegment;
|
3405 | primarySegment._sourceSegment = segmentGroup;
|
3406 | primarySegment._segmentIndexShift = consumedSegments.length;
|
3407 | try {
|
3408 | for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
|
3409 | var r = routes_2_1.value;
|
3410 | if (r.path === '' && getOutlet$1(r) !== PRIMARY_OUTLET) {
|
3411 | var s = new UrlSegmentGroup([], {});
|
3412 | s._sourceSegment = segmentGroup;
|
3413 | s._segmentIndexShift = consumedSegments.length;
|
3414 | res[getOutlet$1(r)] = s;
|
3415 | }
|
3416 | }
|
3417 | }
|
3418 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
3419 | finally {
|
3420 | try {
|
3421 | if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
3422 | }
|
3423 | finally { if (e_3) throw e_3.error; }
|
3424 | }
|
3425 | return res;
|
3426 | }
|
3427 | function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
|
3428 | return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet$1(r) !== PRIMARY_OUTLET; });
|
3429 | }
|
3430 | function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
|
3431 | return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r); });
|
3432 | }
|
3433 | function emptyPathMatch(segmentGroup, slicedSegments, r) {
|
3434 | if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
|
3435 | return false;
|
3436 | }
|
3437 | return r.path === '' && r.redirectTo === undefined;
|
3438 | }
|
3439 | function getOutlet$1(route) {
|
3440 | return route.outlet || PRIMARY_OUTLET;
|
3441 | }
|
3442 | function getData(route) {
|
3443 | return route.data || {};
|
3444 | }
|
3445 | function getResolve(route) {
|
3446 | return route.resolve || {};
|
3447 | }
|
3448 |
|
3449 |
|
3450 |
|
3451 |
|
3452 |
|
3453 |
|
3454 |
|
3455 |
|
3456 | function recognize$1(rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
|
3457 | return function (source) {
|
3458 | return source.pipe(mergeMap(function (t) { return recognize(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
|
3459 | .pipe(map(function (targetSnapshot) { return (__assign(__assign({}, t), { targetSnapshot: targetSnapshot })); })); }));
|
3460 | };
|
3461 | }
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 |
|
3469 |
|
3470 | function resolveData(paramsInheritanceStrategy, moduleInjector) {
|
3471 | return function (source) {
|
3472 | return source.pipe(mergeMap(function (t) {
|
3473 | var targetSnapshot = t.targetSnapshot, canActivateChecks = t.guards.canActivateChecks;
|
3474 | if (!canActivateChecks.length) {
|
3475 | return of(t);
|
3476 | }
|
3477 | return from(canActivateChecks)
|
3478 | .pipe(concatMap(function (check) { return runResolve(check.route, targetSnapshot, paramsInheritanceStrategy, moduleInjector); }), reduce(function (_, __) { return _; }), map(function (_) { return t; }));
|
3479 | }));
|
3480 | };
|
3481 | }
|
3482 | function runResolve(futureARS, futureRSS, paramsInheritanceStrategy, moduleInjector) {
|
3483 | var resolve = futureARS._resolve;
|
3484 | return resolveNode(resolve, futureARS, futureRSS, moduleInjector)
|
3485 | .pipe(map(function (resolvedData) {
|
3486 | futureARS._resolvedData = resolvedData;
|
3487 | futureARS.data = __assign(__assign({}, futureARS.data), inheritedParamsDataResolve(futureARS, paramsInheritanceStrategy).resolve);
|
3488 | return null;
|
3489 | }));
|
3490 | }
|
3491 | function resolveNode(resolve, futureARS, futureRSS, moduleInjector) {
|
3492 | var keys = Object.keys(resolve);
|
3493 | if (keys.length === 0) {
|
3494 | return of({});
|
3495 | }
|
3496 | if (keys.length === 1) {
|
3497 | var key_1 = keys[0];
|
3498 | return getResolver(resolve[key_1], futureARS, futureRSS, moduleInjector)
|
3499 | .pipe(map(function (value) {
|
3500 | var _a;
|
3501 | return _a = {}, _a[key_1] = value, _a;
|
3502 | }));
|
3503 | }
|
3504 | var data = {};
|
3505 | var runningResolvers$ = from(keys).pipe(mergeMap(function (key) {
|
3506 | return getResolver(resolve[key], futureARS, futureRSS, moduleInjector)
|
3507 | .pipe(map(function (value) {
|
3508 | data[key] = value;
|
3509 | return value;
|
3510 | }));
|
3511 | }));
|
3512 | return runningResolvers$.pipe(last$1(), map(function () { return data; }));
|
3513 | }
|
3514 | function getResolver(injectionToken, futureARS, futureRSS, moduleInjector) {
|
3515 | var resolver = getToken(injectionToken, futureARS, moduleInjector);
|
3516 | return resolver.resolve ? wrapIntoObservable(resolver.resolve(futureARS, futureRSS)) :
|
3517 | wrapIntoObservable(resolver(futureARS, futureRSS));
|
3518 | }
|
3519 |
|
3520 |
|
3521 |
|
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 |
|
3533 | function switchTap(next) {
|
3534 | return function (source) {
|
3535 | return source.pipe(switchMap(function (v) {
|
3536 | var nextResult = next(v);
|
3537 | if (nextResult) {
|
3538 | return from(nextResult).pipe(map(function () { return v; }));
|
3539 | }
|
3540 | return from([v]);
|
3541 | }));
|
3542 | };
|
3543 | }
|
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 |
|
3557 |
|
3558 |
|
3559 | var RouteReuseStrategy = (function () {
|
3560 | function RouteReuseStrategy() {
|
3561 | }
|
3562 | return RouteReuseStrategy;
|
3563 | }());
|
3564 |
|
3565 |
|
3566 |
|
3567 | var DefaultRouteReuseStrategy = (function () {
|
3568 | function DefaultRouteReuseStrategy() {
|
3569 | }
|
3570 | DefaultRouteReuseStrategy.prototype.shouldDetach = function (route) { return false; };
|
3571 | DefaultRouteReuseStrategy.prototype.store = function (route, detachedTree) { };
|
3572 | DefaultRouteReuseStrategy.prototype.shouldAttach = function (route) { return false; };
|
3573 | DefaultRouteReuseStrategy.prototype.retrieve = function (route) { return null; };
|
3574 | DefaultRouteReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
|
3575 | return future.routeConfig === curr.routeConfig;
|
3576 | };
|
3577 | return DefaultRouteReuseStrategy;
|
3578 | }());
|
3579 |
|
3580 |
|
3581 |
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 | var ROUTES = new InjectionToken('ROUTES');
|
3593 | var RouterConfigLoader = (function () {
|
3594 | function RouterConfigLoader(loader, compiler, onLoadStartListener, onLoadEndListener) {
|
3595 | this.loader = loader;
|
3596 | this.compiler = compiler;
|
3597 | this.onLoadStartListener = onLoadStartListener;
|
3598 | this.onLoadEndListener = onLoadEndListener;
|
3599 | }
|
3600 | RouterConfigLoader.prototype.load = function (parentInjector, route) {
|
3601 | var _this = this;
|
3602 | if (this.onLoadStartListener) {
|
3603 | this.onLoadStartListener(route);
|
3604 | }
|
3605 | var moduleFactory$ = this.loadModuleFactory(route.loadChildren);
|
3606 | return moduleFactory$.pipe(map(function (factory) {
|
3607 | if (_this.onLoadEndListener) {
|
3608 | _this.onLoadEndListener(route);
|
3609 | }
|
3610 | var module = factory.create(parentInjector);
|
3611 | return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(standardizeConfig), module);
|
3612 | }));
|
3613 | };
|
3614 | RouterConfigLoader.prototype.loadModuleFactory = function (loadChildren) {
|
3615 | var _this = this;
|
3616 | if (typeof loadChildren === 'string') {
|
3617 | return from(this.loader.load(loadChildren));
|
3618 | }
|
3619 | else {
|
3620 | return wrapIntoObservable(loadChildren()).pipe(mergeMap(function (t) {
|
3621 | if (t instanceof NgModuleFactory) {
|
3622 | return of(t);
|
3623 | }
|
3624 | else {
|
3625 | return from(_this.compiler.compileModuleAsync(t));
|
3626 | }
|
3627 | }));
|
3628 | }
|
3629 | };
|
3630 | return RouterConfigLoader;
|
3631 | }());
|
3632 |
|
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 |
|
3639 |
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 | var UrlHandlingStrategy = (function () {
|
3648 | function UrlHandlingStrategy() {
|
3649 | }
|
3650 | return UrlHandlingStrategy;
|
3651 | }());
|
3652 |
|
3653 |
|
3654 |
|
3655 | var DefaultUrlHandlingStrategy = (function () {
|
3656 | function DefaultUrlHandlingStrategy() {
|
3657 | }
|
3658 | DefaultUrlHandlingStrategy.prototype.shouldProcessUrl = function (url) { return true; };
|
3659 | DefaultUrlHandlingStrategy.prototype.extract = function (url) { return url; };
|
3660 | DefaultUrlHandlingStrategy.prototype.merge = function (newUrlPart, wholeUrl) { return newUrlPart; };
|
3661 | return DefaultUrlHandlingStrategy;
|
3662 | }());
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 |
|
3669 |
|
3670 |
|
3671 | function defaultErrorHandler(error) {
|
3672 | throw error;
|
3673 | }
|
3674 | function defaultMalformedUriErrorHandler(error, urlSerializer, url) {
|
3675 | return urlSerializer.parse('/');
|
3676 | }
|
3677 |
|
3678 |
|
3679 |
|
3680 | function defaultRouterHook(snapshot, runExtras) {
|
3681 | return of(null);
|
3682 | }
|
3683 |
|
3684 |
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 |
|
3690 |
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 | var Router = (function () {
|
3696 | |
3697 |
|
3698 |
|
3699 |
|
3700 | function Router(rootComponentType, urlSerializer, rootContexts, location, injector, loader, compiler, config) {
|
3701 | var _this = this;
|
3702 | this.rootComponentType = rootComponentType;
|
3703 | this.urlSerializer = urlSerializer;
|
3704 | this.rootContexts = rootContexts;
|
3705 | this.location = location;
|
3706 | this.config = config;
|
3707 | this.lastSuccessfulNavigation = null;
|
3708 | this.currentNavigation = null;
|
3709 | this.navigationId = 0;
|
3710 | this.isNgZoneEnabled = false;
|
3711 | |
3712 |
|
3713 |
|
3714 | this.events = new Subject();
|
3715 | |
3716 |
|
3717 |
|
3718 | this.errorHandler = defaultErrorHandler;
|
3719 | |
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 | this.malformedUriErrorHandler = defaultMalformedUriErrorHandler;
|
3726 | |
3727 |
|
3728 |
|
3729 |
|
3730 | this.navigated = false;
|
3731 | this.lastSuccessfulId = -1;
|
3732 | |
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 | this.hooks = {
|
3740 | beforePreactivation: defaultRouterHook,
|
3741 | afterPreactivation: defaultRouterHook
|
3742 | };
|
3743 | |
3744 |
|
3745 |
|
3746 |
|
3747 | this.urlHandlingStrategy = new DefaultUrlHandlingStrategy();
|
3748 | |
3749 |
|
3750 |
|
3751 | this.routeReuseStrategy = new DefaultRouteReuseStrategy();
|
3752 | |
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 | this.onSameUrlNavigation = 'ignore';
|
3758 | |
3759 |
|
3760 |
|
3761 |
|
3762 |
|
3763 |
|
3764 |
|
3765 |
|
3766 |
|
3767 | this.paramsInheritanceStrategy = 'emptyOnly';
|
3768 | |
3769 |
|
3770 |
|
3771 |
|
3772 |
|
3773 |
|
3774 |
|
3775 | this.urlUpdateStrategy = 'deferred';
|
3776 | |
3777 |
|
3778 |
|
3779 |
|
3780 | this.relativeLinkResolution = 'legacy';
|
3781 | var onLoadStart = function (r) { return _this.triggerEvent(new RouteConfigLoadStart(r)); };
|
3782 | var onLoadEnd = function (r) { return _this.triggerEvent(new RouteConfigLoadEnd(r)); };
|
3783 | this.ngModule = injector.get(NgModuleRef);
|
3784 | this.console = injector.get(ɵConsole);
|
3785 | var ngZone = injector.get(NgZone);
|
3786 | this.isNgZoneEnabled = ngZone instanceof NgZone;
|
3787 | this.resetConfig(config);
|
3788 | this.currentUrlTree = createEmptyUrlTree();
|
3789 | this.rawUrlTree = this.currentUrlTree;
|
3790 | this.browserUrlTree = this.currentUrlTree;
|
3791 | this.configLoader = new RouterConfigLoader(loader, compiler, onLoadStart, onLoadEnd);
|
3792 | this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
|
3793 | this.transitions = new BehaviorSubject({
|
3794 | id: 0,
|
3795 | currentUrlTree: this.currentUrlTree,
|
3796 | currentRawUrl: this.currentUrlTree,
|
3797 | extractedUrl: this.urlHandlingStrategy.extract(this.currentUrlTree),
|
3798 | urlAfterRedirects: this.urlHandlingStrategy.extract(this.currentUrlTree),
|
3799 | rawUrl: this.currentUrlTree,
|
3800 | extras: {},
|
3801 | resolve: null,
|
3802 | reject: null,
|
3803 | promise: Promise.resolve(true),
|
3804 | source: 'imperative',
|
3805 | restoredState: null,
|
3806 | currentSnapshot: this.routerState.snapshot,
|
3807 | targetSnapshot: null,
|
3808 | currentRouterState: this.routerState,
|
3809 | targetRouterState: null,
|
3810 | guards: { canActivateChecks: [], canDeactivateChecks: [] },
|
3811 | guardsResult: null,
|
3812 | });
|
3813 | this.navigations = this.setupNavigations(this.transitions);
|
3814 | this.processNavigations();
|
3815 | }
|
3816 | Router.prototype.setupNavigations = function (transitions) {
|
3817 | var _this = this;
|
3818 | var eventsSubject = this.events;
|
3819 | return transitions.pipe(filter(function (t) { return t.id !== 0; }),
|
3820 |
|
3821 | map(function (t) { return (__assign(__assign({}, t), { extractedUrl: _this.urlHandlingStrategy.extract(t.rawUrl) })); }),
|
3822 |
|
3823 | switchMap(function (t) {
|
3824 | var completed = false;
|
3825 | var errored = false;
|
3826 | return of(t).pipe(
|
3827 |
|
3828 | tap(function (t) {
|
3829 | _this.currentNavigation = {
|
3830 | id: t.id,
|
3831 | initialUrl: t.currentRawUrl,
|
3832 | extractedUrl: t.extractedUrl,
|
3833 | trigger: t.source,
|
3834 | extras: t.extras,
|
3835 | previousNavigation: _this.lastSuccessfulNavigation ? __assign(__assign({}, _this.lastSuccessfulNavigation), { previousNavigation: null }) :
|
3836 | null
|
3837 | };
|
3838 | }), switchMap(function (t) {
|
3839 | var urlTransition = !_this.navigated || t.extractedUrl.toString() !== _this.browserUrlTree.toString();
|
3840 | var processCurrentUrl = (_this.onSameUrlNavigation === 'reload' ? true : urlTransition) &&
|
3841 | _this.urlHandlingStrategy.shouldProcessUrl(t.rawUrl);
|
3842 | if (processCurrentUrl) {
|
3843 | return of(t).pipe(
|
3844 |
|
3845 | switchMap(function (t) {
|
3846 | var transition = _this.transitions.getValue();
|
3847 | eventsSubject.next(new NavigationStart(t.id, _this.serializeUrl(t.extractedUrl), t.source, t.restoredState));
|
3848 | if (transition !== _this.transitions.getValue()) {
|
3849 | return EMPTY;
|
3850 | }
|
3851 | return [t];
|
3852 | }),
|
3853 |
|
3854 |
|
3855 | switchMap(function (t) { return Promise.resolve(t); }),
|
3856 |
|
3857 | applyRedirects$1(_this.ngModule.injector, _this.configLoader, _this.urlSerializer, _this.config),
|
3858 |
|
3859 | tap(function (t) {
|
3860 | _this.currentNavigation = __assign(__assign({}, _this.currentNavigation), { finalUrl: t.urlAfterRedirects });
|
3861 | }),
|
3862 |
|
3863 | recognize$1(_this.rootComponentType, _this.config, function (url) { return _this.serializeUrl(url); }, _this.paramsInheritanceStrategy, _this.relativeLinkResolution),
|
3864 |
|
3865 | tap(function (t) {
|
3866 | if (_this.urlUpdateStrategy === 'eager') {
|
3867 | if (!t.extras.skipLocationChange) {
|
3868 | _this.setBrowserUrl(t.urlAfterRedirects, !!t.extras.replaceUrl, t.id, t.extras.state);
|
3869 | }
|
3870 | _this.browserUrlTree = t.urlAfterRedirects;
|
3871 | }
|
3872 | }),
|
3873 |
|
3874 | tap(function (t) {
|
3875 | var routesRecognized = new RoutesRecognized(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
3876 | eventsSubject.next(routesRecognized);
|
3877 | }));
|
3878 | }
|
3879 | else {
|
3880 | var processPreviousUrl = urlTransition && _this.rawUrlTree &&
|
3881 | _this.urlHandlingStrategy.shouldProcessUrl(_this.rawUrlTree);
|
3882 | |
3883 |
|
3884 |
|
3885 | if (processPreviousUrl) {
|
3886 | var id = t.id, extractedUrl = t.extractedUrl, source = t.source, restoredState = t.restoredState, extras = t.extras;
|
3887 | var navStart = new NavigationStart(id, _this.serializeUrl(extractedUrl), source, restoredState);
|
3888 | eventsSubject.next(navStart);
|
3889 | var targetSnapshot = createEmptyState(extractedUrl, _this.rootComponentType).snapshot;
|
3890 | return of(__assign(__assign({}, t), { targetSnapshot: targetSnapshot, urlAfterRedirects: extractedUrl, extras: __assign(__assign({}, extras), { skipLocationChange: false, replaceUrl: false }) }));
|
3891 | }
|
3892 | else {
|
3893 | |
3894 |
|
3895 |
|
3896 |
|
3897 | _this.rawUrlTree = t.rawUrl;
|
3898 | _this.browserUrlTree = t.urlAfterRedirects;
|
3899 | t.resolve(null);
|
3900 | return EMPTY;
|
3901 | }
|
3902 | }
|
3903 | }),
|
3904 |
|
3905 | switchTap(function (t) {
|
3906 | var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _a = t.extras, skipLocationChange = _a.skipLocationChange, replaceUrl = _a.replaceUrl;
|
3907 | return _this.hooks.beforePreactivation(targetSnapshot, {
|
3908 | navigationId: navigationId,
|
3909 | appliedUrlTree: appliedUrlTree,
|
3910 | rawUrlTree: rawUrlTree,
|
3911 | skipLocationChange: !!skipLocationChange,
|
3912 | replaceUrl: !!replaceUrl,
|
3913 | });
|
3914 | }),
|
3915 |
|
3916 | tap(function (t) {
|
3917 | var guardsStart = new GuardsCheckStart(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
3918 | _this.triggerEvent(guardsStart);
|
3919 | }), map(function (t) { return (__assign(__assign({}, t), { guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, _this.rootContexts) })); }), checkGuards(_this.ngModule.injector, function (evt) { return _this.triggerEvent(evt); }), tap(function (t) {
|
3920 | if (isUrlTree(t.guardsResult)) {
|
3921 | var error = navigationCancelingError("Redirecting to \"" + _this.serializeUrl(t.guardsResult) + "\"");
|
3922 | error.url = t.guardsResult;
|
3923 | throw error;
|
3924 | }
|
3925 | }), tap(function (t) {
|
3926 | var guardsEnd = new GuardsCheckEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
|
3927 | _this.triggerEvent(guardsEnd);
|
3928 | }), filter(function (t) {
|
3929 | if (!t.guardsResult) {
|
3930 | _this.resetUrlToCurrentUrlTree();
|
3931 | var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), '');
|
3932 | eventsSubject.next(navCancel);
|
3933 | t.resolve(false);
|
3934 | return false;
|
3935 | }
|
3936 | return true;
|
3937 | }),
|
3938 |
|
3939 | switchTap(function (t) {
|
3940 | if (t.guards.canActivateChecks.length) {
|
3941 | return of(t).pipe(tap(function (t) {
|
3942 | var resolveStart = new ResolveStart(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
3943 | _this.triggerEvent(resolveStart);
|
3944 | }), resolveData(_this.paramsInheritanceStrategy, _this.ngModule.injector),
|
3945 | tap(function (t) {
|
3946 | var resolveEnd = new ResolveEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
3947 | _this.triggerEvent(resolveEnd);
|
3948 | }));
|
3949 | }
|
3950 | return undefined;
|
3951 | }),
|
3952 |
|
3953 | switchTap(function (t) {
|
3954 | var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _a = t.extras, skipLocationChange = _a.skipLocationChange, replaceUrl = _a.replaceUrl;
|
3955 | return _this.hooks.afterPreactivation(targetSnapshot, {
|
3956 | navigationId: navigationId,
|
3957 | appliedUrlTree: appliedUrlTree,
|
3958 | rawUrlTree: rawUrlTree,
|
3959 | skipLocationChange: !!skipLocationChange,
|
3960 | replaceUrl: !!replaceUrl,
|
3961 | });
|
3962 | }), map(function (t) {
|
3963 | var targetRouterState = createRouterState(_this.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
|
3964 | return (__assign(__assign({}, t), { targetRouterState: targetRouterState }));
|
3965 | }),
|
3966 | |
3967 |
|
3968 |
|
3969 |
|
3970 |
|
3971 | tap(function (t) {
|
3972 | _this.currentUrlTree = t.urlAfterRedirects;
|
3973 | _this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, t.rawUrl);
|
3974 | _this.routerState = t.targetRouterState;
|
3975 | if (_this.urlUpdateStrategy === 'deferred') {
|
3976 | if (!t.extras.skipLocationChange) {
|
3977 | _this.setBrowserUrl(_this.rawUrlTree, !!t.extras.replaceUrl, t.id, t.extras.state);
|
3978 | }
|
3979 | _this.browserUrlTree = t.urlAfterRedirects;
|
3980 | }
|
3981 | }), activateRoutes(_this.rootContexts, _this.routeReuseStrategy, function (evt) { return _this.triggerEvent(evt); }), tap({ next: function () { completed = true; }, complete: function () { completed = true; } }), finalize(function () {
|
3982 | |
3983 |
|
3984 |
|
3985 |
|
3986 |
|
3987 | if (!completed && !errored) {
|
3988 |
|
3989 |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 | _this.resetUrlToCurrentUrlTree();
|
3995 | var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), "Navigation ID " + t.id + " is not equal to the current navigation id " + _this.navigationId);
|
3996 | eventsSubject.next(navCancel);
|
3997 | t.resolve(false);
|
3998 | }
|
3999 |
|
4000 |
|
4001 |
|
4002 | _this.currentNavigation = null;
|
4003 | }), catchError(function (e) {
|
4004 | errored = true;
|
4005 | |
4006 |
|
4007 | if (isNavigationCancelingError(e)) {
|
4008 | var redirecting = isUrlTree(e.url);
|
4009 | if (!redirecting) {
|
4010 |
|
4011 |
|
4012 |
|
4013 |
|
4014 |
|
4015 | _this.navigated = true;
|
4016 | _this.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);
|
4017 | }
|
4018 | var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), e.message);
|
4019 | eventsSubject.next(navCancel);
|
4020 |
|
4021 |
|
4022 | if (!redirecting) {
|
4023 | t.resolve(false);
|
4024 | }
|
4025 | else {
|
4026 |
|
4027 |
|
4028 |
|
4029 |
|
4030 | setTimeout(function () {
|
4031 | var mergedTree = _this.urlHandlingStrategy.merge(e.url, _this.rawUrlTree);
|
4032 | var extras = {
|
4033 | skipLocationChange: t.extras.skipLocationChange,
|
4034 | replaceUrl: _this.urlUpdateStrategy === 'eager'
|
4035 | };
|
4036 | return _this.scheduleNavigation(mergedTree, 'imperative', null, extras, { resolve: t.resolve, reject: t.reject, promise: t.promise });
|
4037 | }, 0);
|
4038 | }
|
4039 | |
4040 |
|
4041 | }
|
4042 | else {
|
4043 | _this.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);
|
4044 | var navError = new NavigationError(t.id, _this.serializeUrl(t.extractedUrl), e);
|
4045 | eventsSubject.next(navError);
|
4046 | try {
|
4047 | t.resolve(_this.errorHandler(e));
|
4048 | }
|
4049 | catch (ee) {
|
4050 | t.reject(ee);
|
4051 | }
|
4052 | }
|
4053 | return EMPTY;
|
4054 | }));
|
4055 |
|
4056 | }));
|
4057 | };
|
4058 | |
4059 |
|
4060 |
|
4061 |
|
4062 | Router.prototype.resetRootComponentType = function (rootComponentType) {
|
4063 | this.rootComponentType = rootComponentType;
|
4064 |
|
4065 |
|
4066 | this.routerState.root.component = this.rootComponentType;
|
4067 | };
|
4068 | Router.prototype.getTransition = function () {
|
4069 | var transition = this.transitions.value;
|
4070 |
|
4071 |
|
4072 |
|
4073 | transition.urlAfterRedirects = this.browserUrlTree;
|
4074 | return transition;
|
4075 | };
|
4076 | Router.prototype.setTransition = function (t) {
|
4077 | this.transitions.next(__assign(__assign({}, this.getTransition()), t));
|
4078 | };
|
4079 | |
4080 |
|
4081 |
|
4082 | Router.prototype.initialNavigation = function () {
|
4083 | this.setUpLocationChangeListener();
|
4084 | if (this.navigationId === 0) {
|
4085 | this.navigateByUrl(this.location.path(true), { replaceUrl: true });
|
4086 | }
|
4087 | };
|
4088 | |
4089 |
|
4090 |
|
4091 | Router.prototype.setUpLocationChangeListener = function () {
|
4092 | var _this = this;
|
4093 |
|
4094 |
|
4095 |
|
4096 | if (!this.locationSubscription) {
|
4097 | this.locationSubscription = this.location.subscribe(function (change) {
|
4098 | var rawUrlTree = _this.parseUrl(change['url']);
|
4099 | var source = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
|
4100 |
|
4101 |
|
4102 | var state = change.state && change.state.navigationId ? change.state : null;
|
4103 | setTimeout(function () { _this.scheduleNavigation(rawUrlTree, source, state, { replaceUrl: true }); }, 0);
|
4104 | });
|
4105 | }
|
4106 | };
|
4107 | Object.defineProperty(Router.prototype, "url", {
|
4108 |
|
4109 | get: function () { return this.serializeUrl(this.currentUrlTree); },
|
4110 | enumerable: true,
|
4111 | configurable: true
|
4112 | });
|
4113 |
|
4114 | Router.prototype.getCurrentNavigation = function () { return this.currentNavigation; };
|
4115 |
|
4116 | Router.prototype.triggerEvent = function (event) { this.events.next(event); };
|
4117 | |
4118 |
|
4119 |
|
4120 |
|
4121 |
|
4122 |
|
4123 |
|
4124 |
|
4125 |
|
4126 |
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 | Router.prototype.resetConfig = function (config) {
|
4134 | validateConfig(config);
|
4135 | this.config = config.map(standardizeConfig);
|
4136 | this.navigated = false;
|
4137 | this.lastSuccessfulId = -1;
|
4138 | };
|
4139 |
|
4140 | Router.prototype.ngOnDestroy = function () { this.dispose(); };
|
4141 |
|
4142 | Router.prototype.dispose = function () {
|
4143 | if (this.locationSubscription) {
|
4144 | this.locationSubscription.unsubscribe();
|
4145 | this.locationSubscription = null;
|
4146 | }
|
4147 | };
|
4148 | |
4149 |
|
4150 |
|
4151 |
|
4152 |
|
4153 |
|
4154 |
|
4155 |
|
4156 |
|
4157 |
|
4158 |
|
4159 |
|
4160 |
|
4161 |
|
4162 |
|
4163 |
|
4164 |
|
4165 |
|
4166 |
|
4167 |
|
4168 |
|
4169 |
|
4170 |
|
4171 |
|
4172 |
|
4173 |
|
4174 |
|
4175 |
|
4176 |
|
4177 |
|
4178 |
|
4179 |
|
4180 |
|
4181 |
|
4182 |
|
4183 |
|
4184 |
|
4185 |
|
4186 |
|
4187 |
|
4188 |
|
4189 |
|
4190 |
|
4191 |
|
4192 |
|
4193 | Router.prototype.createUrlTree = function (commands, navigationExtras) {
|
4194 | if (navigationExtras === void 0) { navigationExtras = {}; }
|
4195 | var relativeTo = navigationExtras.relativeTo, queryParams = navigationExtras.queryParams, fragment = navigationExtras.fragment, preserveQueryParams = navigationExtras.preserveQueryParams, queryParamsHandling = navigationExtras.queryParamsHandling, preserveFragment = navigationExtras.preserveFragment;
|
4196 | if (isDevMode() && preserveQueryParams && console && console.warn) {
|
4197 | console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
|
4198 | }
|
4199 | var a = relativeTo || this.routerState.root;
|
4200 | var f = preserveFragment ? this.currentUrlTree.fragment : fragment;
|
4201 | var q = null;
|
4202 | if (queryParamsHandling) {
|
4203 | switch (queryParamsHandling) {
|
4204 | case 'merge':
|
4205 | q = __assign(__assign({}, this.currentUrlTree.queryParams), queryParams);
|
4206 | break;
|
4207 | case 'preserve':
|
4208 | q = this.currentUrlTree.queryParams;
|
4209 | break;
|
4210 | default:
|
4211 | q = queryParams || null;
|
4212 | }
|
4213 | }
|
4214 | else {
|
4215 | q = preserveQueryParams ? this.currentUrlTree.queryParams : queryParams || null;
|
4216 | }
|
4217 | if (q !== null) {
|
4218 | q = this.removeEmptyProps(q);
|
4219 | }
|
4220 | return createUrlTree(a, this.currentUrlTree, commands, q, f);
|
4221 | };
|
4222 | |
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 |
|
4239 |
|
4240 |
|
4241 |
|
4242 |
|
4243 | Router.prototype.navigateByUrl = function (url, extras) {
|
4244 | if (extras === void 0) { extras = { skipLocationChange: false }; }
|
4245 | if (isDevMode() && this.isNgZoneEnabled && !NgZone.isInAngularZone()) {
|
4246 | this.console.warn("Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?");
|
4247 | }
|
4248 | var urlTree = isUrlTree(url) ? url : this.parseUrl(url);
|
4249 | var mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
|
4250 | return this.scheduleNavigation(mergedTree, 'imperative', null, extras);
|
4251 | };
|
4252 | |
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 | Router.prototype.navigate = function (commands, extras) {
|
4280 | if (extras === void 0) { extras = { skipLocationChange: false }; }
|
4281 | validateCommands(commands);
|
4282 | return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
|
4283 | };
|
4284 |
|
4285 | Router.prototype.serializeUrl = function (url) { return this.urlSerializer.serialize(url); };
|
4286 |
|
4287 | Router.prototype.parseUrl = function (url) {
|
4288 | var urlTree;
|
4289 | try {
|
4290 | urlTree = this.urlSerializer.parse(url);
|
4291 | }
|
4292 | catch (e) {
|
4293 | urlTree = this.malformedUriErrorHandler(e, this.urlSerializer, url);
|
4294 | }
|
4295 | return urlTree;
|
4296 | };
|
4297 |
|
4298 | Router.prototype.isActive = function (url, exact) {
|
4299 | if (isUrlTree(url)) {
|
4300 | return containsTree(this.currentUrlTree, url, exact);
|
4301 | }
|
4302 | var urlTree = this.parseUrl(url);
|
4303 | return containsTree(this.currentUrlTree, urlTree, exact);
|
4304 | };
|
4305 | Router.prototype.removeEmptyProps = function (params) {
|
4306 | return Object.keys(params).reduce(function (result, key) {
|
4307 | var value = params[key];
|
4308 | if (value !== null && value !== undefined) {
|
4309 | result[key] = value;
|
4310 | }
|
4311 | return result;
|
4312 | }, {});
|
4313 | };
|
4314 | Router.prototype.processNavigations = function () {
|
4315 | var _this = this;
|
4316 | this.navigations.subscribe(function (t) {
|
4317 | _this.navigated = true;
|
4318 | _this.lastSuccessfulId = t.id;
|
4319 | _this.events
|
4320 | .next(new NavigationEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(_this.currentUrlTree)));
|
4321 | _this.lastSuccessfulNavigation = _this.currentNavigation;
|
4322 | _this.currentNavigation = null;
|
4323 | t.resolve(true);
|
4324 | }, function (e) { _this.console.warn("Unhandled Navigation Error: "); });
|
4325 | };
|
4326 | Router.prototype.scheduleNavigation = function (rawUrl, source, restoredState, extras, priorPromise) {
|
4327 | var lastNavigation = this.getTransition();
|
4328 |
|
4329 |
|
4330 |
|
4331 | if (lastNavigation && source !== 'imperative' && lastNavigation.source === 'imperative' &&
|
4332 | lastNavigation.rawUrl.toString() === rawUrl.toString()) {
|
4333 | return Promise.resolve(true);
|
4334 | }
|
4335 |
|
4336 |
|
4337 |
|
4338 | if (lastNavigation && source == 'hashchange' && lastNavigation.source === 'popstate' &&
|
4339 | lastNavigation.rawUrl.toString() === rawUrl.toString()) {
|
4340 | return Promise.resolve(true);
|
4341 | }
|
4342 |
|
4343 |
|
4344 |
|
4345 | if (lastNavigation && source == 'popstate' && lastNavigation.source === 'hashchange' &&
|
4346 | lastNavigation.rawUrl.toString() === rawUrl.toString()) {
|
4347 | return Promise.resolve(true);
|
4348 | }
|
4349 | var resolve;
|
4350 | var reject;
|
4351 | var promise;
|
4352 | if (priorPromise) {
|
4353 | resolve = priorPromise.resolve;
|
4354 | reject = priorPromise.reject;
|
4355 | promise = priorPromise.promise;
|
4356 | }
|
4357 | else {
|
4358 | promise = new Promise(function (res, rej) {
|
4359 | resolve = res;
|
4360 | reject = rej;
|
4361 | });
|
4362 | }
|
4363 | var id = ++this.navigationId;
|
4364 | this.setTransition({
|
4365 | id: id,
|
4366 | source: source,
|
4367 | restoredState: restoredState,
|
4368 | currentUrlTree: this.currentUrlTree,
|
4369 | currentRawUrl: this.rawUrlTree, rawUrl: rawUrl, extras: extras, resolve: resolve, reject: reject, promise: promise,
|
4370 | currentSnapshot: this.routerState.snapshot,
|
4371 | currentRouterState: this.routerState
|
4372 | });
|
4373 |
|
4374 |
|
4375 | return promise.catch(function (e) { return Promise.reject(e); });
|
4376 | };
|
4377 | Router.prototype.setBrowserUrl = function (url, replaceUrl, id, state) {
|
4378 | var path = this.urlSerializer.serialize(url);
|
4379 | state = state || {};
|
4380 | if (this.location.isCurrentPathEqualTo(path) || replaceUrl) {
|
4381 |
|
4382 | this.location.replaceState(path, '', __assign(__assign({}, state), { navigationId: id }));
|
4383 | }
|
4384 | else {
|
4385 | this.location.go(path, '', __assign(__assign({}, state), { navigationId: id }));
|
4386 | }
|
4387 | };
|
4388 | Router.prototype.resetStateAndUrl = function (storedState, storedUrl, rawUrl) {
|
4389 | this.routerState = storedState;
|
4390 | this.currentUrlTree = storedUrl;
|
4391 | this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
|
4392 | this.resetUrlToCurrentUrlTree();
|
4393 | };
|
4394 | Router.prototype.resetUrlToCurrentUrlTree = function () {
|
4395 | this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', { navigationId: this.lastSuccessfulId });
|
4396 | };
|
4397 | return Router;
|
4398 | }());
|
4399 | function validateCommands(commands) {
|
4400 | for (var i = 0; i < commands.length; i++) {
|
4401 | var cmd = commands[i];
|
4402 | if (cmd == null) {
|
4403 | throw new Error("The requested path contains " + cmd + " segment at index " + i);
|
4404 | }
|
4405 | }
|
4406 | }
|
4407 |
|
4408 |
|
4409 |
|
4410 |
|
4411 |
|
4412 |
|
4413 |
|
4414 |
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 |
|
4449 |
|
4450 |
|
4451 |
|
4452 |
|
4453 |
|
4454 |
|
4455 |
|
4456 |
|
4457 |
|
4458 |
|
4459 |
|
4460 |
|
4461 |
|
4462 |
|
4463 |
|
4464 |
|
4465 |
|
4466 |
|
4467 |
|
4468 |
|
4469 |
|
4470 |
|
4471 |
|
4472 |
|
4473 |
|
4474 |
|
4475 |
|
4476 |
|
4477 |
|
4478 |
|
4479 |
|
4480 |
|
4481 |
|
4482 |
|
4483 |
|
4484 |
|
4485 |
|
4486 |
|
4487 |
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 |
|
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 |
|
4502 |
|
4503 |
|
4504 |
|
4505 |
|
4506 |
|
4507 |
|
4508 |
|
4509 | var RouterLink = (function () {
|
4510 | function RouterLink(router, route, tabIndex, renderer, el) {
|
4511 | this.router = router;
|
4512 | this.route = route;
|
4513 | this.commands = [];
|
4514 | if (tabIndex == null) {
|
4515 | renderer.setAttribute(el.nativeElement, 'tabindex', '0');
|
4516 | }
|
4517 | }
|
4518 | Object.defineProperty(RouterLink.prototype, "routerLink", {
|
4519 | set: function (commands) {
|
4520 | if (commands != null) {
|
4521 | this.commands = Array.isArray(commands) ? commands : [commands];
|
4522 | }
|
4523 | else {
|
4524 | this.commands = [];
|
4525 | }
|
4526 | },
|
4527 | enumerable: true,
|
4528 | configurable: true
|
4529 | });
|
4530 | Object.defineProperty(RouterLink.prototype, "preserveQueryParams", {
|
4531 | |
4532 |
|
4533 |
|
4534 | set: function (value) {
|
4535 | if (isDevMode() && console && console.warn) {
|
4536 | console.warn('preserveQueryParams is deprecated!, use queryParamsHandling instead.');
|
4537 | }
|
4538 | this.preserve = value;
|
4539 | },
|
4540 | enumerable: true,
|
4541 | configurable: true
|
4542 | });
|
4543 | RouterLink.prototype.onClick = function () {
|
4544 | var extras = {
|
4545 | skipLocationChange: attrBoolValue(this.skipLocationChange),
|
4546 | replaceUrl: attrBoolValue(this.replaceUrl),
|
4547 | };
|
4548 | this.router.navigateByUrl(this.urlTree, extras);
|
4549 | return true;
|
4550 | };
|
4551 | Object.defineProperty(RouterLink.prototype, "urlTree", {
|
4552 | get: function () {
|
4553 | return this.router.createUrlTree(this.commands, {
|
4554 | relativeTo: this.route,
|
4555 | queryParams: this.queryParams,
|
4556 | fragment: this.fragment,
|
4557 | preserveQueryParams: attrBoolValue(this.preserve),
|
4558 | queryParamsHandling: this.queryParamsHandling,
|
4559 | preserveFragment: attrBoolValue(this.preserveFragment),
|
4560 | });
|
4561 | },
|
4562 | enumerable: true,
|
4563 | configurable: true
|
4564 | });
|
4565 | __decorate([
|
4566 | Input(),
|
4567 | __metadata("design:type", Object)
|
4568 | ], RouterLink.prototype, "queryParams", void 0);
|
4569 | __decorate([
|
4570 | Input(),
|
4571 | __metadata("design:type", String)
|
4572 | ], RouterLink.prototype, "fragment", void 0);
|
4573 | __decorate([
|
4574 | Input(),
|
4575 | __metadata("design:type", String)
|
4576 | ], RouterLink.prototype, "queryParamsHandling", void 0);
|
4577 | __decorate([
|
4578 | Input(),
|
4579 | __metadata("design:type", Boolean)
|
4580 | ], RouterLink.prototype, "preserveFragment", void 0);
|
4581 | __decorate([
|
4582 | Input(),
|
4583 | __metadata("design:type", Boolean)
|
4584 | ], RouterLink.prototype, "skipLocationChange", void 0);
|
4585 | __decorate([
|
4586 | Input(),
|
4587 | __metadata("design:type", Boolean)
|
4588 | ], RouterLink.prototype, "replaceUrl", void 0);
|
4589 | __decorate([
|
4590 | Input(),
|
4591 | __metadata("design:type", Object)
|
4592 | ], RouterLink.prototype, "state", void 0);
|
4593 | __decorate([
|
4594 | Input(),
|
4595 | __metadata("design:type", Object),
|
4596 | __metadata("design:paramtypes", [Object])
|
4597 | ], RouterLink.prototype, "routerLink", null);
|
4598 | __decorate([
|
4599 | Input(),
|
4600 | __metadata("design:type", Boolean),
|
4601 | __metadata("design:paramtypes", [Boolean])
|
4602 | ], RouterLink.prototype, "preserveQueryParams", null);
|
4603 | __decorate([
|
4604 | HostListener('click'),
|
4605 | __metadata("design:type", Function),
|
4606 | __metadata("design:paramtypes", []),
|
4607 | __metadata("design:returntype", Boolean)
|
4608 | ], RouterLink.prototype, "onClick", null);
|
4609 | RouterLink = __decorate([
|
4610 | Directive({ selector: ':not(a):not(area)[routerLink]' }),
|
4611 | __param(2, Attribute('tabindex')),
|
4612 | __metadata("design:paramtypes", [Router, ActivatedRoute, String, Renderer2, ElementRef])
|
4613 | ], RouterLink);
|
4614 | return RouterLink;
|
4615 | }());
|
4616 |
|
4617 |
|
4618 |
|
4619 |
|
4620 |
|
4621 |
|
4622 |
|
4623 |
|
4624 |
|
4625 |
|
4626 |
|
4627 | var RouterLinkWithHref = (function () {
|
4628 | function RouterLinkWithHref(router, route, locationStrategy) {
|
4629 | var _this = this;
|
4630 | this.router = router;
|
4631 | this.route = route;
|
4632 | this.locationStrategy = locationStrategy;
|
4633 | this.commands = [];
|
4634 | this.subscription = router.events.subscribe(function (s) {
|
4635 | if (s instanceof NavigationEnd) {
|
4636 | _this.updateTargetUrlAndHref();
|
4637 | }
|
4638 | });
|
4639 | }
|
4640 | Object.defineProperty(RouterLinkWithHref.prototype, "routerLink", {
|
4641 | set: function (commands) {
|
4642 | if (commands != null) {
|
4643 | this.commands = Array.isArray(commands) ? commands : [commands];
|
4644 | }
|
4645 | else {
|
4646 | this.commands = [];
|
4647 | }
|
4648 | },
|
4649 | enumerable: true,
|
4650 | configurable: true
|
4651 | });
|
4652 | Object.defineProperty(RouterLinkWithHref.prototype, "preserveQueryParams", {
|
4653 | set: function (value) {
|
4654 | if (isDevMode() && console && console.warn) {
|
4655 | console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
|
4656 | }
|
4657 | this.preserve = value;
|
4658 | },
|
4659 | enumerable: true,
|
4660 | configurable: true
|
4661 | });
|
4662 | RouterLinkWithHref.prototype.ngOnChanges = function (changes) { this.updateTargetUrlAndHref(); };
|
4663 | RouterLinkWithHref.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
|
4664 | RouterLinkWithHref.prototype.onClick = function (button, ctrlKey, metaKey, shiftKey) {
|
4665 | if (button !== 0 || ctrlKey || metaKey || shiftKey) {
|
4666 | return true;
|
4667 | }
|
4668 | if (typeof this.target === 'string' && this.target != '_self') {
|
4669 | return true;
|
4670 | }
|
4671 | var extras = {
|
4672 | skipLocationChange: attrBoolValue(this.skipLocationChange),
|
4673 | replaceUrl: attrBoolValue(this.replaceUrl),
|
4674 | state: this.state
|
4675 | };
|
4676 | this.router.navigateByUrl(this.urlTree, extras);
|
4677 | return false;
|
4678 | };
|
4679 | RouterLinkWithHref.prototype.updateTargetUrlAndHref = function () {
|
4680 | this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
|
4681 | };
|
4682 | Object.defineProperty(RouterLinkWithHref.prototype, "urlTree", {
|
4683 | get: function () {
|
4684 | return this.router.createUrlTree(this.commands, {
|
4685 | relativeTo: this.route,
|
4686 | queryParams: this.queryParams,
|
4687 | fragment: this.fragment,
|
4688 | preserveQueryParams: attrBoolValue(this.preserve),
|
4689 | queryParamsHandling: this.queryParamsHandling,
|
4690 | preserveFragment: attrBoolValue(this.preserveFragment),
|
4691 | });
|
4692 | },
|
4693 | enumerable: true,
|
4694 | configurable: true
|
4695 | });
|
4696 | __decorate([
|
4697 | HostBinding('attr.target'), Input(),
|
4698 | __metadata("design:type", String)
|
4699 | ], RouterLinkWithHref.prototype, "target", void 0);
|
4700 | __decorate([
|
4701 | Input(),
|
4702 | __metadata("design:type", Object)
|
4703 | ], RouterLinkWithHref.prototype, "queryParams", void 0);
|
4704 | __decorate([
|
4705 | Input(),
|
4706 | __metadata("design:type", String)
|
4707 | ], RouterLinkWithHref.prototype, "fragment", void 0);
|
4708 | __decorate([
|
4709 | Input(),
|
4710 | __metadata("design:type", String)
|
4711 | ], RouterLinkWithHref.prototype, "queryParamsHandling", void 0);
|
4712 | __decorate([
|
4713 | Input(),
|
4714 | __metadata("design:type", Boolean)
|
4715 | ], RouterLinkWithHref.prototype, "preserveFragment", void 0);
|
4716 | __decorate([
|
4717 | Input(),
|
4718 | __metadata("design:type", Boolean)
|
4719 | ], RouterLinkWithHref.prototype, "skipLocationChange", void 0);
|
4720 | __decorate([
|
4721 | Input(),
|
4722 | __metadata("design:type", Boolean)
|
4723 | ], RouterLinkWithHref.prototype, "replaceUrl", void 0);
|
4724 | __decorate([
|
4725 | Input(),
|
4726 | __metadata("design:type", Object)
|
4727 | ], RouterLinkWithHref.prototype, "state", void 0);
|
4728 | __decorate([
|
4729 | HostBinding(),
|
4730 | __metadata("design:type", String)
|
4731 | ], RouterLinkWithHref.prototype, "href", void 0);
|
4732 | __decorate([
|
4733 | Input(),
|
4734 | __metadata("design:type", Object),
|
4735 | __metadata("design:paramtypes", [Object])
|
4736 | ], RouterLinkWithHref.prototype, "routerLink", null);
|
4737 | __decorate([
|
4738 | Input(),
|
4739 | __metadata("design:type", Boolean),
|
4740 | __metadata("design:paramtypes", [Boolean])
|
4741 | ], RouterLinkWithHref.prototype, "preserveQueryParams", null);
|
4742 | __decorate([
|
4743 | HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey']),
|
4744 | __metadata("design:type", Function),
|
4745 | __metadata("design:paramtypes", [Number, Boolean, Boolean, Boolean]),
|
4746 | __metadata("design:returntype", Boolean)
|
4747 | ], RouterLinkWithHref.prototype, "onClick", null);
|
4748 | RouterLinkWithHref = __decorate([
|
4749 | Directive({ selector: 'a[routerLink],area[routerLink]' }),
|
4750 | __metadata("design:paramtypes", [Router, ActivatedRoute,
|
4751 | LocationStrategy])
|
4752 | ], RouterLinkWithHref);
|
4753 | return RouterLinkWithHref;
|
4754 | }());
|
4755 | function attrBoolValue(s) {
|
4756 | return s === '' || !!s;
|
4757 | }
|
4758 |
|
4759 |
|
4760 |
|
4761 |
|
4762 |
|
4763 |
|
4764 |
|
4765 |
|
4766 |
|
4767 |
|
4768 |
|
4769 |
|
4770 |
|
4771 |
|
4772 |
|
4773 |
|
4774 |
|
4775 |
|
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 |
|
4784 |
|
4785 |
|
4786 |
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 |
|
4795 |
|
4796 |
|
4797 |
|
4798 |
|
4799 |
|
4800 |
|
4801 |
|
4802 |
|
4803 |
|
4804 |
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 |
|
4813 |
|
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 | var RouterLinkActive = (function () {
|
4824 | function RouterLinkActive(router, element, renderer, link, linkWithHref) {
|
4825 | var _this = this;
|
4826 | this.router = router;
|
4827 | this.element = element;
|
4828 | this.renderer = renderer;
|
4829 | this.link = link;
|
4830 | this.linkWithHref = linkWithHref;
|
4831 | this.classes = [];
|
4832 | this.isActive = false;
|
4833 | this.routerLinkActiveOptions = { exact: false };
|
4834 | this.subscription = router.events.subscribe(function (s) {
|
4835 | if (s instanceof NavigationEnd) {
|
4836 | _this.update();
|
4837 | }
|
4838 | });
|
4839 | }
|
4840 | RouterLinkActive.prototype.ngAfterContentInit = function () {
|
4841 | var _this = this;
|
4842 | this.links.changes.subscribe(function (_) { return _this.update(); });
|
4843 | this.linksWithHrefs.changes.subscribe(function (_) { return _this.update(); });
|
4844 | this.update();
|
4845 | };
|
4846 | Object.defineProperty(RouterLinkActive.prototype, "routerLinkActive", {
|
4847 | set: function (data) {
|
4848 | var classes = Array.isArray(data) ? data : data.split(' ');
|
4849 | this.classes = classes.filter(function (c) { return !!c; });
|
4850 | },
|
4851 | enumerable: true,
|
4852 | configurable: true
|
4853 | });
|
4854 | RouterLinkActive.prototype.ngOnChanges = function (changes) { this.update(); };
|
4855 | RouterLinkActive.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
|
4856 | RouterLinkActive.prototype.update = function () {
|
4857 | var _this = this;
|
4858 | if (!this.links || !this.linksWithHrefs || !this.router.navigated)
|
4859 | return;
|
4860 | Promise.resolve().then(function () {
|
4861 | var hasActiveLinks = _this.hasActiveLinks();
|
4862 | if (_this.isActive !== hasActiveLinks) {
|
4863 | _this.isActive = hasActiveLinks;
|
4864 | _this.classes.forEach(function (c) {
|
4865 | if (hasActiveLinks) {
|
4866 | _this.renderer.addClass(_this.element.nativeElement, c);
|
4867 | }
|
4868 | else {
|
4869 | _this.renderer.removeClass(_this.element.nativeElement, c);
|
4870 | }
|
4871 | });
|
4872 | }
|
4873 | });
|
4874 | };
|
4875 | RouterLinkActive.prototype.isLinkActive = function (router) {
|
4876 | var _this = this;
|
4877 | return function (link) {
|
4878 | return router.isActive(link.urlTree, _this.routerLinkActiveOptions.exact);
|
4879 | };
|
4880 | };
|
4881 | RouterLinkActive.prototype.hasActiveLinks = function () {
|
4882 | var isActiveCheckFn = this.isLinkActive(this.router);
|
4883 | return this.link && isActiveCheckFn(this.link) ||
|
4884 | this.linkWithHref && isActiveCheckFn(this.linkWithHref) ||
|
4885 | this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
|
4886 | };
|
4887 | __decorate([
|
4888 | ContentChildren(RouterLink, { descendants: true }),
|
4889 | __metadata("design:type", QueryList)
|
4890 | ], RouterLinkActive.prototype, "links", void 0);
|
4891 | __decorate([
|
4892 | ContentChildren(RouterLinkWithHref, { descendants: true }),
|
4893 | __metadata("design:type", QueryList)
|
4894 | ], RouterLinkActive.prototype, "linksWithHrefs", void 0);
|
4895 | __decorate([
|
4896 | Input(),
|
4897 | __metadata("design:type", Object)
|
4898 | ], RouterLinkActive.prototype, "routerLinkActiveOptions", void 0);
|
4899 | __decorate([
|
4900 | Input(),
|
4901 | __metadata("design:type", Object),
|
4902 | __metadata("design:paramtypes", [Object])
|
4903 | ], RouterLinkActive.prototype, "routerLinkActive", null);
|
4904 | RouterLinkActive = __decorate([
|
4905 | Directive({
|
4906 | selector: '[routerLinkActive]',
|
4907 | exportAs: 'routerLinkActive',
|
4908 | }),
|
4909 | __param(3, Optional()),
|
4910 | __param(4, Optional()),
|
4911 | __metadata("design:paramtypes", [Router, ElementRef, Renderer2,
|
4912 | RouterLink,
|
4913 | RouterLinkWithHref])
|
4914 | ], RouterLinkActive);
|
4915 | return RouterLinkActive;
|
4916 | }());
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 |
|
4925 |
|
4926 |
|
4927 |
|
4928 |
|
4929 |
|
4930 | var OutletContext = (function () {
|
4931 | function OutletContext() {
|
4932 | this.outlet = null;
|
4933 | this.route = null;
|
4934 | this.resolver = null;
|
4935 | this.children = new ChildrenOutletContexts();
|
4936 | this.attachRef = null;
|
4937 | }
|
4938 | return OutletContext;
|
4939 | }());
|
4940 |
|
4941 |
|
4942 |
|
4943 |
|
4944 |
|
4945 | var ChildrenOutletContexts = (function () {
|
4946 | function ChildrenOutletContexts() {
|
4947 |
|
4948 | this.contexts = new Map();
|
4949 | }
|
4950 |
|
4951 | ChildrenOutletContexts.prototype.onChildOutletCreated = function (childName, outlet) {
|
4952 | var context = this.getOrCreateContext(childName);
|
4953 | context.outlet = outlet;
|
4954 | this.contexts.set(childName, context);
|
4955 | };
|
4956 | |
4957 |
|
4958 |
|
4959 |
|
4960 |
|
4961 | ChildrenOutletContexts.prototype.onChildOutletDestroyed = function (childName) {
|
4962 | var context = this.getContext(childName);
|
4963 | if (context) {
|
4964 | context.outlet = null;
|
4965 | }
|
4966 | };
|
4967 | |
4968 |
|
4969 |
|
4970 |
|
4971 | ChildrenOutletContexts.prototype.onOutletDeactivated = function () {
|
4972 | var contexts = this.contexts;
|
4973 | this.contexts = new Map();
|
4974 | return contexts;
|
4975 | };
|
4976 | ChildrenOutletContexts.prototype.onOutletReAttached = function (contexts) { this.contexts = contexts; };
|
4977 | ChildrenOutletContexts.prototype.getOrCreateContext = function (childName) {
|
4978 | var context = this.getContext(childName);
|
4979 | if (!context) {
|
4980 | context = new OutletContext();
|
4981 | this.contexts.set(childName, context);
|
4982 | }
|
4983 | return context;
|
4984 | };
|
4985 | ChildrenOutletContexts.prototype.getContext = function (childName) { return this.contexts.get(childName) || null; };
|
4986 | return ChildrenOutletContexts;
|
4987 | }());
|
4988 |
|
4989 |
|
4990 |
|
4991 |
|
4992 |
|
4993 |
|
4994 |
|
4995 |
|
4996 |
|
4997 |
|
4998 |
|
4999 |
|
5000 |
|
5001 |
|
5002 |
|
5003 |
|
5004 |
|
5005 |
|
5006 |
|
5007 |
|
5008 |
|
5009 |
|
5010 |
|
5011 |
|
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 |
|
5017 |
|
5018 |
|
5019 |
|
5020 |
|
5021 |
|
5022 | var RouterOutlet = (function () {
|
5023 | function RouterOutlet(parentContexts, location, resolver, name, changeDetector) {
|
5024 | this.parentContexts = parentContexts;
|
5025 | this.location = location;
|
5026 | this.resolver = resolver;
|
5027 | this.changeDetector = changeDetector;
|
5028 | this.activated = null;
|
5029 | this._activatedRoute = null;
|
5030 | this.activateEvents = new EventEmitter();
|
5031 | this.deactivateEvents = new EventEmitter();
|
5032 | this.name = name || PRIMARY_OUTLET;
|
5033 | parentContexts.onChildOutletCreated(this.name, this);
|
5034 | }
|
5035 | RouterOutlet.prototype.ngOnDestroy = function () { this.parentContexts.onChildOutletDestroyed(this.name); };
|
5036 | RouterOutlet.prototype.ngOnInit = function () {
|
5037 | if (!this.activated) {
|
5038 |
|
5039 |
|
5040 | var context = this.parentContexts.getContext(this.name);
|
5041 | if (context && context.route) {
|
5042 | if (context.attachRef) {
|
5043 |
|
5044 | this.attach(context.attachRef, context.route);
|
5045 | }
|
5046 | else {
|
5047 |
|
5048 | this.activateWith(context.route, context.resolver || null);
|
5049 | }
|
5050 | }
|
5051 | }
|
5052 | };
|
5053 | Object.defineProperty(RouterOutlet.prototype, "isActivated", {
|
5054 | get: function () { return !!this.activated; },
|
5055 | enumerable: true,
|
5056 | configurable: true
|
5057 | });
|
5058 | Object.defineProperty(RouterOutlet.prototype, "component", {
|
5059 | get: function () {
|
5060 | if (!this.activated)
|
5061 | throw new Error('Outlet is not activated');
|
5062 | return this.activated.instance;
|
5063 | },
|
5064 | enumerable: true,
|
5065 | configurable: true
|
5066 | });
|
5067 | Object.defineProperty(RouterOutlet.prototype, "activatedRoute", {
|
5068 | get: function () {
|
5069 | if (!this.activated)
|
5070 | throw new Error('Outlet is not activated');
|
5071 | return this._activatedRoute;
|
5072 | },
|
5073 | enumerable: true,
|
5074 | configurable: true
|
5075 | });
|
5076 | Object.defineProperty(RouterOutlet.prototype, "activatedRouteData", {
|
5077 | get: function () {
|
5078 | if (this._activatedRoute) {
|
5079 | return this._activatedRoute.snapshot.data;
|
5080 | }
|
5081 | return {};
|
5082 | },
|
5083 | enumerable: true,
|
5084 | configurable: true
|
5085 | });
|
5086 | |
5087 |
|
5088 |
|
5089 | RouterOutlet.prototype.detach = function () {
|
5090 | if (!this.activated)
|
5091 | throw new Error('Outlet is not activated');
|
5092 | this.location.detach();
|
5093 | var cmp = this.activated;
|
5094 | this.activated = null;
|
5095 | this._activatedRoute = null;
|
5096 | return cmp;
|
5097 | };
|
5098 | |
5099 |
|
5100 |
|
5101 | RouterOutlet.prototype.attach = function (ref, activatedRoute) {
|
5102 | this.activated = ref;
|
5103 | this._activatedRoute = activatedRoute;
|
5104 | this.location.insert(ref.hostView);
|
5105 | };
|
5106 | RouterOutlet.prototype.deactivate = function () {
|
5107 | if (this.activated) {
|
5108 | var c = this.component;
|
5109 | this.activated.destroy();
|
5110 | this.activated = null;
|
5111 | this._activatedRoute = null;
|
5112 | this.deactivateEvents.emit(c);
|
5113 | }
|
5114 | };
|
5115 | RouterOutlet.prototype.activateWith = function (activatedRoute, resolver) {
|
5116 | if (this.isActivated) {
|
5117 | throw new Error('Cannot activate an already activated outlet');
|
5118 | }
|
5119 | this._activatedRoute = activatedRoute;
|
5120 | var snapshot = activatedRoute._futureSnapshot;
|
5121 | var component = snapshot.routeConfig.component;
|
5122 | resolver = resolver || this.resolver;
|
5123 | var factory = resolver.resolveComponentFactory(component);
|
5124 | var childContexts = this.parentContexts.getOrCreateContext(this.name).children;
|
5125 | var injector = new OutletInjector(activatedRoute, childContexts, this.location.injector);
|
5126 | this.activated = this.location.createComponent(factory, this.location.length, injector);
|
5127 |
|
5128 |
|
5129 | this.changeDetector.markForCheck();
|
5130 | this.activateEvents.emit(this.activated.instance);
|
5131 | };
|
5132 | __decorate([
|
5133 | Output('activate'),
|
5134 | __metadata("design:type", Object)
|
5135 | ], RouterOutlet.prototype, "activateEvents", void 0);
|
5136 | __decorate([
|
5137 | Output('deactivate'),
|
5138 | __metadata("design:type", Object)
|
5139 | ], RouterOutlet.prototype, "deactivateEvents", void 0);
|
5140 | RouterOutlet = __decorate([
|
5141 | Directive({ selector: 'router-outlet', exportAs: 'outlet' }),
|
5142 | __param(3, Attribute('name')),
|
5143 | __metadata("design:paramtypes", [ChildrenOutletContexts, ViewContainerRef,
|
5144 | ComponentFactoryResolver, String, ChangeDetectorRef])
|
5145 | ], RouterOutlet);
|
5146 | return RouterOutlet;
|
5147 | }());
|
5148 | var OutletInjector = (function () {
|
5149 | function OutletInjector(route, childContexts, parent) {
|
5150 | this.route = route;
|
5151 | this.childContexts = childContexts;
|
5152 | this.parent = parent;
|
5153 | }
|
5154 | OutletInjector.prototype.get = function (token, notFoundValue) {
|
5155 | if (token === ActivatedRoute) {
|
5156 | return this.route;
|
5157 | }
|
5158 | if (token === ChildrenOutletContexts) {
|
5159 | return this.childContexts;
|
5160 | }
|
5161 | return this.parent.get(token, notFoundValue);
|
5162 | };
|
5163 | return OutletInjector;
|
5164 | }());
|
5165 |
|
5166 |
|
5167 |
|
5168 |
|
5169 |
|
5170 |
|
5171 |
|
5172 |
|
5173 |
|
5174 |
|
5175 |
|
5176 |
|
5177 |
|
5178 |
|
5179 |
|
5180 | var PreloadingStrategy = (function () {
|
5181 | function PreloadingStrategy() {
|
5182 | }
|
5183 | return PreloadingStrategy;
|
5184 | }());
|
5185 |
|
5186 |
|
5187 |
|
5188 |
|
5189 |
|
5190 |
|
5191 |
|
5192 |
|
5193 |
|
5194 |
|
5195 |
|
5196 | var PreloadAllModules = (function () {
|
5197 | function PreloadAllModules() {
|
5198 | }
|
5199 | PreloadAllModules.prototype.preload = function (route, fn) {
|
5200 | return fn().pipe(catchError(function () { return of(null); }));
|
5201 | };
|
5202 | return PreloadAllModules;
|
5203 | }());
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 |
|
5209 |
|
5210 |
|
5211 |
|
5212 |
|
5213 | var NoPreloading = (function () {
|
5214 | function NoPreloading() {
|
5215 | }
|
5216 | NoPreloading.prototype.preload = function (route, fn) { return of(null); };
|
5217 | return NoPreloading;
|
5218 | }());
|
5219 |
|
5220 |
|
5221 |
|
5222 |
|
5223 |
|
5224 |
|
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 |
|
5230 |
|
5231 | var RouterPreloader = (function () {
|
5232 | function RouterPreloader(router, moduleLoader, compiler, injector, preloadingStrategy) {
|
5233 | this.router = router;
|
5234 | this.injector = injector;
|
5235 | this.preloadingStrategy = preloadingStrategy;
|
5236 | var onStartLoad = function (r) { return router.triggerEvent(new RouteConfigLoadStart(r)); };
|
5237 | var onEndLoad = function (r) { return router.triggerEvent(new RouteConfigLoadEnd(r)); };
|
5238 | this.loader = new RouterConfigLoader(moduleLoader, compiler, onStartLoad, onEndLoad);
|
5239 | }
|
5240 | RouterPreloader.prototype.setUpPreloading = function () {
|
5241 | var _this = this;
|
5242 | this.subscription =
|
5243 | this.router.events
|
5244 | .pipe(filter(function (e) { return e instanceof NavigationEnd; }), concatMap(function () { return _this.preload(); }))
|
5245 | .subscribe(function () { });
|
5246 | };
|
5247 | RouterPreloader.prototype.preload = function () {
|
5248 | var ngModule = this.injector.get(NgModuleRef);
|
5249 | return this.processRoutes(ngModule, this.router.config);
|
5250 | };
|
5251 |
|
5252 |
|
5253 |
|
5254 | RouterPreloader.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
|
5255 | RouterPreloader.prototype.processRoutes = function (ngModule, routes) {
|
5256 | var e_1, _a;
|
5257 | var res = [];
|
5258 | try {
|
5259 | for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
|
5260 | var route = routes_1_1.value;
|
5261 |
|
5262 | if (route.loadChildren && !route.canLoad && route._loadedConfig) {
|
5263 | var childConfig = route._loadedConfig;
|
5264 | res.push(this.processRoutes(childConfig.module, childConfig.routes));
|
5265 |
|
5266 | }
|
5267 | else if (route.loadChildren && !route.canLoad) {
|
5268 | res.push(this.preloadConfig(ngModule, route));
|
5269 |
|
5270 | }
|
5271 | else if (route.children) {
|
5272 | res.push(this.processRoutes(ngModule, route.children));
|
5273 | }
|
5274 | }
|
5275 | }
|
5276 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
5277 | finally {
|
5278 | try {
|
5279 | if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
5280 | }
|
5281 | finally { if (e_1) throw e_1.error; }
|
5282 | }
|
5283 | return from(res).pipe(mergeAll(), map(function (_) { return void 0; }));
|
5284 | };
|
5285 | RouterPreloader.prototype.preloadConfig = function (ngModule, route) {
|
5286 | var _this = this;
|
5287 | return this.preloadingStrategy.preload(route, function () {
|
5288 | var loaded$ = _this.loader.load(ngModule.injector, route);
|
5289 | return loaded$.pipe(mergeMap(function (config) {
|
5290 | route._loadedConfig = config;
|
5291 | return _this.processRoutes(config.module, config.routes);
|
5292 | }));
|
5293 | });
|
5294 | };
|
5295 | RouterPreloader = __decorate([
|
5296 | Injectable(),
|
5297 | __metadata("design:paramtypes", [Router, NgModuleFactoryLoader, Compiler,
|
5298 | Injector, PreloadingStrategy])
|
5299 | ], RouterPreloader);
|
5300 | return RouterPreloader;
|
5301 | }());
|
5302 |
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 | var RouterScroller = (function () {
|
5311 | function RouterScroller(router,
|
5312 | /** @docsNotRequired */ viewportScroller, options) {
|
5313 | if (options === void 0) { options = {}; }
|
5314 | this.router = router;
|
5315 | this.viewportScroller = viewportScroller;
|
5316 | this.options = options;
|
5317 | this.lastId = 0;
|
5318 | this.lastSource = 'imperative';
|
5319 | this.restoredId = 0;
|
5320 | this.store = {};
|
5321 |
|
5322 | options.scrollPositionRestoration = options.scrollPositionRestoration || 'disabled';
|
5323 | options.anchorScrolling = options.anchorScrolling || 'disabled';
|
5324 | }
|
5325 | RouterScroller.prototype.init = function () {
|
5326 |
|
5327 |
|
5328 |
|
5329 | if (this.options.scrollPositionRestoration !== 'disabled') {
|
5330 | this.viewportScroller.setHistoryScrollRestoration('manual');
|
5331 | }
|
5332 | this.routerEventsSubscription = this.createScrollEvents();
|
5333 | this.scrollEventsSubscription = this.consumeScrollEvents();
|
5334 | };
|
5335 | RouterScroller.prototype.createScrollEvents = function () {
|
5336 | var _this = this;
|
5337 | return this.router.events.subscribe(function (e) {
|
5338 | if (e instanceof NavigationStart) {
|
5339 |
|
5340 | _this.store[_this.lastId] = _this.viewportScroller.getScrollPosition();
|
5341 | _this.lastSource = e.navigationTrigger;
|
5342 | _this.restoredId = e.restoredState ? e.restoredState.navigationId : 0;
|
5343 | }
|
5344 | else if (e instanceof NavigationEnd) {
|
5345 | _this.lastId = e.id;
|
5346 | _this.scheduleScrollEvent(e, _this.router.parseUrl(e.urlAfterRedirects).fragment);
|
5347 | }
|
5348 | });
|
5349 | };
|
5350 | RouterScroller.prototype.consumeScrollEvents = function () {
|
5351 | var _this = this;
|
5352 | return this.router.events.subscribe(function (e) {
|
5353 | if (!(e instanceof Scroll))
|
5354 | return;
|
5355 |
|
5356 | if (e.position) {
|
5357 | if (_this.options.scrollPositionRestoration === 'top') {
|
5358 | _this.viewportScroller.scrollToPosition([0, 0]);
|
5359 | }
|
5360 | else if (_this.options.scrollPositionRestoration === 'enabled') {
|
5361 | _this.viewportScroller.scrollToPosition(e.position);
|
5362 | }
|
5363 |
|
5364 | }
|
5365 | else {
|
5366 | if (e.anchor && _this.options.anchorScrolling === 'enabled') {
|
5367 | _this.viewportScroller.scrollToAnchor(e.anchor);
|
5368 | }
|
5369 | else if (_this.options.scrollPositionRestoration !== 'disabled') {
|
5370 | _this.viewportScroller.scrollToPosition([0, 0]);
|
5371 | }
|
5372 | }
|
5373 | });
|
5374 | };
|
5375 | RouterScroller.prototype.scheduleScrollEvent = function (routerEvent, anchor) {
|
5376 | this.router.triggerEvent(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
|
5377 | };
|
5378 | RouterScroller.prototype.ngOnDestroy = function () {
|
5379 | if (this.routerEventsSubscription) {
|
5380 | this.routerEventsSubscription.unsubscribe();
|
5381 | }
|
5382 | if (this.scrollEventsSubscription) {
|
5383 | this.scrollEventsSubscription.unsubscribe();
|
5384 | }
|
5385 | };
|
5386 | return RouterScroller;
|
5387 | }());
|
5388 |
|
5389 |
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 |
|
5398 |
|
5399 | var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent];
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 | var ROUTER_CONFIGURATION = new InjectionToken('ROUTER_CONFIGURATION');
|
5406 |
|
5407 |
|
5408 |
|
5409 | var ROUTER_FORROOT_GUARD = new InjectionToken('ROUTER_FORROOT_GUARD');
|
5410 | var ɵ0 = { enableTracing: false };
|
5411 | var ROUTER_PROVIDERS = [
|
5412 | Location,
|
5413 | { provide: UrlSerializer, useClass: DefaultUrlSerializer },
|
5414 | {
|
5415 | provide: Router,
|
5416 | useFactory: setupRouter,
|
5417 | deps: [
|
5418 | UrlSerializer, ChildrenOutletContexts, Location, Injector, NgModuleFactoryLoader, Compiler,
|
5419 | ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()],
|
5420 | [RouteReuseStrategy, new Optional()]
|
5421 | ]
|
5422 | },
|
5423 | ChildrenOutletContexts,
|
5424 | { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
|
5425 | { provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader },
|
5426 | RouterPreloader,
|
5427 | NoPreloading,
|
5428 | PreloadAllModules,
|
5429 | { provide: ROUTER_CONFIGURATION, useValue: ɵ0 },
|
5430 | ];
|
5431 | function routerNgProbeToken() {
|
5432 | return new NgProbeToken('Router', Router);
|
5433 | }
|
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 |
|
5442 |
|
5443 |
|
5444 |
|
5445 |
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 |
|
5452 |
|
5453 |
|
5454 |
|
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 |
|
5465 |
|
5466 |
|
5467 |
|
5468 |
|
5469 |
|
5470 |
|
5471 |
|
5472 |
|
5473 |
|
5474 |
|
5475 |
|
5476 |
|
5477 |
|
5478 |
|
5479 |
|
5480 |
|
5481 |
|
5482 |
|
5483 |
|
5484 |
|
5485 | var RouterModule = (function () {
|
5486 |
|
5487 | function RouterModule(guard, router) {
|
5488 | }
|
5489 | RouterModule_1 = RouterModule;
|
5490 | |
5491 |
|
5492 |
|
5493 |
|
5494 |
|
5495 |
|
5496 |
|
5497 |
|
5498 | RouterModule.forRoot = function (routes, config) {
|
5499 | return {
|
5500 | ngModule: RouterModule_1,
|
5501 | providers: [
|
5502 | ROUTER_PROVIDERS,
|
5503 | provideRoutes(routes),
|
5504 | {
|
5505 | provide: ROUTER_FORROOT_GUARD,
|
5506 | useFactory: provideForRootGuard,
|
5507 | deps: [[Router, new Optional(), new SkipSelf()]]
|
5508 | },
|
5509 | { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },
|
5510 | {
|
5511 | provide: LocationStrategy,
|
5512 | useFactory: provideLocationStrategy,
|
5513 | deps: [
|
5514 | PlatformLocation, [new Inject(APP_BASE_HREF), new Optional()], ROUTER_CONFIGURATION
|
5515 | ]
|
5516 | },
|
5517 | {
|
5518 | provide: RouterScroller,
|
5519 | useFactory: createRouterScroller,
|
5520 | deps: [Router, ViewportScroller, ROUTER_CONFIGURATION]
|
5521 | },
|
5522 | {
|
5523 | provide: PreloadingStrategy,
|
5524 | useExisting: config && config.preloadingStrategy ? config.preloadingStrategy :
|
5525 | NoPreloading
|
5526 | },
|
5527 | { provide: NgProbeToken, multi: true, useFactory: routerNgProbeToken },
|
5528 | provideRouterInitializer(),
|
5529 | ],
|
5530 | };
|
5531 | };
|
5532 | |
5533 |
|
5534 |
|
5535 | RouterModule.forChild = function (routes) {
|
5536 | return { ngModule: RouterModule_1, providers: [provideRoutes(routes)] };
|
5537 | };
|
5538 | var RouterModule_1;
|
5539 | RouterModule = RouterModule_1 = __decorate([
|
5540 | NgModule({
|
5541 | declarations: ROUTER_DIRECTIVES,
|
5542 | exports: ROUTER_DIRECTIVES,
|
5543 | entryComponents: [ɵEmptyOutletComponent]
|
5544 | }),
|
5545 | __param(0, Optional()), __param(0, Inject(ROUTER_FORROOT_GUARD)), __param(1, Optional()),
|
5546 | __metadata("design:paramtypes", [Object, Router])
|
5547 | ], RouterModule);
|
5548 | return RouterModule;
|
5549 | }());
|
5550 | function createRouterScroller(router, viewportScroller, config) {
|
5551 | if (config.scrollOffset) {
|
5552 | viewportScroller.setOffset(config.scrollOffset);
|
5553 | }
|
5554 | return new RouterScroller(router, viewportScroller, config);
|
5555 | }
|
5556 | function provideLocationStrategy(platformLocationStrategy, baseHref, options) {
|
5557 | if (options === void 0) { options = {}; }
|
5558 | return options.useHash ? new HashLocationStrategy(platformLocationStrategy, baseHref) :
|
5559 | new PathLocationStrategy(platformLocationStrategy, baseHref);
|
5560 | }
|
5561 | function provideForRootGuard(router) {
|
5562 | if (router) {
|
5563 | throw new Error("RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.");
|
5564 | }
|
5565 | return 'guarded';
|
5566 | }
|
5567 |
|
5568 |
|
5569 |
|
5570 |
|
5571 |
|
5572 |
|
5573 |
|
5574 |
|
5575 |
|
5576 |
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 | function provideRoutes(routes) {
|
5584 | return [
|
5585 | { provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes },
|
5586 | { provide: ROUTES, multi: true, useValue: routes },
|
5587 | ];
|
5588 | }
|
5589 | function setupRouter(urlSerializer, contexts, location, injector, loader, compiler, config, opts, urlHandlingStrategy, routeReuseStrategy) {
|
5590 | if (opts === void 0) { opts = {}; }
|
5591 | var router = new Router(null, urlSerializer, contexts, location, injector, loader, compiler, flatten(config));
|
5592 | if (urlHandlingStrategy) {
|
5593 | router.urlHandlingStrategy = urlHandlingStrategy;
|
5594 | }
|
5595 | if (routeReuseStrategy) {
|
5596 | router.routeReuseStrategy = routeReuseStrategy;
|
5597 | }
|
5598 | if (opts.errorHandler) {
|
5599 | router.errorHandler = opts.errorHandler;
|
5600 | }
|
5601 | if (opts.malformedUriErrorHandler) {
|
5602 | router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
|
5603 | }
|
5604 | if (opts.enableTracing) {
|
5605 | var dom_1 = ɵgetDOM();
|
5606 | router.events.subscribe(function (e) {
|
5607 | dom_1.logGroup("Router Event: " + e.constructor.name);
|
5608 | dom_1.log(e.toString());
|
5609 | dom_1.log(e);
|
5610 | dom_1.logGroupEnd();
|
5611 | });
|
5612 | }
|
5613 | if (opts.onSameUrlNavigation) {
|
5614 | router.onSameUrlNavigation = opts.onSameUrlNavigation;
|
5615 | }
|
5616 | if (opts.paramsInheritanceStrategy) {
|
5617 | router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
|
5618 | }
|
5619 | if (opts.urlUpdateStrategy) {
|
5620 | router.urlUpdateStrategy = opts.urlUpdateStrategy;
|
5621 | }
|
5622 | if (opts.relativeLinkResolution) {
|
5623 | router.relativeLinkResolution = opts.relativeLinkResolution;
|
5624 | }
|
5625 | return router;
|
5626 | }
|
5627 | function rootRoute(router) {
|
5628 | return router.routerState.root;
|
5629 | }
|
5630 |
|
5631 |
|
5632 |
|
5633 |
|
5634 |
|
5635 |
|
5636 |
|
5637 |
|
5638 |
|
5639 |
|
5640 |
|
5641 | var RouterInitializer = (function () {
|
5642 | function RouterInitializer(injector) {
|
5643 | this.injector = injector;
|
5644 | this.initNavigation = false;
|
5645 | this.resultOfPreactivationDone = new Subject();
|
5646 | }
|
5647 | RouterInitializer.prototype.appInitializer = function () {
|
5648 | var _this = this;
|
5649 | var p = this.injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
5650 | return p.then(function () {
|
5651 | var resolve = null;
|
5652 | var res = new Promise(function (r) { return resolve = r; });
|
5653 | var router = _this.injector.get(Router);
|
5654 | var opts = _this.injector.get(ROUTER_CONFIGURATION);
|
5655 | if (_this.isLegacyDisabled(opts) || _this.isLegacyEnabled(opts)) {
|
5656 | resolve(true);
|
5657 | }
|
5658 | else if (opts.initialNavigation === 'disabled') {
|
5659 | router.setUpLocationChangeListener();
|
5660 | resolve(true);
|
5661 | }
|
5662 | else if (opts.initialNavigation === 'enabled') {
|
5663 | router.hooks.afterPreactivation = function () {
|
5664 |
|
5665 | if (!_this.initNavigation) {
|
5666 | _this.initNavigation = true;
|
5667 | resolve(true);
|
5668 | return _this.resultOfPreactivationDone;
|
5669 |
|
5670 | }
|
5671 | else {
|
5672 | return of(null);
|
5673 | }
|
5674 | };
|
5675 | router.initialNavigation();
|
5676 | }
|
5677 | else {
|
5678 | throw new Error("Invalid initialNavigation options: '" + opts.initialNavigation + "'");
|
5679 | }
|
5680 | return res;
|
5681 | });
|
5682 | };
|
5683 | RouterInitializer.prototype.bootstrapListener = function (bootstrappedComponentRef) {
|
5684 | var opts = this.injector.get(ROUTER_CONFIGURATION);
|
5685 | var preloader = this.injector.get(RouterPreloader);
|
5686 | var routerScroller = this.injector.get(RouterScroller);
|
5687 | var router = this.injector.get(Router);
|
5688 | var ref = this.injector.get(ApplicationRef);
|
5689 | if (bootstrappedComponentRef !== ref.components[0]) {
|
5690 | return;
|
5691 | }
|
5692 | if (this.isLegacyEnabled(opts)) {
|
5693 | router.initialNavigation();
|
5694 | }
|
5695 | else if (this.isLegacyDisabled(opts)) {
|
5696 | router.setUpLocationChangeListener();
|
5697 | }
|
5698 | preloader.setUpPreloading();
|
5699 | routerScroller.init();
|
5700 | router.resetRootComponentType(ref.componentTypes[0]);
|
5701 | this.resultOfPreactivationDone.next(null);
|
5702 | this.resultOfPreactivationDone.complete();
|
5703 | };
|
5704 | RouterInitializer.prototype.isLegacyEnabled = function (opts) {
|
5705 | return opts.initialNavigation === 'legacy_enabled' || opts.initialNavigation === true ||
|
5706 | opts.initialNavigation === undefined;
|
5707 | };
|
5708 | RouterInitializer.prototype.isLegacyDisabled = function (opts) {
|
5709 | return opts.initialNavigation === 'legacy_disabled' || opts.initialNavigation === false;
|
5710 | };
|
5711 | RouterInitializer = __decorate([
|
5712 | Injectable(),
|
5713 | __metadata("design:paramtypes", [Injector])
|
5714 | ], RouterInitializer);
|
5715 | return RouterInitializer;
|
5716 | }());
|
5717 | function getAppInitializer(r) {
|
5718 | return r.appInitializer.bind(r);
|
5719 | }
|
5720 | function getBootstrapListener(r) {
|
5721 | return r.bootstrapListener.bind(r);
|
5722 | }
|
5723 |
|
5724 |
|
5725 |
|
5726 |
|
5727 |
|
5728 |
|
5729 | var ROUTER_INITIALIZER = new InjectionToken('Router Initializer');
|
5730 | function provideRouterInitializer() {
|
5731 | return [
|
5732 | RouterInitializer,
|
5733 | {
|
5734 | provide: APP_INITIALIZER,
|
5735 | multi: true,
|
5736 | useFactory: getAppInitializer,
|
5737 | deps: [RouterInitializer]
|
5738 | },
|
5739 | { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener, deps: [RouterInitializer] },
|
5740 | { provide: APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
|
5741 | ];
|
5742 | }
|
5743 |
|
5744 |
|
5745 |
|
5746 |
|
5747 |
|
5748 |
|
5749 |
|
5750 |
|
5751 |
|
5752 |
|
5753 |
|
5754 | var VERSION = new Version('9.0.4');
|
5755 |
|
5756 |
|
5757 |
|
5758 |
|
5759 |
|
5760 |
|
5761 |
|
5762 |
|
5763 |
|
5764 |
|
5765 |
|
5766 |
|
5767 |
|
5768 |
|
5769 |
|
5770 |
|
5771 |
|
5772 |
|
5773 |
|
5774 |
|
5775 |
|
5776 |
|
5777 |
|
5778 |
|
5779 |
|
5780 |
|
5781 |
|
5782 |
|
5783 |
|
5784 |
|
5785 |
|
5786 |
|
5787 |
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 |
|
5793 | export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, ROUTER_FORROOT_GUARD as ɵangular_packages_router_router_a, routerNgProbeToken as ɵangular_packages_router_router_b, createRouterScroller as ɵangular_packages_router_router_c, provideLocationStrategy as ɵangular_packages_router_router_d, provideForRootGuard as ɵangular_packages_router_router_e, setupRouter as ɵangular_packages_router_router_f, rootRoute as ɵangular_packages_router_router_g, RouterInitializer as ɵangular_packages_router_router_h, getAppInitializer as ɵangular_packages_router_router_i, getBootstrapListener as ɵangular_packages_router_router_j, provideRouterInitializer as ɵangular_packages_router_router_k, ɵEmptyOutletComponent as ɵangular_packages_router_router_l, Tree as ɵangular_packages_router_router_m, TreeNode as ɵangular_packages_router_router_n, RouterScroller as ɵangular_packages_router_router_o, flatten as ɵflatten };
|
5794 |
|