UNPKG

43.2 kBJavaScriptView Raw
1/**
2 * @license Framing v0.8.5
3 * Copyright 2016-2017 Biznas Innovations, Inc. http://biznas.io
4 * License: Apache License, Version 2.0
5 */
6!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/router"),require("rxjs/Rx"),require("lodash"),require("rxjs/BehaviorSubject"),require("rxjs"),require("@angular/common"),require("@angular/forms"),require("@angular/platform-browser")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","rxjs/Rx","lodash","rxjs/BehaviorSubject","rxjs","@angular/common","@angular/forms","@angular/platform-browser"],factory):factory((global.ng=global.ng||{},global.ng.core=global.ng.core||{}),global._angular_core,global._angular_router,global.rxjs_Rx,global.lodash,global.rxjs_BehaviorSubject,global.rxjs,global._angular_common,global._angular_forms,global._angular_platformBrowser)}(this,function(exports,_angular_core,_angular_router,rxjs_Rx,lodash,rxjs_BehaviorSubject,rxjs,_angular_common,_angular_forms,_angular_platformBrowser){"use strict";var __extends=void 0||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}(),__decorate=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},__metadata=void 0||function(k,v){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(k,v):void 0};exports.FramingComponentOutletDirective=function(){function FramingComponentOutletDirective(_view){this._view=_view,this.onComponent=new _angular_core.EventEmitter}return FramingComponentOutletDirective.prototype.isActivated=function(){return!!this._componentRef},FramingComponentOutletDirective.prototype.ngOnChanges=function(changes){var activate=!1;if(changes.ngModuleFactory){if(this._moduleRef&&this._moduleRef.destroy(),this.ngModuleFactory){var injector=this.injector||this._view.parentInjector;this._moduleRef=this.ngModuleFactory.create(injector)}else this._moduleRef=void 0;activate=!0}changes.framingComponentOutlet.currentValue!==changes.framingComponentOutlet.previousValue&&(activate=!0),activate&&this.activate(this.framingComponentOutlet)},FramingComponentOutletDirective.prototype.ngOnDestroy=function(){this.deactivate(),this._moduleRef&&this._moduleRef.destroy()},FramingComponentOutletDirective.prototype.activate=function(component){if(this.deactivate(),component)try{var injector=this.injector||this._view.parentInjector,factory=injector.get(_angular_core.ComponentFactoryResolver).resolveComponentFactory(component);this._componentRef=this._view.createComponent(factory,this._view.length,injector,this.content),this.onComponent.emit(this._componentRef);try{this._componentRef.changeDetectorRef.detectChanges()}catch(e){return void console.error("detectChanges failed on activated component in FramingComponentOutlet",{e:e,component:component})}}catch(e){return void console.error("Failed to activate component in FramingComponentOutlet",{e:e,component:component})}},FramingComponentOutletDirective.prototype.deactivate=function(){this._componentRef&&(this._view.remove(this._view.indexOf(this._componentRef.hostView)),this._componentRef.destroy()),this._view.clear(),this._componentRef=void 0},FramingComponentOutletDirective}(),__decorate([_angular_core.Input(),__metadata("design:type",_angular_core.Type)],exports.FramingComponentOutletDirective.prototype,"framingComponentOutlet",void 0),__decorate([_angular_core.Input(),__metadata("design:type",_angular_core.Injector)],exports.FramingComponentOutletDirective.prototype,"injector",void 0),__decorate([_angular_core.Input(),__metadata("design:type",Array)],exports.FramingComponentOutletDirective.prototype,"content",void 0),__decorate([_angular_core.Input(),__metadata("design:type",_angular_core.NgModuleFactory)],exports.FramingComponentOutletDirective.prototype,"ngModuleFactory",void 0),__decorate([_angular_core.Output(),__metadata("design:type",_angular_core.EventEmitter)],exports.FramingComponentOutletDirective.prototype,"onComponent",void 0),exports.FramingComponentOutletDirective=__decorate([_angular_core.Directive({selector:"[framingComponentOutlet]"}),__metadata("design:paramtypes",[_angular_core.ViewContainerRef])],exports.FramingComponentOutletDirective);var __decorate$1=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.FramingComponentOutletModule=FramingComponentOutletModule_1=function(){function FramingComponentOutletModule(){}return FramingComponentOutletModule.withEntryComponents=function(){for(var components=[],_i=0;_i<arguments.length;_i++)components[_i]=arguments[_i];return{ngModule:FramingComponentOutletModule_1,providers:[{provide:_angular_core.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:components,multi:!0}]}},FramingComponentOutletModule}(),exports.FramingComponentOutletModule=FramingComponentOutletModule_1=__decorate$1([_angular_core.NgModule({declarations:[exports.FramingComponentOutletDirective],exports:[exports.FramingComponentOutletDirective]})],exports.FramingComponentOutletModule);var FramingComponentOutletModule_1,__decorate$3=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},__metadata$2=void 0||function(k,v){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(k,v):void 0};exports.FramingContainerOutletService=function(){function FramingContainerOutletService(router){var _this=this;this.router=router,this.contentsSubject=new rxjs_Rx.ReplaySubject,this.contents=[],this.routeContents=[],this.subscriptions=[],this.subscriptions.push(this.router.events.subscribe(function(event){event instanceof _angular_router.NavigationEnd&&_this.onNavigationEnd()}))}return Object.defineProperty(FramingContainerOutletService.prototype,"contents$",{get:function(){return this.contentsSubject.asObservable()},enumerable:!0,configurable:!0}),FramingContainerOutletService.prototype.hasContent=function(container){return!!this.contents.filter(function(c){return lodash.isEqual(c.container,container)}).length},FramingContainerOutletService.prototype.activate=function(content){var _this=this;return this.contents.push(content),this.contentsSubject.next(lodash.clone(this.contents)),function(){_this.deactivate(content)}},FramingContainerOutletService.prototype.deactivate=function(content){this.contents=this.contents.filter(function(e){return e!==content}),this.contentsSubject.next(lodash.clone(this.contents))},FramingContainerOutletService.prototype.onNavigationEnd=function(){var _this=this,newRouteContents=[];this.resolveRouteContents(this.router.routerState.snapshot.root,newRouteContents),newRouteContents=lodash.uniqWith(newRouteContents,lodash.isEqual);var newContents=lodash.differenceWith(newRouteContents,this.routeContents,lodash.isEqual),removedContents=lodash.differenceWith(this.routeContents,newRouteContents,lodash.isEqual);newContents.forEach(function(c){return _this.activate(c)}),removedContents.forEach(function(c){return _this.deactivate(c)}),this.routeContents=newRouteContents},FramingContainerOutletService.prototype.resolveRouteContents=function(snapshot,routeContents){if(snapshot.data&&snapshot.data.containers)for(var containers=snapshot.data.containers,_i=0,containers_1=containers;_i<containers_1.length;_i++){var container=containers_1[_i];routeContents.push(container)}for(var _a=0,_b=snapshot.children;_a<_b.length;_a++){var child=_b[_a];this.resolveRouteContents(child,routeContents)}},FramingContainerOutletService}(),exports.FramingContainerOutletService=__decorate$3([_angular_core.Injectable(),__metadata$2("design:paramtypes",[_angular_router.Router])],exports.FramingContainerOutletService);var __decorate$2=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},__metadata$1=void 0||function(k,v){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(k,v):void 0};exports.FramingContainerOutletDirective=function(){function FramingContainerOutletDirective(_view,_containerService,_router){this._view=_view,this._containerService=_containerService,this._router=_router,this.onComponents=new _angular_core.EventEmitter,this._activated=[],this._subscriptions=[]}return FramingContainerOutletDirective.prototype.containerName=function(){return this.framingContainerOutlet},FramingContainerOutletDirective.prototype.isActivated=function(){return this._activated.length>0},FramingContainerOutletDirective.prototype.ngOnInit=function(){var _this=this;this.framingContainerOutlet?("'"===this.framingContainerOutlet[0]&&console.warn('FramingContainerOutlet name "'+this.framingContainerOutlet+'" starts with a qoute'),this._subscriptions.push(this._containerService.contents$.subscribe(function(contents){return _this.onContent(contents)}))):console.warn("FramingContainerOutlet without a container name"),this._subscriptions.push(this._router.events.subscribe(function(event){event instanceof _angular_router.NavigationEnd&&(_this.optionalContainer||_this.isActivated()||console.warn("No content for required FramingContainerOutlet '"+_this.framingContainerOutlet+"' found"))}))},FramingContainerOutletDirective.prototype.ngOnDestroy=function(){var _this=this;this._activated.forEach(function(a){return _this.deactivate(a)}),this._subscriptions.forEach(function(s){return s.unsubscribe()})},FramingContainerOutletDirective.prototype.onContent=function(allContents){var _this=this,contents=allContents.filter(function(c){return lodash.isEqual(c.container,_this.framingContainerOutlet)});this._activated.forEach(function(a){-1===contents.findIndex(function(content){return content===a.content})&&_this.deactivate(a)}),this._activated=this._activated.filter(function(a){return!!a.ref});for(var i=0,_loop_1=function(content){if(this_1._activated.length>i){if(this_1._activated[i].content!==content){var activatedIndex=this_1._activated.findIndex(function(a){return a.content===content});if(-1===activatedIndex)this_1._activated.splice(i,0,{content:content,ref:this_1.activate(content)});else if(activatedIndex>i){var _activated=this_1._activated.splice(activatedIndex,1);(_a=this_1._activated).splice.apply(_a,[i,0].concat(_activated));var view=this_1._view.detach(activatedIndex);this_1._view.insert(view,i)}else console.error("Logic error in FramingContainerOutlet!")}}else{var ref=this_1.activate(content);ref&&this_1._activated.push({content:content,ref:ref})}i++;var _a},this_1=this,_i=0,contents_1=contents;_i<contents_1.length;_i++){var content=contents_1[_i];_loop_1(content)}this.onComponents.emit(this._activated.map(function(a){return a.ref}))},FramingContainerOutletDirective.prototype.activate=function(content,i){try{var injector=!this.useViewInjector&&content.injector?content.injector:this._view.parentInjector,factory=injector.get(_angular_core.ComponentFactoryResolver).resolveComponentFactory(content.component),ref=this._view.createComponent(factory,i,injector,this.content);try{ref.changeDetectorRef.detectChanges()}catch(e){console.error("detectChanges failed on activated component in FramingContainerOutlet '"+this.framingContainerOutlet+"'",{e:e,component:content.component})}return ref}catch(e){return void console.error("Failed to activate component in FramingContainerOutlet '"+this.framingContainerOutlet+"'",{e:e,component:content.component})}},FramingContainerOutletDirective.prototype.deactivate=function(activated){activated.ref.destroy(),activated.ref=null},FramingContainerOutletDirective}(),__decorate$2([_angular_core.Input(),__metadata$1("design:type",String)],exports.FramingContainerOutletDirective.prototype,"framingContainerOutlet",void 0),__decorate$2([_angular_core.Input(),__metadata$1("design:type",Boolean)],exports.FramingContainerOutletDirective.prototype,"optionalContainer",void 0),__decorate$2([_angular_core.Input(),__metadata$1("design:type",Boolean)],exports.FramingContainerOutletDirective.prototype,"useViewInjector",void 0),__decorate$2([_angular_core.Input(),__metadata$1("design:type",Array)],exports.FramingContainerOutletDirective.prototype,"content",void 0),__decorate$2([_angular_core.Output(),__metadata$1("design:type",_angular_core.EventEmitter)],exports.FramingContainerOutletDirective.prototype,"onComponents",void 0),exports.FramingContainerOutletDirective=__decorate$2([_angular_core.Directive({selector:"[framingContainerOutlet]"}),__metadata$1("design:paramtypes",[_angular_core.ViewContainerRef,exports.FramingContainerOutletService,_angular_router.Router])],exports.FramingContainerOutletDirective);var __decorate$4=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.FramingContainerOutletModule=FramingContainerOutletModule_1=function(){function FramingContainerOutletModule(){}return FramingContainerOutletModule.withEntryComponents=function(){for(var components=[],_i=0;_i<arguments.length;_i++)components[_i]=arguments[_i];return{ngModule:FramingContainerOutletModule_1,providers:[{provide:_angular_core.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:components,multi:!0}]}},FramingContainerOutletModule.forRoot=function(){return{ngModule:FramingContainerOutletModule_1,providers:[exports.FramingContainerOutletService]}},FramingContainerOutletModule}(),exports.FramingContainerOutletModule=FramingContainerOutletModule_1=__decorate$4([_angular_core.NgModule({declarations:[exports.FramingContainerOutletDirective],exports:[exports.FramingContainerOutletDirective]})],exports.FramingContainerOutletModule);var FramingContainerOutletModule_1,__decorate$5=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},__metadata$3=void 0||function(k,v){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(k,v):void 0};exports.FramingContainerOutletResolver=function(){function FramingContainerOutletResolver(containers,injector){this.containers=containers,this.injector=injector}return FramingContainerOutletResolver.prototype.resolve=function(){for(var _i=0,_a=this.containers;_i<_a.length;_i++){var container=_a[_i];container.injector=this.injector}return this.containers},FramingContainerOutletResolver}(),exports.FramingContainerOutletResolver=__decorate$5([_angular_core.Injectable(),__metadata$3("design:paramtypes",[Array,_angular_core.Injector])],exports.FramingContainerOutletResolver);var __decorate$6=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.FramingEmptyParentComponent=function(){function FramingEmptyParentComponent(){}return FramingEmptyParentComponent}(),exports.FramingEmptyParentComponent=__decorate$6([_angular_core.Component({selector:"empty-parent-component",template:"<router-outlet></router-outlet>"})],exports.FramingEmptyParentComponent);var __decorate$7=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.FramingComponentsModule=function(){function FramingComponentsModule(){}return FramingComponentsModule}(),exports.FramingComponentsModule=__decorate$7([_angular_core.NgModule({imports:[_angular_router.RouterModule],declarations:[exports.FramingEmptyParentComponent],exports:[exports.FramingEmptyParentComponent]})],exports.FramingComponentsModule);var __decorate$8=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.FramingRootComponent=function(){function FramingRootComponent(){}return FramingRootComponent}(),exports.FramingRootComponent=__decorate$8([_angular_core.Component({selector:"app",template:"<router-outlet></router-outlet>"})],exports.FramingRootComponent);var Component$1=function(){function Component$1(controller,injector){var _this=this;this.changeDetectorRef=injector.get(_angular_core.ChangeDetectorRef),controller.model$.subscribe(function(model){_this.model=model,_this.changeDetectorRef.markForCheck()}),controller.view$.subscribe(function(view){_this.view=view,_this.changeDetectorRef.markForCheck()})}return Component$1}(),__decorate$9=void 0||function(decorators,target,key,desc){var d,c=arguments.length,r=3>c?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(3>c?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};exports.Controller=function(){function Controller(){}return Object.defineProperty(Controller.prototype,"model$",{get:function(){return this._model$},enumerable:!0,configurable:!0}),Object.defineProperty(Controller.prototype,"view$",{get:function(){return this._view$},enumerable:!0,configurable:!0}),Object.defineProperty(Controller.prototype,"model",{get:function(){return this._model},enumerable:!0,configurable:!0}),Object.defineProperty(Controller.prototype,"view",{get:function(){return this._view},enumerable:!0,configurable:!0}),Object.defineProperty(Controller.prototype,"frame",{get:function(){return this._frame},enumerable:!0,configurable:!0}),Object.defineProperty(Controller.prototype,"injector",{get:function(){return this._injector},enumerable:!0,configurable:!0}),Controller.prototype.onControllerInit=function(){},Controller.prototype.onResolveStart=function(){},Controller.prototype.onResolveEnd=function(){},Controller.prototype.onResolveCancel=function(){},Controller.prototype.initController=function(model,view,frame,injector){var _this=this;this._modelSubject=new rxjs_BehaviorSubject.BehaviorSubject(model),this._viewSubject=new rxjs_BehaviorSubject.BehaviorSubject(view),this._model$=this._modelSubject.asObservable(),this._view$=this._viewSubject.asObservable(),this._model=model,this._view=view,this._frame=frame,this._injector=injector,this._frame&&(this._frame.resolveStart$.subscribe(function(){_this.onResolveStart()}),this._frame.resolveEnd$.subscribe(function(){_this.onResolveEnd()}),this._frame.resolveCancel$.subscribe(function(){_this.onResolveCancel()})),this.onControllerInit()},Controller.prototype.updateModel=function(model,replace){void 0===replace&&(replace=!1),this._model=replace?model:lodash.assign({},this._model,model),this._modelSubject.next(this._model)},Controller.prototype.updateView=function(view,replace){void 0===replace&&(replace=!1),this._view=replace?view:lodash.assign({},this._view,view),this._view=view,this._viewSubject.next(this._view)},Controller}(),exports.Controller=__decorate$9([_angular_core.Injectable()],exports.Controller);var Frame=function(){function Frame(){this.routeUrlSubject=new rxjs.ReplaySubject,this.resolveStartSubject=new rxjs.Subject,this.resolveEndSubject=new rxjs.Subject,this.resolveCancelSubject=new rxjs.Subject}return Object.defineProperty(Frame.prototype,"routeUrl$",{get:function(){return this.routeUrlSubject},enumerable:!0,configurable:!0}),Object.defineProperty(Frame.prototype,"resolveStart$",{get:function(){return this.resolveStartSubject},enumerable:!0,configurable:!0}),Object.defineProperty(Frame.prototype,"resolveEnd$",{get:function(){return this.resolveEndSubject},enumerable:!0,configurable:!0}),Object.defineProperty(Frame.prototype,"resolveCancel$",{get:function(){return this.resolveCancelSubject},enumerable:!0,configurable:!0}),Frame}(),FramerHelper=function(){function FramerHelper(){this.framerHelperId=FramerHelper._nextId++}return Object.defineProperty(FramerHelper.prototype,"framerHelperIdent",{get:function(){return lodash.camelCase("framerHelper-"+this.__proto__.constructor.name+"-"+this.framerHelperId)},enumerable:!0,configurable:!0}),FramerHelper}();FramerHelper._nextId=1;var Framer=function(){function Framer(model,view,controller){this._framed=!1,this.construct(model,view,controller)}return Object.defineProperty(Framer.prototype,"theModel",{get:function(){return this._model},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"theView",{get:function(){return this._view},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"theController",{get:function(){return this._controller},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"createFrame",{get:function(){return!0},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"multiFramer",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"provideControllerByType",{get:function(){return!0},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"addModelToRouteData",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"addViewToRouteData",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"addFrameToRouteData",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"defaultModel",{get:function(){return void 0},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"defaultView",{get:function(){return void 0},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"defaultController",{get:function(){return void 0},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"routeRule",{get:function(){return"require"},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"framerId",{get:function(){return this._framerId},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"framerIdent",{get:function(){return this.framerName+"Framer-"+this._framerId},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"framed",{get:function(){return this._framed},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"injector",{get:function(){return this._injector},enumerable:!0,configurable:!0}),Object.defineProperty(Framer.prototype,"route",{get:function(){return this._route},enumerable:!0,configurable:!0}),Framer.buildUrlLink=function(route){if(!route)return"/";for(var urls=[];route.parent;route=route.parent)urls=urls.concat(route.url.reverse());return urls=urls.reverse(),"/"+urls.join("/")},Framer.prototype.model=function(model){return lodash.merge(this._model,model),this},Framer.prototype.view=function(view){return lodash.merge(this._view,view),this},Framer.prototype.controller=function(controller){return controller&&(this._controller=controller),this},Framer.prototype.framerOnResolveRoute=function(){},Framer.prototype.framerOnControllerInit=function(){},Framer.prototype.runFraming=function(framing,routeParam){var _this=this;if(this._framed)return void console.warn("runFraming() called multiple times on framer '"+this.framerIdent+"'");this._framed=!0,"auto"===this.routeRule?this._route=routeParam:"require"===this.routeRule&&(this._route=routeParam?routeParam:routeParam=framing.getOrAddRoute()),this._framing=framing;try{this.frame(framing)}catch(e){console.error("Exception when framing "+this.framerIdent+" :",e),this._model=void 0,this._view=void 0,this._controller=void 0}this._framing=void 0,"auto"===this.routeRule&&(this._route=routeParam);var self=this;if(this._controller&&this.provideControllerByType){var controllerInstance_1;framing.provide({provide:this.framerIdent+"-ControllerInternal",useClass:this._controller}).provide({provide:this.framerIdent+"-Controller",useFactory:function(injector){return controllerInstance_1?controllerInstance_1:(self._injector=injector,controllerInstance_1=injector.get(_this.framerIdent+"-ControllerInternal"),controllerInstance_1.initController(_this._model,_this._view,_this._frame,injector),_this.framerOnControllerInit(controllerInstance_1),controllerInstance_1)},deps:[_angular_core.Injector]}).provide({provide:this._controller,useExisting:this.framerIdent+"-Controller",multi:this.multiFramer&&this._controller===this.defaultController}),console.info("Providing controller for framer "+this.framerIdent+" by type"),this.defaultController&&this._controller!==this.defaultController&&(framing.provide({provide:this.defaultController,useExisting:this.framerIdent+"-Controller",multi:this.multiFramer}),console.info("Providing controller overload for framer "+this.framerIdent+" by default controller type"))}if(this.route&&(this.addFrameToRouteData&&this.addRouteData(framing,this.framerName+"Frame",this._frame),this.addModelToRouteData&&this.addRouteData(framing,this.framerName+"Model",this._model),this.addViewToRouteData&&this.addRouteData(framing,this.framerName+"View",this._view),this._frame)){var FrameResolver_1=function(){function FrameResolver_1(router,route,injector){this.router=router,this.route=route,self._injector=injector}return FrameResolver_1.prototype.resolve=function(routeSnapshot){var _this=this;self._frame.resolveStartSubject.next();var routeUrl=Framer.buildUrlLink(routeSnapshot),sub=this.router.events.subscribe(function(event){event instanceof _angular_router.NavigationStart?console.error("Unexpected NavigationStart"):event instanceof _angular_router.NavigationEnd?(console.info("Route url for framer "+self.framerIdent+" changed to "+routeUrl),self._frame.routeSnapshot=self.findActivateRouteSnapshot(_this.route),self._frame.routeUrl=routeUrl,self._frame.routeUrlSubject.next(routeUrl),self.framerOnResolveRoute(),self._frame.resolveEndSubject.next()):event instanceof _angular_router.NavigationError?self._frame.resolveCancelSubject.next():event instanceof _angular_router.NavigationCancel&&self._frame.resolveCancelSubject.next(),sub.unsubscribe()});return self._frame},FrameResolver_1}();framing.resolve(this.framerIdent,FrameResolver_1,this.route).provide({provide:FrameResolver_1,useFactory:function(r,a,i){return new FrameResolver_1(r,a,i)},deps:[_angular_router.Router,_angular_router.ActivatedRoute,_angular_core.Injector]})}this._route=void 0},Framer.prototype.construct=function(model,view,controller){this._framerId=Framer._nextId++,this.createFrame&&(this._frame=new Frame);var defaultModel=this.defaultModel;this._model=defaultModel?lodash.merge(defaultModel,model):model;var defaultView=this.defaultView;this._view=defaultView?lodash.merge(defaultView,view):view,this._controller=controller||this.defaultController},Framer.prototype.findActivateRouteSnapshot=function(route){return route?route.snapshot&&route.snapshot.data&&route.snapshot.data.hasOwnProperty(this.framerIdent)?route.snapshot:this.findActivateRouteSnapshot(route.firstChild):void console.error("Failed to find activated route snapshot")},Framer.prototype.addRouteData=function(framing,name,value){if(value){var routeConfig=framing.getOrAddRoute(this.route);routeConfig.data&&routeConfig.data[name]?console.warn("Failed to add "+name+" route data for framer "+this.framerIdent+". Data item already exists."):(framing.datum(name,value,this.route),console.info("Adding "+name+" route data for framer "+this.framerIdent))}},Framer}();Framer._nextId=1;var FramingNgModule=function(){function FramingNgModule(){this._ngModule={imports:[],declarations:[],exports:[],providers:[],bootstrap:[],entryComponents:[]},this._root=!1,this._routes=[]}return Object.defineProperty(FramingNgModule,"defaultPathMatch",{get:function(){return"prefix"},enumerable:!0,configurable:!0}),FramingNgModule.prototype.ngModule=function(ngModule){var _this=this;return ngModule&&(lodash.defaults(this._ngModule,ngModule),lodash.each(lodash.filter(lodash.keys(ngModule),function(key){return lodash.isArray(ngModule[key])}),function(key){_this._ngModule[key]=lodash.uniqWith(_this._ngModule[key].concat(lodash.reject(ngModule[key],lodash.isNil)),lodash.isEqual)})),this},FramingNgModule.prototype.child=function(child,parent){var parentRoute=this.getOrAddRouteOverload(parent);return parentRoute.children||(parentRoute.children=[]),parentRoute.component||(parentRoute.component=exports.FramingEmptyParentComponent),this.getOrAddRoute(child,parentRoute.children),this},FramingNgModule.prototype.children=function(children,parent){var _this=this;return lodash.each(children,function(child){_this.child(child,parent)}),this},FramingNgModule.prototype.component=function(component,route){if(component){var routeConfig=this.getOrAddRouteOverload(route);routeConfig.component=component}return this},FramingNgModule.prototype.componentAndDeclare=function(component,route){return this.componentAndDeclaration(component,route)},FramingNgModule.prototype.componentAndDeclaration=function(component,route){return this.component(component,route),component&&this.declare(component),this},FramingNgModule.prototype.container=function(container,components,route){var containers={};return containers[container]=components,this.containers(containers,route),this},FramingNgModule.prototype.containers=function(containers,route){for(var key in containers)containers.hasOwnProperty(key)&&lodash.isNil(containers[key])&&delete containers[key];var routeConfig=this.getOrAddRoute(route);routeConfig.resolve||(routeConfig.resolve={}),
7routeConfig.resolve.containers||(routeConfig.resolve.containers=[]);for(var key in containers)if(containers.hasOwnProperty(key)){var components=containers[key];if(lodash.isArray(components))for(var _i=0,components_1=components;_i<components_1.length;_i++){var component=components_1[_i];routeConfig.resolve.containers.push({container:key,component:component})}else routeConfig.resolve.containers.push({container:key,component:components})}return this},FramingNgModule.prototype.datum=function(key,datum,route){var data={};return data[key]=datum,this.data(data,route),this},FramingNgModule.prototype.data=function(data,route){var routeConfig=this.getOrAddRouteOverload(route);return routeConfig.data||(routeConfig.data={}),lodash.merge(routeConfig.data,data),this},FramingNgModule.prototype.resolve=function(key,resolve,route){var resolves={};return resolves[key]=resolve,this.resolves(resolves,route),this},FramingNgModule.prototype.resolves=function(resolves,route){var routeConfig=this.getOrAddRouteOverload(route);return routeConfig.resolve||(routeConfig.resolve={}),lodash.merge(routeConfig.resolve,resolves),this},FramingNgModule.prototype.declare=function(declaration){return this.declaration(declaration)},FramingNgModule.prototype.declaration=function(declaration){return this.declarations(lodash.isArray(declaration)?declaration:[declaration])},FramingNgModule.prototype.declarations=function(declarations){var flattened=[].concat.apply([],declarations);return this._ngModule.declarations=lodash.uniqWith(this._ngModule.declarations.concat(lodash.reject(flattened,lodash.isNil)),lodash.isEqual),this},FramingNgModule.prototype.declareAndExport=function(declaration){return this.declarationAndExport(declaration)},FramingNgModule.prototype.declarationAndExport=function(declaration){return this.declarationsAndExports(lodash.isArray(declaration)?declaration:[declaration])},FramingNgModule.prototype.declarationsAndExports=function(declarations){return this.declarations(declarations),this.exports(declarations),this},FramingNgModule.prototype.declareAndEntryComponent=function(declaration){return this.declarationAndEntryComponent(declaration)},FramingNgModule.prototype.declarationAndEntryComponent=function(declaration){return this.declarationsAndEntryComponents(lodash.isArray(declaration)?declaration:[declaration])},FramingNgModule.prototype.declarationsAndEntryComponents=function(declarations){return this.declarations(declarations),this.entryComponents(declarations),this},FramingNgModule.prototype.entryComponent=function(entryComponent){return this.entryComponents(lodash.isArray(entryComponent)?entryComponent:[entryComponent])},FramingNgModule.prototype.entryComponents=function(entryComponents){var flattened=[].concat.apply([],entryComponents);return this._ngModule.entryComponents=lodash.uniqWith(this._ngModule.entryComponents.concat(lodash.reject(flattened,lodash.isNil)),lodash.isEqual),this},FramingNgModule.prototype.export=function(e){return this.exports(lodash.isArray(e)?e:[e])},FramingNgModule.prototype.exports=function(exports){var flattened=[].concat.apply([],exports);return this._ngModule.exports=lodash.uniqWith(this._ngModule.exports.concat(lodash.reject(flattened,lodash.isNil)),lodash.isEqual),this},FramingNgModule.prototype.import=function(i){return this.imports(lodash.isArray(i)?i:[i])},FramingNgModule.prototype.imports=function(imports){var flattened=[].concat.apply([],imports);return this._ngModule.imports=lodash.uniqWith(this._ngModule.imports.concat(lodash.reject(flattened,lodash.isNil)),lodash.isEqual),this},FramingNgModule.prototype.importAndExport=function(m){return this.importsAndExports(lodash.isArray(m)?m:[m])},FramingNgModule.prototype.importsAndExports=function(modules){return this.imports(modules),this.exports(modules),this},FramingNgModule.prototype.provide=function(provider){return this.provider(provider)},FramingNgModule.prototype.provider=function(provider){return this.providers(lodash.isArray(provider)?provider:[provider])},FramingNgModule.prototype.providers=function(providers){var flattened=[].concat.apply([],providers);return this._ngModule.providers=lodash.uniqWith(this._ngModule.providers.concat(lodash.reject(flattened,lodash.isNil)),lodash.isEqual),this},FramingNgModule.prototype.root=function(rootComponent,config){return this._root=!0,this._rootComponentConfig=config||{},lodash.defaults(this._rootComponentConfig,{hybrid:!1}),this._rootComponent=rootComponent||exports.FramingRootComponent,this},FramingNgModule.prototype.route=function(route,config){return this.getOrAddRoute(route),this._routeConfig?config&&lodash.merge(this._routeConfig,config):(this._routeConfig=config||{},lodash.defaults(this._routeConfig,{forRoot:!1})),this},FramingNgModule.prototype.routes=function(routes,config){var _this=this;return lodash.each(routes,function(route){_this.route(route,config)}),this},FramingNgModule.prototype.frameRoute=function(route){for(var framers=[],_i=1;_i<arguments.length;_i++)framers[_i-1]=arguments[_i];return this.buildFramers(framers,this.getOrAddRouteOverload(route)),this},FramingNgModule.prototype.getRoute=function(route,array){return void 0===route&&(route={}),array||(array=this._routes),lodash.defaults(route,{path:"",pathMatch:FramingNgModule.defaultPathMatch}),lodash.find(array,function(m){return m.path===route.path&&m.pathMatch===route.pathMatch})},FramingNgModule.prototype.getOrAddRoute=function(route,array){void 0===route&&(route={}),array||(array=this._routes),lodash.defaults(route,{path:"",pathMatch:FramingNgModule.defaultPathMatch});var r=lodash.find(array,function(m){return m.path===route.path&&m.pathMatch===route.pathMatch});return r?(lodash.merge(r,route),r):(array.push(route),route)},FramingNgModule.prototype.frame=function(){for(var framers=[],_i=0;_i<arguments.length;_i++)framers[_i]=arguments[_i];return this.buildFramers(framers),this},FramingNgModule.prototype.build=function(){return this.buildRouteFramers(this._routes),this.buildRoot(),this.buildContainers(this._routes),this.buildRoute(),this.inspectModule(),this._ngModule},FramingNgModule.prototype.inspectModule=function(){var _this=this;this._routes.forEach(function(r){return _this.inspectRoute(r)})},FramingNgModule.prototype.inspectRoute=function(route){var _this=this;void 0===route.component&&void 0===route.redirectTo&&lodash.isEmpty(route.children)&&void 0===route.loadChildren&&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}),route.children&&route.children.forEach(function(c){return _this.inspectRoute(c)})},FramingNgModule.prototype.buildRoot=function(){var m=this._ngModule;this._root?(m.imports=lodash.uniqWith(m.imports.concat([_angular_platformBrowser.BrowserModule.withServerTransition({appId:"app"}),_angular_forms.FormsModule]),lodash.isEqual),m.declarations=lodash.uniqWith(m.declarations.concat([this._rootComponent]),lodash.isEqual),this._rootComponentConfig.hybrid?m.entryComponents=lodash.uniqWith(m.entryComponents.concat([this._rootComponent]),lodash.isEqual):m.bootstrap=lodash.uniqWith(m.bootstrap.concat([this._rootComponent]),lodash.isEqual)):m.imports=lodash.uniqWith(m.imports.concat([_angular_common.CommonModule]),lodash.isEqual),m.imports=lodash.uniqWith(m.imports.concat([exports.FramingComponentsModule]),lodash.isEqual)},FramingNgModule.prototype.buildFramers=function(framers,route){for(var _i=0,framers_1=framers;_i<framers_1.length;_i++){var framer=framers_1[_i];this.buildFramer(framer,route)}},FramingNgModule.prototype.buildFramer=function(framer,route){framer.framed||framer.runFraming(this,route||this.getRoute())},FramingNgModule.prototype.buildRouteFramers=function(routes){for(var _i=0,routes_1=routes;_i<routes_1.length;_i++){var route=routes_1[_i];if(route.data)for(var key in route.data)if(route.data.hasOwnProperty(key)){var prop=route.data[key];prop&&void 0!==prop._frame&&this.buildFramer(prop,route)}route.children&&this.buildRouteFramers(route.children)}},FramingNgModule.prototype.buildContainers=function(routes){for(var _loop_2=function(route){if(route.resolve&&route.resolve.containers){for(var containers_2=route.resolve.containers,_i=0,containers_3=containers_2;_i<containers_3.length;_i++){var container=containers_3[_i],containerId=FramingNgModule._nextId++;container.id=""+containerId}var resolveId=FramingNgModule._nextId++;this_2.provide({provide:"containerResolver"+resolveId,useFactory:function(i){return new exports.FramingContainerOutletResolver(containers_2,i)},deps:[_angular_core.Injector]}),route.resolve.containers="containerResolver"+resolveId}route.children&&this_2.buildContainers(route.children)},this_2=this,_i=0,routes_2=routes;_i<routes_2.length;_i++){var route=routes_2[_i];_loop_2(route)}},FramingNgModule.prototype.buildRoute=function(){var _this=this;if(this._routes.length>0){var fullRoutes_1=[],prefixRoutes_1=[];this._routes.forEach(function(route){route.pathMatch&&"full"===route.pathMatch?fullRoutes_1.push(route):route.pathMatch&&"prefix"!==route.pathMatch?console.warn("Unknown pathMatch on route",route):prefixRoutes_1.push(route),_this._routes=[],_this._routes=_this._routes.concat(fullRoutes_1),_this._routes=_this._routes.concat(prefixRoutes_1)});var routing=this._root||this._routeConfig&&this._routeConfig.forRoot?_angular_router.RouterModule.forRoot(this._routes,this._routeConfig?this._routeConfig.extraRootRouterOptions:void 0):_angular_router.RouterModule.forChild(this._routes);this.imports([routing]),this._routeConfig&&this._routeConfig.forRoot&&!this._root&&this.exports([_angular_router.RouterModule])}},FramingNgModule.prototype.getOrAddRouteOverload=function(route){if(lodash.isArray(route)){if(route.length){var result=void 0;result=this.getOrAddRoute(route[0]);for(var i=1;i<route.length;i++)result.children||(result.children=[]),result=this.getOrAddRoute(route[i],result.children);return result}return this.getOrAddRoute()}return this.getOrAddRoute(route)},FramingNgModule}();FramingNgModule._nextId=1;var Framing=function(ngModuleBuilder){var framing=ngModuleBuilder(new FramingNgModule);return framing?framing.build():(console.error("Framing must return a FramingNgModule"),{})},SimpleFramer=function(_super){function SimpleFramer(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SimpleFramer,_super),Object.defineProperty(SimpleFramer.prototype,"framerName",{get:function(){return"Simple"},enumerable:!0,configurable:!0}),Object.defineProperty(SimpleFramer.prototype,"createFrame",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(SimpleFramer.prototype,"routeRule",{get:function(){return"none"},enumerable:!0,configurable:!0}),SimpleFramer}(Framer);exports.Component=Component$1,exports.Frame=Frame,exports.FramerHelper=FramerHelper,exports.Framer=Framer,exports.FramingNgModule=FramingNgModule,exports.Framing=Framing,exports.SimpleFramer=SimpleFramer,Object.defineProperty(exports,"__esModule",{value:!0})});
8//# sourceMappingURL=ng-core.umd.min.js.map