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