UNPKG

83.1 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = Object.setPrototypeOf ||
3 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5 return function (d, b) {
6 extendStatics(d, b);
7 function __() { this.constructor = d; }
8 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9 };
10})();
11/**
12 * @license Framing v0.8.20
13 * Copyright 2016-2017 Biznas Innovations, Inc. http://biznas.io
14 * License: Apache License, Version 2.0
15 */
16import { ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectorRef, Component, ComponentFactoryResolver, Directive, EventEmitter, Injectable, Injector, Input, NgModule, NgModuleFactory, Output, Type, ViewContainerRef } from '@angular/core';
17import { ActivatedRoute, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router, RouterModule } from '@angular/router';
18import { assign, camelCase, clone, defaults, differenceWith, each, filter, find, isArray, isEmpty, isEqual, isNil, keys, merge, reject, uniqWith } from 'lodash';
19import { BehaviorSubject } from 'rxjs/BehaviorSubject';
20import { ReplaySubject, Subject } from 'rxjs';
21import { ReplaySubject as ReplaySubject$1 } from 'rxjs/Rx';
22import { CommonModule } from '@angular/common';
23import { FormsModule } from '@angular/forms';
24import { BrowserModule } from '@angular/platform-browser';
25var Component$1 = (function () {
26 function Component$1(controller, injector) {
27 var _this = this;
28 this.controller = controller;
29 this.changeDetectorRef = injector.get(ChangeDetectorRef);
30 this.subscriptions = [];
31 this.subscriptions.push(controller.model$.subscribe(function (model) { return _this.updateModel(model); }), controller.view$.subscribe(function (view) { return _this.updateView(view); }), controller.markForCheck$.subscribe(function () { return _this.changeDetectorRef.markForCheck(); }));
32 this.controller.attach();
33 }
34 Component$1.prototype.ngOnInit = function () {
35 };
36 Component$1.prototype.ngOnDestroy = function () {
37 this.controller.detach();
38 this.subscriptions.forEach(function (s) { return s.unsubscribe(); });
39 this.subscriptions = null;
40 this.changeDetectorRef = null;
41 this.controller = null;
42 this.model = null;
43 this.view = null;
44 };
45 Component$1.prototype.updateModel = function (model) {
46 this.model = model;
47 this.changeDetectorRef.markForCheck();
48 };
49 Component$1.prototype.updateView = function (view) {
50 this.view = view;
51 this.changeDetectorRef.markForCheck();
52 };
53 return Component$1;
54}());
55var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
56 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
57 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
58 r = Reflect.decorate(decorators, target, key, desc);
59 else
60 for (var i = decorators.length - 1; i >= 0; i--)
61 if (d = decorators[i])
62 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
63 return c > 3 && r && Object.defineProperty(target, key, r), r;
64};
65// import { Subject } from 'rxjs/Subject';
66var Controller = (function () {
67 // import { Subject } from 'rxjs/Subject';
68 function Controller() {
69 // ========================================
70 // private properties
71 // ========================================
72 this._refCount = 0;
73 }
74 Object.defineProperty(Controller.prototype, "model$", {
75 // ========================================
76 // public methods
77 // ========================================
78 /**
79 * Model observable accessor.
80 */
81 get: function () { return this._model$; },
82 enumerable: true,
83 configurable: true
84 });
85 Object.defineProperty(Controller.prototype, "model", {
86 /**
87 * Model accessor.
88 */
89 get: function () { return this._model; },
90 enumerable: true,
91 configurable: true
92 });
93 Object.defineProperty(Controller.prototype, "view$", {
94 /**
95 * View observable accessor.
96 */
97 get: function () { return this._view$; },
98 enumerable: true,
99 configurable: true
100 });
101 Object.defineProperty(Controller.prototype, "view", {
102 /**
103 * View accessor.
104 */
105 get: function () { return this._view; },
106 enumerable: true,
107 configurable: true
108 });
109 Object.defineProperty(Controller.prototype, "markForCheck$", {
110 /**
111 * Mark for check observable accessor.
112 */
113 get: function () { return this._markForCheck$; },
114 enumerable: true,
115 configurable: true
116 });
117 Object.defineProperty(Controller.prototype, "frame", {
118 /**
119 * Frame accessor.
120 */
121 get: function () { return this._frame; },
122 enumerable: true,
123 configurable: true
124 });
125 Object.defineProperty(Controller.prototype, "injector", {
126 /**
127 * Model accessor.
128 */
129 get: function () { return this._injector; },
130 enumerable: true,
131 configurable: true
132 });
133 /**
134 * Called after controller is initialized with model, view & frame from framing.
135 */
136 Controller.prototype.onControllerInit = function () { };
137 /**
138 * Called when the controller's route starts resolving.
139 */
140 Controller.prototype.onResolveStart = function () { };
141 /**
142 * Called when the controller's route end resolving.
143 */
144 Controller.prototype.onResolveEnd = function () { };
145 /**
146 * Called when the controller's route resolve is cancelled.
147 */
148 Controller.prototype.onResolveCancel = function () { };
149 /**
150 * Called by framing after construction to link the model, view & frame for this controller.
151 */
152 Controller.prototype.initController = function (model, view, frame, framerName, injector) {
153 var _this = this;
154 this._modelSubject = new BehaviorSubject(model);
155 this._viewSubject = new BehaviorSubject(view);
156 this._model$ = this._modelSubject.asObservable();
157 this._view$ = this._viewSubject.asObservable();
158 this._model = model;
159 this._view = view;
160 this._markForCheckSubject = new BehaviorSubject(true);
161 this._markForCheck$ = this._markForCheckSubject.asObservable();
162 this._frame = frame;
163 this._injector = injector;
164 this._framerName = framerName;
165 if (this._frame) {
166 this._frame.resolveStart$.subscribe(function () { _this.onResolveStart(); });
167 this._frame.resolveEnd$.subscribe(function () { _this.onResolveEnd(); });
168 this._frame.resolveCancel$.subscribe(function () { _this.onResolveCancel(); });
169 }
170 this.onControllerInit();
171 console.log('initController');
172 console.log(this);
173 };
174 Controller.prototype.updateModel = function (model, replace) {
175 if (replace === void 0) { replace = false; }
176 if (replace) {
177 this._model = clone(model);
178 }
179 else {
180 this._model = assign({}, this._model, model);
181 }
182 this._modelSubject.next(this._model);
183 };
184 Controller.prototype.updateView = function (view, replace) {
185 if (replace === void 0) { replace = false; }
186 if (replace) {
187 this._view = clone(view);
188 }
189 else {
190 this._view = assign({}, this._view, view);
191 }
192 this._viewSubject.next(this._view);
193 };
194 Controller.prototype.markForCheck = function () {
195 this._markForCheckSubject.next(true);
196 };
197 Controller.prototype.attach = function () {
198 var _this = this;
199 this._refCount++;
200 if (this._refCount === 1) {
201 setTimeout(function () {
202 _this.onAttached();
203 });
204 }
205 };
206 Controller.prototype.detach = function () {
207 var _this = this;
208 this._refCount--;
209 if (this._refCount === 0) {
210 setTimeout(function () {
211 _this.onDetached();
212 });
213 }
214 };
215 Controller.prototype.onAttached = function () { };
216 Controller.prototype.onDetached = function () { };
217 return Controller;
218}());
219Controller = __decorate$2([
220 Injectable()
221], Controller);
222/**
223 * Dev tool class used for framing integration with Redux DevTools
224 *
225 * @class FramingTools
226 */
227/**
228 * Dev tool class used for framing integration with Redux DevTools
229 *
230 * @class FramingTools
231 */ var FramingTools = (function () {
232 function FramingTools() {
233 this.instantiatedControllers = {};
234 }
235 Object.defineProperty(FramingTools, "Instance", {
236 get: function () {
237 return this._instance || (this._instance = new this());
238 },
239 enumerable: true,
240 configurable: true
241 });
242 FramingTools.prototype.addController = function (framerName, controller) {
243 this.instantiatedControllers[framerName] = controller;
244 };
245 FramingTools.prototype.getAllControllers = function () {
246 return this.instantiatedControllers;
247 };
248 FramingTools.prototype.getControllerByKey = function (key) {
249 return this.instantiatedControllers[key] ? this.instantiatedControllers[key] : null;
250 };
251 return FramingTools;
252}());
253var framingTools = FramingTools.Instance;
254var stateRoot = {};
255var onLoad = true;
256// let controllers: any[] = [];
257var devTools = _createReduxDevtoolsExtension();
258var isListening = false;
259/* tslint:disable */
260function Action(description, log) {
261 if (description === void 0) { description = null; }
262 if (log === void 0) { log = true; }
263 return function (target, propertyKey, descriptor) {
264 if (descriptor === undefined) {
265 descriptor = Object.getOwnPropertyDescriptor(target, propertyKey);
266 }
267 var originalMethod = descriptor.value;
268 descriptor.value = function () {
269 var args = [];
270 var controller = this;
271 // let controllerIndex: number;
272 // if (controllers.indexOf(controller) <= -1) {
273 // controllers.push(controller);
274 // controllerIndex = controllers.length - 1;
275 // } else {
276 // controllerIndex = controllers.indexOf(controller);
277 // }
278 for (var _i = 0; _i < arguments.length; _i++) {
279 args[_i] = arguments[_i];
280 }
281 try {
282 listenForChanges();
283 }
284 catch (e) {
285 console.log('Listen to Devtools failed: ');
286 console.log(e);
287 }
288 // Send the initial state if this is the first time connecting to the dev tools
289 if (onLoad && log && devTools) {
290 onLoad = !onLoad;
291 stateRoot[controller._framerName] = controller.model;
292 var state = {
293 framerName: controller._framerName,
294 value: stateRoot,
295 };
296 try {
297 devTools.send((description || propertyKey), state);
298 }
299 catch (e) {
300 console.log('Send to Devtools failed: ');
301 console.log(e);
302 }
303 }
304 originalMethod.apply(controller, args);
305 // Need to log after the method has been ran and state is updated
306 if (log && devTools) {
307 stateRoot[controller._framerName] = controller.model;
308 var state = {
309 framerName: controller._framerName,
310 // controllerIndex: controllerIndex,
311 value: stateRoot,
312 };
313 try {
314 devTools.send((description || propertyKey), state);
315 }
316 catch (e) {
317 console.log('Send to Devtools failed: ');
318 console.log(e);
319 }
320 }
321 controller.markForCheck();
322 };
323 return descriptor;
324 };
325}
326/**
327 * Listen for message events being broadcast from the redux devTools
328 * Changes state on the correct controller to match the state changes broadcast
329 */
330function listenForChanges() {
331 if (isListening || !devTools)
332 return;
333 isListening = true;
334 var connection = devTools.connect();
335 connection.subscribe(function (message) {
336 if (!!message.state) {
337 var messageState = JSON.parse(message.state);
338 var messageController = framingTools.getControllerByKey(messageState.framerName);
339 if (messageController) {
340 for (var prop in messageController.model) {
341 messageController.model[prop] = messageState.value[messageState.framerName][prop];
342 }
343 messageController.markForCheck();
344 }
345 }
346 });
347}
348/**
349 * Returns correct instance of redux dev tools installed
350 *
351 * @export
352 * @returns
353 */
354function _createReduxDevtoolsExtension() {
355 var legacyExtensionKey = 'devToolsExtension';
356 var extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
357 if (typeof window === 'object' && typeof window[legacyExtensionKey] !== 'undefined') {
358 return window[legacyExtensionKey];
359 }
360 else if (typeof window === 'object' && typeof window[extensionKey] !== 'undefined') {
361 return window[extensionKey];
362 }
363 else {
364 return null;
365 }
366}
367var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
368 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
369 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
370 r = Reflect.decorate(decorators, target, key, desc);
371 else
372 for (var i = decorators.length - 1; i >= 0; i--)
373 if (d = decorators[i])
374 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
375 return c > 3 && r && Object.defineProperty(target, key, r), r;
376};
377var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
378 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
379 return Reflect.metadata(k, v);
380};
381var FramingDevToolsController = (function (_super) {
382 __extends(FramingDevToolsController, _super);
383 function FramingDevToolsController(router) {
384 var _this = _super.call(this) || this;
385 _this.router = router;
386 _this.replayNavigation = false;
387 return _this;
388 }
389 FramingDevToolsController.prototype.onControllerInit = function () {
390 var _this = this;
391 this.router.events.subscribe(function (event) {
392 _this.handleRouterEvents(event);
393 });
394 this.markForCheck$.subscribe(function (data) {
395 if (_this.model.snapshotUrl && _this.model.snapshotUrl !== _this.router.routerState.snapshot.url) {
396 _this.replayNavigation = true;
397 _this.router.navigate([_this.model.snapshotUrl]);
398 }
399 }, function (err) { return console.error(err); });
400 };
401 FramingDevToolsController.prototype.trackRouterState = function () {
402 this.model.snapshotUrl = this.router.routerState.snapshot.url;
403 };
404 FramingDevToolsController.prototype.handleRouterEvents = function (event) {
405 if (event instanceof NavigationEnd) {
406 if (!this.replayNavigation) {
407 this.trackRouterState();
408 }
409 this.replayNavigation = false;
410 }
411 };
412 return FramingDevToolsController;
413}(Controller));
414__decorate$1([
415 Action(),
416 __metadata$1("design:type", Function),
417 __metadata$1("design:paramtypes", []),
418 __metadata$1("design:returntype", void 0)
419], FramingDevToolsController.prototype, "trackRouterState", null);
420FramingDevToolsController = __decorate$1([
421 Injectable(),
422 __metadata$1("design:paramtypes", [Router])
423], FramingDevToolsController);
424var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
425 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
426 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
427 r = Reflect.decorate(decorators, target, key, desc);
428 else
429 for (var i = decorators.length - 1; i >= 0; i--)
430 if (d = decorators[i])
431 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
432 return c > 3 && r && Object.defineProperty(target, key, r), r;
433};
434var __metadata = (undefined && undefined.__metadata) || function (k, v) {
435 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
436 return Reflect.metadata(k, v);
437};
438var FramingDevToolsComponent = (function (_super) {
439 __extends(FramingDevToolsComponent, _super);
440 function FramingDevToolsComponent(controller, injector) {
441 return _super.call(this, controller, injector) || this;
442 }
443 return FramingDevToolsComponent;
444}(Component$1));
445FramingDevToolsComponent = __decorate([
446 Component({}),
447 __metadata("design:paramtypes", [FramingDevToolsController, Injector])
448], FramingDevToolsComponent);
449var Frame = (function () {
450 function Frame() {
451 // ========================================
452 // public properties
453 // ========================================
454 /**
455 * Subjects
456 */
457 this.routeUrlSubject = new ReplaySubject();
458 this.resolveStartSubject = new Subject();
459 this.resolveEndSubject = new Subject();
460 this.resolveCancelSubject = new Subject();
461 }
462 Object.defineProperty(Frame.prototype, "routeUrl$", {
463 /**
464 * An observable of the route url of the route that this controllerr is attached to, if any.
465 */
466 get: function () { return this.routeUrlSubject; },
467 enumerable: true,
468 configurable: true
469 });
470 Object.defineProperty(Frame.prototype, "resolveStart$", {
471 /**
472 * Emitted when the frame resolve method starts if this controller is attached to a route.
473 */
474 get: function () { return this.resolveStartSubject; },
475 enumerable: true,
476 configurable: true
477 });
478 Object.defineProperty(Frame.prototype, "resolveEnd$", {
479 /**
480 * Emitted when the frame resolve method ends if this controller is attached to a route.
481 */
482 get: function () { return this.resolveEndSubject; },
483 enumerable: true,
484 configurable: true
485 });
486 Object.defineProperty(Frame.prototype, "resolveCancel$", {
487 /**
488 * Emitted when the frame resolve method is cancelled if this controller is attached to a route.
489 */
490 get: function () { return this.resolveCancelSubject; },
491 enumerable: true,
492 configurable: true
493 });
494 return Frame;
495}());
496/**
497 * @description This is a description
498 */
499var Framer = (function () {
500 // ========================================
501 // constructor
502 // ========================================
503 /**
504 * Contructor.
505 */
506 function Framer(model, view, controller) {
507 this.framingDevTools = FramingTools.Instance;
508 /**
509 * True if framing() has been called.
510 */
511 this._framed = false;
512 this.construct(model, view, controller);
513 }
514 Object.defineProperty(Framer.prototype, "theModel", {
515 /**
516 * Model accessor.
517 */
518 get: function () { return this._model; },
519 enumerable: true,
520 configurable: true
521 });
522 Object.defineProperty(Framer.prototype, "theView", {
523 /**
524 * View accessor.
525 */
526 get: function () { return this._view; },
527 enumerable: true,
528 configurable: true
529 });
530 Object.defineProperty(Framer.prototype, "theController", {
531 /**
532 * Controller accessor.
533 */
534 get: function () { return this._controller; },
535 enumerable: true,
536 configurable: true
537 });
538 Object.defineProperty(Framer.prototype, "createFrame", {
539 /**
540 * When true, framing will create a frame for this framer.
541 */
542 get: function () { return true; },
543 enumerable: true,
544 configurable: true
545 });
546 Object.defineProperty(Framer.prototype, "multiFramer", {
547 /**
548 * When true, framing will use multi on all providers so multiple framers of the same type can be setup on the same module.
549 */
550 get: function () { return false; },
551 enumerable: true,
552 configurable: true
553 });
554 Object.defineProperty(Framer.prototype, "provideControllerByType", {
555 /**
556 * When true, framing will setup the controller as a provider by its type.
557 */
558 get: function () { return true; },
559 enumerable: true,
560 configurable: true
561 });
562 Object.defineProperty(Framer.prototype, "addModelToRouteData", {
563 /**
564 * When true, framing will add the model to the route data.
565 */
566 get: function () { return false; },
567 enumerable: true,
568 configurable: true
569 });
570 Object.defineProperty(Framer.prototype, "addViewToRouteData", {
571 /**
572 * When true, framing will add the view to the route data.
573 */
574 get: function () { return false; },
575 enumerable: true,
576 configurable: true
577 });
578 Object.defineProperty(Framer.prototype, "addFrameToRouteData", {
579 /**
580 * When true, framing will add the frame to the route data.
581 */
582 get: function () { return false; },
583 enumerable: true,
584 configurable: true
585 });
586 Object.defineProperty(Framer.prototype, "defaultModel", {
587 /**
588 * The default model.
589 */
590 get: function () { return undefined; },
591 enumerable: true,
592 configurable: true
593 });
594 Object.defineProperty(Framer.prototype, "defaultView", {
595 /**
596 * The default view.
597 */
598 get: function () { return undefined; },
599 enumerable: true,
600 configurable: true
601 });
602 Object.defineProperty(Framer.prototype, "defaultController", {
603 /**
604 * The default controller.
605 */
606 get: function () { return undefined; },
607 enumerable: true,
608 configurable: true
609 });
610 Object.defineProperty(Framer.prototype, "routeRule", {
611 /**
612 * 'require': framing will attach the default route, creating it if it doesn't yet exist, if not route is attached to this framer (default behavior)
613 * 'auto': framing will attach the default route if available if not route is attached to this framer
614 * 'none': framing will not attach a route to this framer
615 */
616 get: function () { return 'require'; },
617 enumerable: true,
618 configurable: true
619 });
620 Object.defineProperty(Framer.prototype, "framerId", {
621 /**
622 * A unique framer id for this framer.
623 */
624 get: function () { return this._framerId; },
625 enumerable: true,
626 configurable: true
627 });
628 Object.defineProperty(Framer.prototype, "framerIdent", {
629 /**
630 * A unique identifier string for this framer instance.
631 */
632 get: function () { return this.framerName + "Framer-" + this._framerId; },
633 enumerable: true,
634 configurable: true
635 });
636 Object.defineProperty(Framer.prototype, "framed", {
637 /**
638 * True if framing() has been called.
639 */
640 get: function () { return this._framed; },
641 enumerable: true,
642 configurable: true
643 });
644 Object.defineProperty(Framer.prototype, "injector", {
645 /**
646 * The injector (available on and after framerOnResolveRoute or framerOnControllerInit, whichever comes first)
647 */
648 get: function () { return this._injector; },
649 enumerable: true,
650 configurable: true
651 });
652 Object.defineProperty(Framer.prototype, "route", {
653 /**
654 * The framer's route, if attached to a route, otherwise undefined
655 * Valid ONLY during the runFraming() and framing() functions
656 */
657 get: function () { return this._route; },
658 enumerable: true,
659 configurable: true
660 });
661 // ========================================
662 // public static methods
663 // ========================================
664 /**
665 * Helper function to build the URL of an ActivatedRouteSnapshot
666 */
667 Framer.buildUrlLink = function (route) {
668 if (!route) {
669 return '/';
670 }
671 var urls = [];
672 /* tslint:disable:no-param-reassign */
673 for (; route.parent; route = route.parent) {
674 /* tslint:enable:no-param-reassign */
675 urls = urls.concat(route.url.reverse());
676 }
677 urls = urls.reverse();
678 return '/' + urls.join('/');
679 };
680 // ========================================
681 // public methods
682 // ========================================
683 /**
684 * Model chaining function.
685 */
686 Framer.prototype.model = function (model) {
687 merge(this._model, model);
688 return this;
689 };
690 /**
691 * View chaining function.
692 */
693 Framer.prototype.view = function (view) {
694 merge(this._view, view);
695 return this;
696 };
697 /**
698 * Controller chaining function.
699 */
700 Framer.prototype.controller = function (controller) {
701 if (controller) {
702 this._controller = controller;
703 }
704 return this;
705 };
706 /**
707 * Framer on resolve route function called when framer's route is resolved.
708 * Injector is set before during this call.
709 * Not called if framer is not attached to a route.
710 * To be overwritten if needed.
711 */
712 Framer.prototype.framerOnResolveRoute = function () { };
713 /**
714 * Framer on controller init function is called when the controller is first injected.
715 * To be overwritten if needed.
716 */
717 Framer.prototype.framerOnControllerInit = function (controller) { };
718 /**
719 * Calls derived framing()
720 */
721 Framer.prototype.runFraming = function (framing, routeParam) {
722 var _this = this;
723 if (this._framed) {
724 console.warn("runFraming() called multiple times on framer '" + this.framerIdent + "'");
725 return;
726 }
727 this._framed = true; // mark this framer to framed
728 if (this.routeRule === 'auto') {
729 // set the framer's attached route (if any)
730 this._route = routeParam;
731 }
732 else if (this.routeRule === 'require') {
733 // set the framer's attached route to the supplied route or create one if it doesn not exist
734 if (routeParam) {
735 this._route = routeParam;
736 }
737 else {
738 /* tslint:disable:no-param-reassign */
739 this._route = routeParam = framing.getOrAddRoute();
740 /* tslint:enable:no-param-reassign */
741 }
742 }
743 this._framing = framing; // set _framing to framing ONLY for the duration of the controller() function
744 try {
745 this.frame(framing);
746 }
747 catch (e) {
748 console.error("Exception when framing " + this.framerIdent + " :", e);
749 this._model = undefined;
750 this._view = undefined;
751 this._controller = undefined;
752 }
753 this._framing = undefined;
754 if (this.routeRule === 'auto') {
755 this._route = routeParam;
756 }
757 var self = this;
758 if (this._controller) {
759 // FUTURE
760 // this.provideTypeByName(framing, this.framerName + 'Controller', this._controller);
761 if (this.provideControllerByType) {
762 var controllerInstance_1;
763 framing
764 .provide({
765 provide: this.framerIdent + '-ControllerInternal',
766 useClass: this._controller,
767 })
768 .provide({
769 provide: this.framerIdent + '-Controller',
770 useFactory: function (injector) {
771 if (controllerInstance_1) {
772 _this.framingDevTools.addController(_this.framerName, controllerInstance_1);
773 return controllerInstance_1;
774 }
775 self._injector = injector;
776 controllerInstance_1 = injector.get(_this.framerIdent + '-ControllerInternal');
777 controllerInstance_1.initController(_this._model, _this._view, _this._frame, _this.framerName, injector);
778 _this.framerOnControllerInit(controllerInstance_1);
779 _this.framingDevTools.addController(_this.framerName, controllerInstance_1);
780 return controllerInstance_1;
781 },
782 deps: [Injector],
783 })
784 .provide({
785 provide: this._controller,
786 useExisting: this.framerIdent + '-Controller',
787 multi: this.multiFramer && this._controller === this.defaultController,
788 });
789 /* tslint:disable:no-console */
790 console.info("Providing controller for framer " + this.framerIdent + " by type");
791 /* tslint:enable:no-console */
792 if (this.defaultController && this._controller !== this.defaultController) {
793 framing.provide({
794 provide: this.defaultController,
795 useExisting: this.framerIdent + '-Controller',
796 multi: this.multiFramer,
797 });
798 /* tslint:disable:no-console */
799 console.info("Providing controller overload for framer " + this.framerIdent + " by default controller type");
800 /* tslint:enable:no-console */
801 }
802 }
803 }
804 // FUTURE: frame, model & view provided by name
805 // this.provideValueByName(framing, this.framerName + 'Frame', this._frame);
806 // this.provideValueByName(framing, this.framerName + 'Model', this._model);
807 // this.provideValueByName(framing, this.framerName + 'View', this._view);
808 // FUTURE: model & view provided by type
809 // this.provideInstanceByType(framing, this._model);
810 // this.provideInstanceByType(framing, this._view);
811 if (this.route) {
812 if (this.addFrameToRouteData) {
813 this.addRouteData(framing, this.framerName + 'Frame', this._frame);
814 }
815 if (this.addModelToRouteData) {
816 this.addRouteData(framing, this.framerName + 'Model', this._model);
817 }
818 if (this.addViewToRouteData) {
819 this.addRouteData(framing, this.framerName + 'View', this._view);
820 }
821 if (this._frame) {
822 var FrameResolver_1 = (function () {
823 function FrameResolver_1(router, route, injector) {
824 this.router = router;
825 this.route = route;
826 self._injector = injector;
827 }
828 FrameResolver_1.prototype.resolve = function (routeSnapshot, routeStateSnapshot) {
829 var _this = this;
830 self._frame.resolveStartSubject.next();
831 var routeUrl = Framer.buildUrlLink(routeSnapshot);
832 var sub = this.router.events.subscribe(function (event) {
833 if (event instanceof NavigationStart) {
834 console.error('Unexpected NavigationStart');
835 }
836 else if (event instanceof NavigationEnd) {
837 /* tslint:disable:no-console */
838 console.info("Route url for framer " + self.framerIdent + " changed to " + routeUrl);
839 /* tslint:enable:no-console */
840 self._frame.routeSnapshot = self.findActivateRouteSnapshot(_this.route);
841 self._frame.routeUrl = routeUrl;
842 self._frame.routeUrlSubject.next(routeUrl);
843 self.framerOnResolveRoute();
844 self._frame.resolveEndSubject.next();
845 }
846 else if (event instanceof NavigationError) {
847 self._frame.resolveCancelSubject.next();
848 }
849 else if (event instanceof NavigationCancel) {
850 self._frame.resolveCancelSubject.next();
851 }
852 sub.unsubscribe();
853 });
854 return self._frame;
855 };
856 return FrameResolver_1;
857 }());
858 framing
859 .resolve(this.framerIdent, FrameResolver_1, this.route)
860 .provide({
861 provide: FrameResolver_1,
862 useFactory: function (r, a, i) { return new FrameResolver_1(r, a, i); },
863 deps: [Router, ActivatedRoute, Injector]
864 });
865 }
866 }
867 this._route = undefined; // clear the route so we're not holding any references to its properties
868 };
869 /**
870 * Protected construct function for derived construction help.
871 */
872 Framer.prototype.construct = function (model, view, controller) {
873 this._framerId = Framer._nextId++;
874 if (this.createFrame) {
875 this._frame = new Frame();
876 }
877 var defaultModel = this.defaultModel;
878 this._model = defaultModel ? merge(defaultModel, model) : model;
879 var defaultView = this.defaultView;
880 this._view = defaultView ? merge(defaultView, view) : view;
881 this._controller = controller || this.defaultController;
882 };
883 /**
884 * Protected construct function for derived construction help.
885 */
886 Framer.prototype.findActivateRouteSnapshot = function (route) {
887 if (!route) {
888 console.error('Failed to find activated route snapshot');
889 return undefined;
890 }
891 if (route.snapshot && route.snapshot.data && route.snapshot.data.hasOwnProperty(this.framerIdent)) {
892 return route.snapshot;
893 }
894 return this.findActivateRouteSnapshot(route.firstChild);
895 };
896 /**
897 * FUTURE
898 */
899 // private provideTypeByName(framing: FramingNgModule, name: string, type: any): void {
900 // if (type) {
901 // framing.provide({ provide: name, useClass: type });
902 // /* tslint:disable:no-console */
903 // console.info(`Providing ${name} for framer ${this.framerIdent} by name`);
904 // /* tslint:enable:no-console */
905 // }
906 // }
907 /**
908 * FUTURE
909 */
910 // private provideInstanceByType(framing: FramingNgModule, instance: any): void {
911 // if (instance &&
912 // (instance as any).__proto__ &&
913 // (instance as any).__proto__.constructor &&
914 // (instance as any).__proto__.constructor.name !== 'Object') {
915 // framing.provide({ provide: (instance as any).__proto__.constructor, useValue: instance });
916 // /* tslint:disable:no-console */
917 // console.info(`Providing ${(instance as any).__proto__.constructor.name} for framer ${this.framerIdent} by type`);
918 // /* tslint:enable:no-console */
919 // }
920 // }
921 /**
922 * FUTURE
923 */
924 // private provideValueByName(framing: FramingNgModule, name: string, value: any): void {
925 // if (value) {
926 // framing.provide({ provide: name, useValue: value });
927 // /* tslint:disable:no-console */
928 // console.info(`Providing ${name} for framer ${this.framerIdent} by name`);
929 // /* tslint:enable:no-console */
930 // }
931 // }
932 Framer.prototype.addRouteData = function (framing, name, value) {
933 if (value) {
934 var routeConfig = framing.getOrAddRoute(this.route);
935 if (routeConfig.data && routeConfig.data[name]) {
936 console.warn("Failed to add " + name + " route data for framer " + this.framerIdent + ". Data item already exists.");
937 }
938 else {
939 framing.datum(name, value, this.route);
940 /* tslint:disable:no-console */
941 console.info("Adding " + name + " route data for framer " + this.framerIdent);
942 /* tslint:enable:no-console */
943 }
944 }
945 };
946 return Framer;
947}());
948Framer._nextId = 1;
949var FramingDevToolsFeature = (function (_super) {
950 __extends(FramingDevToolsFeature, _super);
951 function FramingDevToolsFeature() {
952 return _super !== null && _super.apply(this, arguments) || this;
953 }
954 Object.defineProperty(FramingDevToolsFeature.prototype, "defaultModel", {
955 get: function () {
956 return {};
957 },
958 enumerable: true,
959 configurable: true
960 });
961 Object.defineProperty(FramingDevToolsFeature.prototype, "defaultView", {
962 get: function () {
963 return {};
964 },
965 enumerable: true,
966 configurable: true
967 });
968 FramingDevToolsFeature.prototype.frame = function (framing) { };
969 FramingDevToolsFeature.prototype.framerOnResolveRoute = function () {
970 var framingDevToolsController;
971 framingDevToolsController = this.injector.get(FramingDevToolsController);
972 };
973 Object.defineProperty(FramingDevToolsFeature.prototype, "framerName", {
974 // ========================================
975 // internal framing methods (don't touch!)
976 // ========================================
977 get: function () { return 'FramingDevTools'; },
978 enumerable: true,
979 configurable: true
980 });
981 Object.defineProperty(FramingDevToolsFeature.prototype, "defaultController", {
982 get: function () { return FramingDevToolsController; },
983 enumerable: true,
984 configurable: true
985 });
986 return FramingDevToolsFeature;
987}(Framer));
988var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
989 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
990 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
991 r = Reflect.decorate(decorators, target, key, desc);
992 else
993 for (var i = decorators.length - 1; i >= 0; i--)
994 if (d = decorators[i])
995 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
996 return c > 3 && r && Object.defineProperty(target, key, r), r;
997};
998var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
999 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1000 return Reflect.metadata(k, v);
1001};
1002var FramingComponentOutletDirective = (function () {
1003 function FramingComponentOutletDirective(_view) {
1004 this._view = _view;
1005 this.onComponent = new EventEmitter();
1006 }
1007 FramingComponentOutletDirective.prototype.isActivated = function () { return !!this._componentRef; };
1008 FramingComponentOutletDirective.prototype.ngOnChanges = function (changes) {
1009 var activate = false;
1010 if (changes.ngModuleFactory) {
1011 if (this._moduleRef) {
1012 this._moduleRef.destroy();
1013 }
1014 if (this.ngModuleFactory) {
1015 var injector = this.injector || this._view.parentInjector;
1016 this._moduleRef = this.ngModuleFactory.create(injector);
1017 }
1018 else {
1019 this._moduleRef = undefined;
1020 }
1021 activate = true;
1022 }
1023 if (changes.framingComponentOutlet.currentValue !== changes.framingComponentOutlet.previousValue) {
1024 activate = true;
1025 }
1026 if (activate) {
1027 this.activate(this.framingComponentOutlet);
1028 }
1029 };
1030 FramingComponentOutletDirective.prototype.ngOnDestroy = function () {
1031 this.deactivate();
1032 if (this._moduleRef) {
1033 this._moduleRef.destroy();
1034 }
1035 };
1036 FramingComponentOutletDirective.prototype.activate = function (component) {
1037 this.deactivate();
1038 if (!component) {
1039 return;
1040 }
1041 try {
1042 var injector = this.injector || this._view.parentInjector;
1043 var factory = injector.get(ComponentFactoryResolver).resolveComponentFactory(component);
1044 this._componentRef = this._view.createComponent(factory, this._view.length, injector, this.content);
1045 this.onComponent.emit(this._componentRef);
1046 try {
1047 this._componentRef.changeDetectorRef.detectChanges();
1048 }
1049 catch (e) {
1050 console.error("detectChanges failed on activated component in FramingComponentOutlet", { e: e, component: component });
1051 return;
1052 }
1053 }
1054 catch (e) {
1055 console.error("Failed to activate component in FramingComponentOutlet", { e: e, component: component });
1056 return;
1057 }
1058 };
1059 FramingComponentOutletDirective.prototype.deactivate = function () {
1060 if (this._componentRef) {
1061 this._view.remove(this._view.indexOf(this._componentRef.hostView));
1062 this._componentRef.destroy();
1063 }
1064 this._view.clear();
1065 this._componentRef = undefined;
1066 };
1067 return FramingComponentOutletDirective;
1068}());
1069__decorate$3([
1070 Input(),
1071 __metadata$2("design:type", Type)
1072], FramingComponentOutletDirective.prototype, "framingComponentOutlet", void 0);
1073__decorate$3([
1074 Input(),
1075 __metadata$2("design:type", Injector)
1076], FramingComponentOutletDirective.prototype, "injector", void 0);
1077__decorate$3([
1078 Input(),
1079 __metadata$2("design:type", Array)
1080], FramingComponentOutletDirective.prototype, "content", void 0);
1081__decorate$3([
1082 Input(),
1083 __metadata$2("design:type", NgModuleFactory)
1084], FramingComponentOutletDirective.prototype, "ngModuleFactory", void 0);
1085__decorate$3([
1086 Output(),
1087 __metadata$2("design:type", EventEmitter)
1088], FramingComponentOutletDirective.prototype, "onComponent", void 0);
1089FramingComponentOutletDirective = __decorate$3([
1090 Directive({
1091 selector: '[framingComponentOutlet]',
1092 }),
1093 __metadata$2("design:paramtypes", [ViewContainerRef])
1094], FramingComponentOutletDirective);
1095var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1096 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1097 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1098 r = Reflect.decorate(decorators, target, key, desc);
1099 else
1100 for (var i = decorators.length - 1; i >= 0; i--)
1101 if (d = decorators[i])
1102 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1103 return c > 3 && r && Object.defineProperty(target, key, r), r;
1104};
1105var FramingComponentOutletModule = FramingComponentOutletModule_1 = (function () {
1106 function FramingComponentOutletModule() {
1107 }
1108 FramingComponentOutletModule.withEntryComponents = function () {
1109 var components = [];
1110 for (var _a = 0; _a < arguments.length; _a++) {
1111 components[_a] = arguments[_a];
1112 }
1113 return {
1114 ngModule: FramingComponentOutletModule_1,
1115 providers: [
1116 { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: components, multi: true },
1117 ],
1118 };
1119 };
1120 return FramingComponentOutletModule;
1121}());
1122FramingComponentOutletModule = FramingComponentOutletModule_1 = __decorate$4([
1123 NgModule({
1124 declarations: [FramingComponentOutletDirective],
1125 exports: [FramingComponentOutletDirective],
1126 })
1127], FramingComponentOutletModule);
1128var FramingComponentOutletModule_1;
1129var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1130 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1131 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1132 r = Reflect.decorate(decorators, target, key, desc);
1133 else
1134 for (var i = decorators.length - 1; i >= 0; i--)
1135 if (d = decorators[i])
1136 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1137 return c > 3 && r && Object.defineProperty(target, key, r), r;
1138};
1139var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) {
1140 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1141 return Reflect.metadata(k, v);
1142};
1143var FramingContainerOutletService = (function () {
1144 function FramingContainerOutletService(router) {
1145 var _this = this;
1146 this.router = router;
1147 this.contentsSubject = new ReplaySubject$1();
1148 this.contents = [];
1149 this.routeContents = [];
1150 this.subscriptions = [];
1151 this.subscriptions.push(this.router.events.subscribe(function (event) {
1152 if (event instanceof NavigationEnd) {
1153 _this.onNavigationEnd();
1154 }
1155 }));
1156 }
1157 Object.defineProperty(FramingContainerOutletService.prototype, "contents$", {
1158 get: function () { return this.contentsSubject.asObservable(); },
1159 enumerable: true,
1160 configurable: true
1161 });
1162 FramingContainerOutletService.prototype.hasContent = function (container) {
1163 return !!this.contents.filter(function (c) { return isEqual(c.container, container); }).length;
1164 };
1165 FramingContainerOutletService.prototype.activate = function (content) {
1166 var _this = this;
1167 this.contents.push(content);
1168 this.contentsSubject.next(clone(this.contents));
1169 return function () { _this.deactivate(content); };
1170 };
1171 FramingContainerOutletService.prototype.deactivate = function (content) {
1172 this.contents = this.contents.filter(function (e) { return e !== content; });
1173 this.contentsSubject.next(clone(this.contents));
1174 };
1175 FramingContainerOutletService.prototype.onNavigationEnd = function () {
1176 var _this = this;
1177 var newRouteContents = [];
1178 this.resolveRouteContents(this.router.routerState.snapshot.root, newRouteContents);
1179 newRouteContents = uniqWith(newRouteContents, isEqual);
1180 var newContents = differenceWith(newRouteContents, this.routeContents, isEqual);
1181 var removedContents = differenceWith(this.routeContents, newRouteContents, isEqual);
1182 newContents.forEach(function (c) { return _this.activate(c); });
1183 removedContents.forEach(function (c) { return _this.deactivate(c); });
1184 this.routeContents = newRouteContents;
1185 };
1186 FramingContainerOutletService.prototype.resolveRouteContents = function (snapshot, routeContents) {
1187 if (snapshot.data && snapshot.data.containers) {
1188 var containers = snapshot.data.containers;
1189 for (var _a = 0, containers_1 = containers; _a < containers_1.length; _a++) {
1190 var container = containers_1[_a];
1191 routeContents.push(container);
1192 }
1193 }
1194 for (var _b = 0, _c = snapshot.children; _b < _c.length; _b++) {
1195 var child = _c[_b];
1196 this.resolveRouteContents(child, routeContents);
1197 }
1198 };
1199 return FramingContainerOutletService;
1200}());
1201FramingContainerOutletService = __decorate$6([
1202 Injectable(),
1203 __metadata$4("design:paramtypes", [Router])
1204], FramingContainerOutletService);
1205var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1206 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1207 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1208 r = Reflect.decorate(decorators, target, key, desc);
1209 else
1210 for (var i = decorators.length - 1; i >= 0; i--)
1211 if (d = decorators[i])
1212 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1213 return c > 3 && r && Object.defineProperty(target, key, r), r;
1214};
1215var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) {
1216 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1217 return Reflect.metadata(k, v);
1218};
1219var FramingContainerOutletDirective = (function () {
1220 function FramingContainerOutletDirective(_view, _containerService, _router) {
1221 this._view = _view;
1222 this._containerService = _containerService;
1223 this._router = _router;
1224 this.onComponents = new EventEmitter();
1225 this._activated = [];
1226 this._subscriptions = [];
1227 }
1228 FramingContainerOutletDirective.prototype.containerName = function () { return this.framingContainerOutlet; };
1229 FramingContainerOutletDirective.prototype.isActivated = function () { return this._activated.length > 0; };
1230 FramingContainerOutletDirective.prototype.ngOnInit = function () {
1231 var _this = this;
1232 if (!this.framingContainerOutlet) {
1233 console.warn('FramingContainerOutlet without a container name');
1234 }
1235 else {
1236 if (this.framingContainerOutlet[0] === '\'') {
1237 console.warn("FramingContainerOutlet name \"" + this.framingContainerOutlet + "\" starts with a qoute");
1238 }
1239 this._subscriptions.push(this._containerService.contents$.subscribe(function (contents) { return _this.onContent(contents); }));
1240 }
1241 this._subscriptions.push(this._router.events.subscribe(function (event) {
1242 if (event instanceof NavigationEnd) {
1243 if (!_this.optionalContainer && !_this.isActivated()) {
1244 console.warn("No content for required FramingContainerOutlet '" + _this.framingContainerOutlet + "' found");
1245 }
1246 }
1247 }));
1248 };
1249 FramingContainerOutletDirective.prototype.ngOnDestroy = function () {
1250 var _this = this;
1251 this._activated.forEach(function (a) { return _this.deactivate(a); });
1252 this._subscriptions.forEach(function (s) { return s.unsubscribe(); });
1253 };
1254 FramingContainerOutletDirective.prototype.onContent = function (allContents) {
1255 var _this = this;
1256 var contents = allContents.filter(function (c) { return isEqual(c.container, _this.framingContainerOutlet); });
1257 // remove all content that is no longer active
1258 this._activated.forEach(function (a) {
1259 if (contents.findIndex(function (content) { return content === a.content; }) === -1) {
1260 _this.deactivate(a);
1261 }
1262 });
1263 this._activated = this._activated.filter(function (a) { return !!a.ref; });
1264 // now setup the new activated components
1265 var i = 0;
1266 var _loop_1 = function (content) {
1267 if (this_1._activated.length > i) {
1268 if (this_1._activated[i].content !== content) {
1269 // look for this content
1270 var activatedIndex = this_1._activated.findIndex(function (a) { return a.content === content; });
1271 if (activatedIndex === -1) {
1272 // activate this content at i
1273 this_1._activated.splice(i, 0, { content: content, ref: this_1.activate(content) });
1274 }
1275 else if (activatedIndex > i) {
1276 // move content from activatedIndex to i
1277 var _activated = this_1._activated.splice(activatedIndex, 1);
1278 (_a = this_1._activated).splice.apply(_a, [i, 0].concat(_activated));
1279 var view = this_1._view.detach(activatedIndex);
1280 this_1._view.insert(view, i);
1281 }
1282 else {
1283 console.error('Logic error in FramingContainerOutlet!');
1284 }
1285 }
1286 }
1287 else {
1288 // activate this content
1289 var ref = this_1.activate(content);
1290 if (ref) {
1291 this_1._activated.push({ content: content, ref: ref });
1292 }
1293 }
1294 i++;
1295 var _a;
1296 };
1297 var this_1 = this;
1298 for (var _a = 0, contents_1 = contents; _a < contents_1.length; _a++) {
1299 var content = contents_1[_a];
1300 _loop_1(content);
1301 }
1302 this.onComponents.emit(this._activated.map(function (a) { return a.ref; }));
1303 };
1304 FramingContainerOutletDirective.prototype.activate = function (content, i) {
1305 try {
1306 var injector = (!this.useViewInjector && content.injector) ? content.injector : this._view.parentInjector;
1307 var factory = injector.get(ComponentFactoryResolver).resolveComponentFactory(content.component);
1308 var ref = this._view.createComponent(factory, i, injector, this.content);
1309 try {
1310 ref.changeDetectorRef.detectChanges();
1311 }
1312 catch (e) {
1313 console.error("detectChanges failed on activated component in FramingContainerOutlet '" + this.framingContainerOutlet + "'", { e: e, component: content.component });
1314 }
1315 return ref;
1316 }
1317 catch (e) {
1318 console.error("Failed to activate component in FramingContainerOutlet '" + this.framingContainerOutlet + "'", { e: e, component: content.component });
1319 return undefined;
1320 }
1321 };
1322 FramingContainerOutletDirective.prototype.deactivate = function (activated) {
1323 activated.ref.destroy();
1324 activated.ref = null;
1325 };
1326 return FramingContainerOutletDirective;
1327}());
1328__decorate$5([
1329 Input(),
1330 __metadata$3("design:type", String)
1331], FramingContainerOutletDirective.prototype, "framingContainerOutlet", void 0);
1332__decorate$5([
1333 Input(),
1334 __metadata$3("design:type", Boolean)
1335], FramingContainerOutletDirective.prototype, "optionalContainer", void 0);
1336__decorate$5([
1337 Input(),
1338 __metadata$3("design:type", Boolean)
1339], FramingContainerOutletDirective.prototype, "useViewInjector", void 0);
1340__decorate$5([
1341 Input(),
1342 __metadata$3("design:type", Array)
1343], FramingContainerOutletDirective.prototype, "content", void 0);
1344__decorate$5([
1345 Output(),
1346 __metadata$3("design:type", EventEmitter)
1347], FramingContainerOutletDirective.prototype, "onComponents", void 0);
1348FramingContainerOutletDirective = __decorate$5([
1349 Directive({
1350 selector: '[framingContainerOutlet]',
1351 }),
1352 __metadata$3("design:paramtypes", [ViewContainerRef,
1353 FramingContainerOutletService,
1354 Router])
1355], FramingContainerOutletDirective);
1356var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1357 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1358 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1359 r = Reflect.decorate(decorators, target, key, desc);
1360 else
1361 for (var i = decorators.length - 1; i >= 0; i--)
1362 if (d = decorators[i])
1363 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1364 return c > 3 && r && Object.defineProperty(target, key, r), r;
1365};
1366var FramingContainerOutletModule = FramingContainerOutletModule_1 = (function () {
1367 function FramingContainerOutletModule() {
1368 }
1369 FramingContainerOutletModule.withEntryComponents = function () {
1370 var components = [];
1371 for (var _a = 0; _a < arguments.length; _a++) {
1372 components[_a] = arguments[_a];
1373 }
1374 return {
1375 ngModule: FramingContainerOutletModule_1,
1376 providers: [
1377 { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: components, multi: true },
1378 ],
1379 };
1380 };
1381 FramingContainerOutletModule.forRoot = function () {
1382 return {
1383 ngModule: FramingContainerOutletModule_1,
1384 providers: [FramingContainerOutletService],
1385 };
1386 };
1387 return FramingContainerOutletModule;
1388}());
1389FramingContainerOutletModule = FramingContainerOutletModule_1 = __decorate$7([
1390 NgModule({
1391 declarations: [FramingContainerOutletDirective],
1392 exports: [FramingContainerOutletDirective],
1393 })
1394], FramingContainerOutletModule);
1395var FramingContainerOutletModule_1;
1396var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1397 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1398 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1399 r = Reflect.decorate(decorators, target, key, desc);
1400 else
1401 for (var i = decorators.length - 1; i >= 0; i--)
1402 if (d = decorators[i])
1403 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1404 return c > 3 && r && Object.defineProperty(target, key, r), r;
1405};
1406var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) {
1407 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1408 return Reflect.metadata(k, v);
1409};
1410var FramingContainerOutletResolver = (function () {
1411 function FramingContainerOutletResolver(containers, injector) {
1412 this.containers = containers;
1413 this.injector = injector;
1414 }
1415 /**
1416 * Resolve hook.
1417 */
1418 FramingContainerOutletResolver.prototype.resolve = function (route, state) {
1419 // set the injector in each container
1420 for (var _a = 0, _b = this.containers; _a < _b.length; _a++) {
1421 var container = _b[_a];
1422 container.injector = this.injector;
1423 }
1424 return this.containers;
1425 };
1426 return FramingContainerOutletResolver;
1427}());
1428FramingContainerOutletResolver = __decorate$8([
1429 Injectable(),
1430 __metadata$5("design:paramtypes", [Array, Injector])
1431], FramingContainerOutletResolver);
1432var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1433 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1434 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1435 r = Reflect.decorate(decorators, target, key, desc);
1436 else
1437 for (var i = decorators.length - 1; i >= 0; i--)
1438 if (d = decorators[i])
1439 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1440 return c > 3 && r && Object.defineProperty(target, key, r), r;
1441};
1442/**
1443 * @experimental
1444 */
1445var FramingEmptyParentComponent = (function () {
1446 function FramingEmptyParentComponent() {
1447 }
1448 return FramingEmptyParentComponent;
1449}());
1450FramingEmptyParentComponent = __decorate$9([
1451 Component({
1452 selector: 'empty-parent-component',
1453 template: '<router-outlet></router-outlet>',
1454 })
1455], FramingEmptyParentComponent);
1456var __decorate$11 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1457 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1458 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1459 r = Reflect.decorate(decorators, target, key, desc);
1460 else
1461 for (var i = decorators.length - 1; i >= 0; i--)
1462 if (d = decorators[i])
1463 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1464 return c > 3 && r && Object.defineProperty(target, key, r), r;
1465};
1466var FramingRootComponent = (function () {
1467 function FramingRootComponent() {
1468 }
1469 return FramingRootComponent;
1470}());
1471FramingRootComponent = __decorate$11([
1472 Component({
1473 selector: 'app-root',
1474 template: '<router-outlet></router-outlet>',
1475 })
1476], FramingRootComponent);
1477var __decorate$10 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1478 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1479 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1480 r = Reflect.decorate(decorators, target, key, desc);
1481 else
1482 for (var i = decorators.length - 1; i >= 0; i--)
1483 if (d = decorators[i])
1484 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1485 return c > 3 && r && Object.defineProperty(target, key, r), r;
1486};
1487var FramingComponentsModule = (function () {
1488 function FramingComponentsModule() {
1489 }
1490 return FramingComponentsModule;
1491}());
1492FramingComponentsModule = __decorate$10([
1493 NgModule({
1494 imports: [
1495 RouterModule,
1496 ],
1497 declarations: [
1498 FramingEmptyParentComponent,
1499 FramingRootComponent,
1500 ],
1501 exports: [
1502 FramingEmptyParentComponent,
1503 FramingRootComponent,
1504 ],
1505 })
1506], FramingComponentsModule);
1507var FramerHelper = (function () {
1508 // ========================================
1509 // constructor
1510 // ========================================
1511 function FramerHelper() {
1512 this.framerHelperId = FramerHelper._nextId++;
1513 }
1514 Object.defineProperty(FramerHelper.prototype, "framerHelperIdent", {
1515 /**
1516 * A unique identifier string for this framer helper instance.
1517 */
1518 get: function () {
1519 return camelCase("framerHelper-" + this.__proto__.constructor.name + "-" + this.framerHelperId);
1520 },
1521 enumerable: true,
1522 configurable: true
1523 });
1524 return FramerHelper;
1525}());
1526FramerHelper._nextId = 1;
1527/**
1528 *
1529 */
1530var FramingNgModule = (function () {
1531 function FramingNgModule() {
1532 // ========================================
1533 // private properties
1534 // ========================================
1535 this._ngModule = {
1536 imports: [],
1537 declarations: [],
1538 exports: [],
1539 providers: [],
1540 bootstrap: [],
1541 entryComponents: [],
1542 };
1543 this._root = false;
1544 this._routes = [];
1545 }
1546 Object.defineProperty(FramingNgModule, "defaultPathMatch", {
1547 get: function () { return 'prefix'; },
1548 enumerable: true,
1549 configurable: true
1550 });
1551 // ========================================
1552 // public methods
1553 // ========================================
1554 FramingNgModule.prototype.ngModule = function (ngModule) {
1555 var _this = this;
1556 if (ngModule) {
1557 defaults(this._ngModule, ngModule);
1558 each(filter(keys(ngModule), function (key) { return isArray(ngModule[key]); }), function (key) {
1559 _this._ngModule[key] = uniqWith(_this._ngModule[key].concat(reject(ngModule[key], isNil)), isEqual);
1560 });
1561 }
1562 return this;
1563 };
1564 FramingNgModule.prototype.bootstrap = function (bootstrap) {
1565 var flattened = [].concat.apply([], bootstrap);
1566 this._ngModule.bootstrap = uniqWith(this._ngModule.bootstrap.concat(reject(flattened, isNil)), isEqual);
1567 return this;
1568 };
1569 FramingNgModule.prototype.child = function (child, parent) {
1570 var parentRoute = this.getOrAddRouteOverload(parent);
1571 if (!parentRoute.children) {
1572 parentRoute.children = [];
1573 }
1574 if (!parentRoute.component) {
1575 parentRoute.component = FramingEmptyParentComponent;
1576 }
1577 this.getOrAddRoute(child, parentRoute.children);
1578 return this;
1579 };
1580 FramingNgModule.prototype.children = function (children, parent) {
1581 var _this = this;
1582 each(children, function (child) {
1583 _this.child(child, parent);
1584 });
1585 return this;
1586 };
1587 FramingNgModule.prototype.component = function (component, route) {
1588 if (component) {
1589 var routeConfig = this.getOrAddRouteOverload(route);
1590 routeConfig.component = component;
1591 }
1592 return this;
1593 };
1594 FramingNgModule.prototype.componentAndDeclare = function (component, route) {
1595 return this.componentAndDeclaration(component, route);
1596 };
1597 FramingNgModule.prototype.componentAndDeclaration = function (component, route) {
1598 this.component(component, route);
1599 if (component) {
1600 this.declare(component);
1601 }
1602 return this;
1603 };
1604 FramingNgModule.prototype.container = function (container, components, route) {
1605 var containers = {};
1606 containers[container] = components;
1607 this.containers(containers, route);
1608 return this;
1609 };
1610 FramingNgModule.prototype.containers = function (containers, route) {
1611 for (var key in containers) {
1612 if (containers.hasOwnProperty(key)) {
1613 if (isNil(containers[key])) {
1614 delete containers[key];
1615 }
1616 }
1617 }
1618 var routeConfig = this.getOrAddRoute(route);
1619 if (!routeConfig.resolve) {
1620 routeConfig.resolve = {};
1621 }
1622 if (!routeConfig.resolve.containers) {
1623 routeConfig.resolve.containers = [];
1624 }
1625 for (var key in containers) {
1626 if (containers.hasOwnProperty(key)) {
1627 var components = containers[key];
1628 if (isArray(components)) {
1629 for (var _a = 0, components_1 = components; _a < components_1.length; _a++) {
1630 var component = components_1[_a];
1631 routeConfig.resolve.containers.push({ container: key, component: component });
1632 }
1633 }
1634 else {
1635 routeConfig.resolve.containers.push({ container: key, component: components });
1636 }
1637 }
1638 }
1639 return this;
1640 };
1641 FramingNgModule.prototype.datum = function (key, datum, route) {
1642 var data = {};
1643 data[key] = datum;
1644 this.data(data, route);
1645 return this;
1646 };
1647 FramingNgModule.prototype.data = function (data, route) {
1648 var routeConfig = this.getOrAddRouteOverload(route);
1649 if (!routeConfig.data) {
1650 routeConfig.data = {};
1651 }
1652 merge(routeConfig.data, data);
1653 return this;
1654 };
1655 FramingNgModule.prototype.resolve = function (key, resolve, route) {
1656 var resolves = {};
1657 resolves[key] = resolve;
1658 this.resolves(resolves, route);
1659 return this;
1660 };
1661 FramingNgModule.prototype.resolves = function (resolves, route) {
1662 var routeConfig = this.getOrAddRouteOverload(route);
1663 if (!routeConfig.resolve) {
1664 routeConfig.resolve = {};
1665 }
1666 merge(routeConfig.resolve, resolves);
1667 return this;
1668 };
1669 FramingNgModule.prototype.declare = function (declaration) {
1670 return this.declaration(declaration);
1671 };
1672 FramingNgModule.prototype.declaration = function (declaration) {
1673 return this.declarations(isArray(declaration) ? declaration : [declaration]);
1674 };
1675 FramingNgModule.prototype.declarations = function (declarations) {
1676 var flattened = [].concat.apply([], declarations);
1677 this._ngModule.declarations = uniqWith(this._ngModule.declarations.concat(reject(flattened, isNil)), isEqual);
1678 return this;
1679 };
1680 FramingNgModule.prototype.declareAndExport = function (declaration) {
1681 return this.declarationAndExport(declaration);
1682 };
1683 FramingNgModule.prototype.declarationAndExport = function (declaration) {
1684 return this.declarationsAndExports(isArray(declaration) ? declaration : [declaration]);
1685 };
1686 FramingNgModule.prototype.declarationsAndExports = function (declarations) {
1687 this.declarations(declarations);
1688 this.exports(declarations);
1689 return this;
1690 };
1691 FramingNgModule.prototype.declareAndEntryComponent = function (declaration) {
1692 return this.declarationAndEntryComponent(declaration);
1693 };
1694 FramingNgModule.prototype.declarationAndEntryComponent = function (declaration) {
1695 return this.declarationsAndEntryComponents(isArray(declaration) ? declaration : [declaration]);
1696 };
1697 FramingNgModule.prototype.declarationsAndEntryComponents = function (declarations) {
1698 this.declarations(declarations);
1699 this.entryComponents(declarations);
1700 return this;
1701 };
1702 FramingNgModule.prototype.entryComponent = function (entryComponent) {
1703 return this.entryComponents(isArray(entryComponent) ? entryComponent : [entryComponent]);
1704 };
1705 FramingNgModule.prototype.entryComponents = function (entryComponents) {
1706 var flattened = [].concat.apply([], entryComponents);
1707 this._ngModule.entryComponents = uniqWith(this._ngModule.entryComponents.concat(reject(flattened, isNil)), isEqual);
1708 return this;
1709 };
1710 FramingNgModule.prototype.export = function (e) {
1711 return this.exports(isArray(e) ? e : [e]);
1712 };
1713 FramingNgModule.prototype.exports = function (exports) {
1714 var flattened = [].concat.apply([], exports);
1715 this._ngModule.exports = uniqWith(this._ngModule.exports.concat(reject(flattened, isNil)), isEqual);
1716 return this;
1717 };
1718 FramingNgModule.prototype.import = function (i) {
1719 return this.imports(isArray(i) ? i : [i]);
1720 };
1721 FramingNgModule.prototype.imports = function (imports) {
1722 var flattened = [].concat.apply([], imports);
1723 this._ngModule.imports = uniqWith(this._ngModule.imports.concat(reject(flattened, isNil)), isEqual);
1724 return this;
1725 };
1726 FramingNgModule.prototype.importAndExport = function (m) {
1727 return this.importsAndExports(isArray(m) ? m : [m]);
1728 };
1729 FramingNgModule.prototype.importsAndExports = function (modules) {
1730 this.imports(modules);
1731 this.exports(modules);
1732 return this;
1733 };
1734 FramingNgModule.prototype.provide = function (provider) {
1735 return this.provider(provider);
1736 };
1737 FramingNgModule.prototype.provider = function (provider) {
1738 return this.providers(isArray(provider) ? provider : [provider]);
1739 };
1740 FramingNgModule.prototype.providers = function (providers) {
1741 var flattened = [].concat.apply([], providers);
1742 this._ngModule.providers = uniqWith(this._ngModule.providers.concat(reject(flattened, isNil)), isEqual);
1743 return this;
1744 };
1745 /**
1746 * Adds component to bootstrap
1747 * Defaults route to path '', pathMatch: 'full'
1748 */
1749 FramingNgModule.prototype.root = function (rootComponent, config) {
1750 this._root = true;
1751 this._rootComponentConfig = config || {};
1752 defaults(this._rootComponentConfig, { hybrid: false });
1753 this._rootComponent = rootComponent || FramingRootComponent;
1754 return this;
1755 };
1756 /**
1757 * Creates Routes array with single route
1758 * Adds RouterModule.forRoot(routes) or RouterModule.forChild(routes) to imports
1759 * Adds all resolve services as providers
1760 */
1761 FramingNgModule.prototype.route = function (route, config) {
1762 this.getOrAddRoute(route);
1763 if (this._routeConfig) {
1764 if (config) {
1765 merge(this._routeConfig, config);
1766 }
1767 }
1768 else {
1769 this._routeConfig = config || {};
1770 defaults(this._routeConfig, { forRoot: false });
1771 }
1772 return this;
1773 };
1774 FramingNgModule.prototype.routes = function (routes, config) {
1775 var _this = this;
1776 each(routes, function (route) {
1777 _this.route(route, config);
1778 });
1779 return this;
1780 };
1781 FramingNgModule.prototype.frameRoute = function (route) {
1782 var framers = [];
1783 for (var _a = 1; _a < arguments.length; _a++) {
1784 framers[_a - 1] = arguments[_a];
1785 }
1786 this.buildFramers(framers, this.getOrAddRouteOverload(route));
1787 return this;
1788 };
1789 /**
1790 * Returns the route if it exists.
1791 */
1792 FramingNgModule.prototype.getRoute = function (route, array) {
1793 if (route === void 0) { route = {}; }
1794 /* tslint:disable:no-param-reassign */
1795 if (!array) {
1796 array = this._routes;
1797 }
1798 /* tslint:enable:no-param-reassign */
1799 defaults(route, { path: '', pathMatch: FramingNgModule.defaultPathMatch });
1800 return find(array, function (m) { return m.path === route.path && m.pathMatch === route.pathMatch; });
1801 };
1802 /**
1803 * Returns the route. Creates it if it does not exist.
1804 */
1805 FramingNgModule.prototype.getOrAddRoute = function (route, array) {
1806 if (route === void 0) { route = {}; }
1807 /* tslint:disable:no-param-reassign */
1808 if (!array) {
1809 array = this._routes;
1810 }
1811 /* tslint:enable:no-param-reassign */
1812 defaults(route, { path: '', pathMatch: FramingNgModule.defaultPathMatch });
1813 var r = find(array, function (m) { return m.path === route.path && m.pathMatch === route.pathMatch; });
1814 if (r) {
1815 merge(r, route);
1816 return r;
1817 }
1818 else {
1819 array.push(route);
1820 return route;
1821 }
1822 };
1823 /**
1824 * Run framers.
1825 */
1826 FramingNgModule.prototype.frame = function () {
1827 var framers = [];
1828 for (var _a = 0; _a < arguments.length; _a++) {
1829 framers[_a] = arguments[_a];
1830 }
1831 this.buildFramers(framers);
1832 return this;
1833 };
1834 FramingNgModule.prototype.use = function () {
1835 var framers = [];
1836 for (var _a = 0; _a < arguments.length; _a++) {
1837 framers[_a] = arguments[_a];
1838 }
1839 return this.frame.apply(this, framers);
1840 };
1841 /**
1842 * Builds @NgModule() config in the following order:
1843 * - Route framers
1844 * - Root
1845 * - Route
1846 */
1847 FramingNgModule.prototype.build = function () {
1848 this.buildRouteFramers(this._routes);
1849 this.buildRoot();
1850 this.buildContainers(this._routes);
1851 this.buildRoute();
1852 this.inspectModule();
1853 return this._ngModule;
1854 };
1855 // ========================================
1856 // private methods
1857 // ========================================
1858 FramingNgModule.prototype.inspectModule = function () {
1859 var _this = this;
1860 this._routes.forEach(function (r) { return _this.inspectRoute(r); });
1861 };
1862 FramingNgModule.prototype.inspectRoute = function (route) {
1863 var _this = this;
1864 if (route.component === undefined && route.redirectTo === undefined && isEmpty(route.children) && route.loadChildren === undefined) {
1865 console.error("Looks like you have a badly configured route in a framed module.\n One of the following must be provided: component, redirectTo, children or loadChildren", { route: route, self: this });
1866 }
1867 if (route.children) {
1868 route.children.forEach(function (c) { return _this.inspectRoute(c); });
1869 }
1870 };
1871 FramingNgModule.prototype.buildRoot = function () {
1872 var m = this._ngModule;
1873 if (this._root) {
1874 m.imports = uniqWith(m.imports.concat([
1875 BrowserModule.withServerTransition({
1876 appId: 'app',
1877 }),
1878 FormsModule,
1879 ]), isEqual);
1880 m.bootstrap = uniqWith(m.bootstrap.concat([this._rootComponent]), isEqual);
1881 }
1882 else {
1883 m.imports = uniqWith(m.imports.concat([
1884 CommonModule,
1885 ]), isEqual);
1886 }
1887 m.imports = uniqWith(m.imports.concat([FramingComponentsModule]), isEqual);
1888 };
1889 FramingNgModule.prototype.buildFramers = function (framers, route) {
1890 for (var _a = 0, framers_1 = framers; _a < framers_1.length; _a++) {
1891 var framer = framers_1[_a];
1892 this.buildFramer(framer, route);
1893 }
1894 };
1895 FramingNgModule.prototype.buildFramer = function (framer, route) {
1896 if (!framer.framed) {
1897 framer.runFraming(this, route || this.getRoute());
1898 }
1899 };
1900 /**
1901 * Builds framers that were manually added to route data.
1902 */
1903 FramingNgModule.prototype.buildRouteFramers = function (routes) {
1904 for (var _a = 0, routes_1 = routes; _a < routes_1.length; _a++) {
1905 var route = routes_1[_a];
1906 if (route.data) {
1907 for (var key in route.data) {
1908 if (route.data.hasOwnProperty(key)) {
1909 var prop = route.data[key];
1910 if (prop && prop._frame !== undefined) {
1911 // this is a framer attached to route data
1912 this.buildFramer(prop, route);
1913 }
1914 }
1915 }
1916 }
1917 if (route.children) {
1918 this.buildRouteFramers(route.children);
1919 }
1920 }
1921 };
1922 FramingNgModule.prototype.buildContainers = function (routes) {
1923 var _loop_2 = function (route) {
1924 if (route.resolve && route.resolve.containers) {
1925 var containers_2 = route.resolve.containers;
1926 for (var _a = 0, containers_3 = containers_2; _a < containers_3.length; _a++) {
1927 var container = containers_3[_a];
1928 var containerId = FramingNgModule._nextId++;
1929 container.id = '' + containerId;
1930 }
1931 var resolveId = FramingNgModule._nextId++;
1932 this_2.provide({
1933 provide: 'containerResolver' + resolveId,
1934 useFactory: function (i) { return new FramingContainerOutletResolver(containers_2, i); },
1935 deps: [Injector],
1936 });
1937 route.resolve.containers = 'containerResolver' + resolveId;
1938 }
1939 if (route.children) {
1940 this_2.buildContainers(route.children);
1941 }
1942 };
1943 var this_2 = this;
1944 for (var _a = 0, routes_2 = routes; _a < routes_2.length; _a++) {
1945 var route = routes_2[_a];
1946 _loop_2(route);
1947 }
1948 };
1949 FramingNgModule.prototype.buildRoute = function () {
1950 var _this = this;
1951 if (this._routes.length > 0) {
1952 // re-order routes so that full routes are first
1953 var fullRoutes_1 = [];
1954 var prefixRoutes_1 = [];
1955 this._routes.forEach(function (route) {
1956 if (route.pathMatch && route.pathMatch === 'full') {
1957 fullRoutes_1.push(route);
1958 }
1959 else if (!route.pathMatch || route.pathMatch === 'prefix') {
1960 prefixRoutes_1.push(route);
1961 }
1962 else {
1963 console.warn('Unknown pathMatch on route', route);
1964 }
1965 _this._routes = [];
1966 _this._routes = _this._routes.concat(fullRoutes_1);
1967 _this._routes = _this._routes.concat(prefixRoutes_1);
1968 });
1969 var routing = this._root || (this._routeConfig && this._routeConfig.forRoot) ?
1970 RouterModule.forRoot(this._routes, this._routeConfig ? this._routeConfig.extraRootRouterOptions : undefined) :
1971 RouterModule.forChild(this._routes);
1972 this.imports([routing]);
1973 if (this._routeConfig && this._routeConfig.forRoot && !this._root) {
1974 this.exports([RouterModule]); // export RouterModule from AppRoutingModule
1975 }
1976 }
1977 };
1978 FramingNgModule.prototype.getOrAddRouteOverload = function (route) {
1979 if (isArray(route)) {
1980 if (route.length) {
1981 var result = void 0;
1982 /* tslint:disable:prefer-for-of */
1983 result = this.getOrAddRoute(route[0]);
1984 for (var i = 1; i < route.length; i++) {
1985 if (!result.children) {
1986 result.children = [];
1987 }
1988 result = this.getOrAddRoute(route[i], result.children);
1989 }
1990 /* tslint:enable:prefer-for-of */
1991 return result;
1992 }
1993 else {
1994 return this.getOrAddRoute();
1995 }
1996 }
1997 else {
1998 return this.getOrAddRoute(route);
1999 }
2000 };
2001 return FramingNgModule;
2002}());
2003FramingNgModule._nextId = 1;
2004/* tslint:disable:variable-name */
2005var Framing = function (ngModuleBuilder) {
2006 /* tslint:enable:variable-name */
2007 var framing = ngModuleBuilder(new FramingNgModule());
2008 if (!framing) {
2009 console.error('Framing must return a FramingNgModule');
2010 return {};
2011 }
2012 return framing.build();
2013};
2014/**
2015 * A framer with no route, model, view, controller or frame.
2016 * To be used for leveraging the frame() function only.
2017 */
2018var SimpleFramer = (function (_super) {
2019 __extends(SimpleFramer, _super);
2020 function SimpleFramer() {
2021 return _super !== null && _super.apply(this, arguments) || this;
2022 }
2023 Object.defineProperty(SimpleFramer.prototype, "framerName", {
2024 get: function () { return 'Simple'; },
2025 enumerable: true,
2026 configurable: true
2027 });
2028 Object.defineProperty(SimpleFramer.prototype, "createFrame", {
2029 get: function () { return false; },
2030 enumerable: true,
2031 configurable: true
2032 });
2033 Object.defineProperty(SimpleFramer.prototype, "routeRule", {
2034 get: function () { return 'none'; },
2035 enumerable: true,
2036 configurable: true
2037 });
2038 return SimpleFramer;
2039}(Framer));
2040export { FramingDevToolsComponent, FramingDevToolsController, FramingDevToolsFeature, Action, _createReduxDevtoolsExtension, FramingComponentOutletDirective, FramingComponentOutletModule, FramingContainerOutletDirective, FramingContainerOutletModule, FramingContainerOutletResolver, FramingContainerOutletService, FramingEmptyParentComponent, FramingComponentsModule, FramingRootComponent, Component$1 as Component, Controller, FramingTools, Frame, FramerHelper, Framer, FramingNgModule, Framing, SimpleFramer };
2041//# sourceMappingURL=ng-core.es5.js.map