@kephas/angular
Version:
Provides integration capabilities with Angular.
17 lines (15 loc) • 15.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms"),require("@kephas/core"),require("@kephas/ui"),require("@angular/common/http"),require("reflect-metadata"),require("@kephas/commands"),require("rxjs/operators"),require("@kephas/messaging")):"function"==typeof define&&define.amd?define("@kephas/angular",["exports","@angular/core","@angular/forms","@kephas/core","@kephas/ui","@angular/common/http","reflect-metadata","@kephas/commands","rxjs/operators","@kephas/messaging"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kephas=e.kephas||{},e.kephas.angular={}),e.ng.core,e.ng.forms,e["@kephas/core"],e["@kephas/ui"],e.ng.common.http,null,e["@kephas/commands"],e.rxjs.operators,e["@kephas/messaging"])}(this,(function(e,t,r,n,o,i,a,s,c,p){"use strict";var u=function(){function e(e,r){this.elementRef=e,this.viewContainerRef=r,this._isVisible=!0,this._readonly=!1;var i=r.injector;this.logger=i.get(n.Logger),this.notification=i.get(o.Notification),this.changeDetector=i.get(t.ChangeDetectorRef)}return Object.defineProperty(e.prototype,"childWidgets",{get:function(){return this._childWidgets},set:function(e){if(this._childWidgets!==e){var t=this._childWidgets;this._childWidgets=e,this.onChildWidgetsChanged(t,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible!==e&&(this._isVisible=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readonly",{get:function(){return this._readonly},set:function(e){if(this._readonly!==e){var t=this._readonly;this._readonly=e,this.onReadOnlyChanged(t,e)}},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngAfterViewInit=function(){},e.prototype.ngOnChanges=function(e){},e.prototype.ngOnDestroy=function(){},e.prototype.onReadOnlyChanged=function(e,t){},e.prototype.onChildWidgetsChanged=function(e,t){},e}();u.decorators=[{type:t.Component,args:[{template:""}]}],u.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef}]},u.propDecorators={childWidgets:[{type:t.ViewChildren,args:[u]}],isVisible:[{type:t.Input}],readonly:[{type:t.Input}]};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function f(e,t){function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function h(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function g(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function y(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function d(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}Object.create;function v(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}Object.create;var b=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.valueChangeFromEvent=!1,n.valueChangeFromValue=!1,n._onChange=function(e){},n._onTouched=function(){},n}return f(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getEditorValue()},set:function(e){this._valueBeforeChange!==e&&this.updateEditor(e)},enumerable:!1,configurable:!0}),t.prototype.updateEditor=function(e){if(this.valueChangeFromValue)return!1;var t=this.valueChangeFromValue;this.valueChangeFromValue=!0;try{var r=this._valueBeforeChange;this.onValueChanging(r,e),this._valueBeforeChange=e,this.valueChangeFromEvent||(this.setEditorValue(e),e=this.getEditorValue()),this.onValueChanged(r,e)}catch(e){throw this.logger.error(e,"Error while updating the editor."),e}finally{this.valueChangeFromValue=t}return!0},t.prototype.onValueChanging=function(e,t){},t.prototype.onValueChanged=function(e,t){this._onChange(t)},t.prototype.onEditorChange=function(e){if(!this.valueChangeFromValue){var t=this.valueChangeFromEvent;this.valueChangeFromEvent=!0;try{var r=this.getEditorValueOnChange(e);this.value=r}catch(e){this.notification.notifyError(e)}finally{this.valueChangeFromEvent=t}}},t.prototype.getEditorValueOnChange=function(e){return this.getEditorValue()},t.prototype.writeValue=function(e){this.value=e},t.prototype.registerOnChange=function(e){this._onChange=e},t.prototype.registerOnTouched=function(e){this._onTouched=e},t.prototype.setDisabledState=function(e){},t}(u);b.decorators=[{type:t.Component,args:[{template:""}]}],b.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef}]},b.propDecorators={value:[{type:t.Input}]},e.HttpInterceptor=function(){},e.HttpInterceptor=h([n.SingletonAppServiceContract({allowMultiple:!0,contractToken:i.HTTP_INTERCEPTORS})],e.HttpInterceptor),n.SingletonAppServiceContract()(i.XhrFactory),n.AppServiceContract()(i.HttpBackend),n.AppServiceContract()(t.Injector),n.AppServiceContract()(i.HttpXhrBackend),n.AppService({overridePriority:n.Priority.Low})(i.HttpXhrBackend);var C=function(){function e(){}return e.prototype.build=function(){return new XMLHttpRequest},e}(),w=function(){function e(e,t){this.next=e,this.interceptor=t}return e.prototype.handle=function(e){return this.interceptor.intercept(e,this.next)},e}(),E=function(){function e(e,t){this.backend=e,this.injector=t,this.chain=null}return e.prototype.handle=function(e){if(null===this.chain){var t=this.injector.get(i.HTTP_INTERCEPTORS,[]);this.chain=t.reduceRight((function(e,t){return new w(e,t)}),this.backend)}return this.chain.handle(e)},e}();E.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new E(t.ɵɵinject(i.HttpBackend),t.ɵɵinject(t.INJECTOR))},token:E,providedIn:"root"}),E.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],E.ctorParameters=function(){return[{type:i.HttpBackend},{type:t.Injector}]};var P,_=function(){function e(){}return e.prototype.getHttpClientProviders=function(){return[{provide:i.HttpClient,useClass:i.HttpClient,deps:[i.HttpHandler]},{provide:i.HttpHandler,useClass:E,deps:[i.HttpBackend,t.Injector]},{provide:i.HttpBackend,useClass:i.HttpXhrBackend,deps:[i.XhrFactory]},{provide:i.XhrFactory,useClass:C,deps:[]}]},e}(),R=function(){function e(e){this.serviceRegistry=e,n.Requires.HasValue(e,"serviceRegistry")}return e.prototype.registerServices=function(){var e,r;try{for(var n=v(this.serviceRegistry.services),o=n.next();!o.done;o=n.next()){var i=o.value;t.Injectable({providedIn:"root"})(i.serviceType)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},e.prototype.getRootProviders=function(){var e,t,r,n,o=[];try{for(var i=v(this.serviceRegistry.serviceContracts),a=i.next();!a.done;a=i.next()){var s=a.value;try{for(var c=(r=void 0,v(s.services)),p=c.next();!p.done;p=c.next()){var u=p.value;o.push({provide:s.contractToken||s.contractType,useClass:u.serviceType,multi:s.allowMultiple,deps:this.getDependencies(u.serviceType)})}}catch(e){r={error:e}}finally{try{p&&!p.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o.push.apply(o,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}((new _).getHttpClientProviders())),o},e.prototype.getDependencies=function(e){var t=Reflect.getMetadata("design:paramtypes",e);return!t&&e.ctorParameters&&(t=e.ctorParameters()),t||[]},e}();e.AppSettings=function(){function e(){}return Object.defineProperty(e.prototype,"baseUrl",{get:function(){var e=document.getElementsByTagName("base"),t=e&&e[0];return t&&t.href||document.baseURI||"/"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseApiUrl",{get:function(){return this.baseUrl+"api/"},enumerable:!1,configurable:!0}),e}(),e.AppSettings=h([n.AppService({overridePriority:n.Priority.Low}),n.SingletonAppServiceContract()],e.AppSettings),e.HttpCommandProcessorClient=function(e){function t(t,r,n,o){var i=e.call(this)||this;return i.appSettings=t,i.http=r,i.notification=n,i.logger=o,i.baseRoute="api/cmd/",i}return f(t,e),t.prototype.process=function(e,t,r){var n=this,o=this.getHttpGetUrl(e,t,r),i=this.http.get(o,this.getHttpGetOptions(e,t,r));return i=r&&r.retries?i.pipe(c.retry(r.retries),c.map((function(e){return n._processResponse(e,r)})),c.catchError((function(e){return n._processError(e,r)}))):i.pipe(c.map((function(e){return n._processResponse(e,r)})),c.catchError((function(e){return n._processError(e,r)})))},t.prototype.getHttpGetUrl=function(e,t,r){var n=this.appSettings.baseUrl;n.endsWith("/")||(n+="/");var o=""+n+this.baseRoute+e+"/";return t&&(o=o+"?"+Object.keys(t).map((function(e){return e+"="+t[e]})).join("&")),o},t.prototype.getHttpGetOptions=function(e,t,r){},t.prototype._processResponse=function(e,t){if("string"==typeof e.severity&&(e.severity=n.LogLevel[e.severity]),e.severity<=n.LogLevel.Error)throw new s.CommandError(e.message,e);if(e.severity===n.LogLevel.Warning&&(this.logger.log(e.severity,null,e.message),t&&(void 0===t.notifyWarnings||t.notifyWarnings)||this.notification.notifyWarning(e)),e.severity<=n.LogLevel.Error)throw new Error(e.message);return e},t.prototype._processError=function(e,t){throw this.logger.error(e),t&&(void 0===t.notifyErrors||t.notifyErrors)||this.notification.notifyError(e),e},t}(s.CommandProcessorClient),e.HttpCommandProcessorClient=h([n.AppService({overridePriority:n.Priority.Low}),g("design:paramtypes",[e.AppSettings,i.HttpClient,o.Notification,n.Logger])],e.HttpCommandProcessorClient),e.HttpMessageProcessorClient=function(e){function t(t,r,n,o){var i=e.call(this)||this;return i.appSettings=t,i.http=r,i.notification=n,i.logger=o,i.baseRoute="api/msg/",i}return f(t,e),t.prototype.process=function(e,t){var r=this,n=this.getHttpPostUrl(e,t),o=this.http.post(n,e,this.getHttpPostOptions(e,t));return t&&t.retries?o.pipe(c.retry(t.retries),c.map((function(e){return r._processResponse(e,t)})),c.catchError((function(e){return r._processError(e,t)}))):o.pipe(c.map((function(e){return r._processResponse(e,t)})),c.catchError((function(e){return r._processError(e,t)})))},t.prototype.getHttpPostUrl=function(e,t){var r=this.appSettings.baseUrl;return r.endsWith("/")||(r+="/"),""+r+this.baseRoute},t.prototype.getHttpPostOptions=function(e,t){},t.prototype._processResponse=function(e,t){if(e.exception){var r=e.exception;throw"string"==typeof r.severity&&(r.severity=n.LogLevel[r.severity]),new p.MessagingError(r.message,r)}var o=e.message;if("string"==typeof o.severity&&(o.severity=n.LogLevel[o.severity]),o.severity<=n.LogLevel.Error)throw new p.MessagingError(o.message,o);if(o.severity===n.LogLevel.Warning&&(this.logger.log(o.severity,null,o.message),t&&(void 0===t.notifyWarnings||t.notifyWarnings)||this.notification.notifyWarning(o)),o.severity<=n.LogLevel.Error)throw new p.MessagingError(o.message,o);return o},t.prototype._processError=function(e,t){throw this.logger.error(e),t&&(void 0===t.notifyErrors||t.notifyErrors)||this.notification.notifyError(e),e},t}(p.MessageProcessorClient),e.HttpMessageProcessorClient=h([n.AppService({overridePriority:n.Priority.Low}),g("design:paramtypes",[e.AppSettings,i.HttpClient,o.Notification,n.Logger])],e.HttpMessageProcessorClient),e.Configuration=P=function(){function e(){}return e.prototype.initializeAsync=function(e){return y(this,void 0,void 0,(function(){var t;return d(this,(function(r){switch(r.label){case 0:return P.configurationFile?[2]:[4,e.http.get(e.configurationFileUrl?e.configurationFileUrl:P.configurationFileUrl).toPromise()];case 1:return t=r.sent(),P.configurationFile=t||{},[2]}}))}))},e.prototype.getSettings=function(e){if(!P.configurationFile)throw new Error("The configuration manager must be initialized prior to requesting settings from it.");var t=e.name,r="Settings";return t.endsWith(r)&&(t=t.substr(0,t.length-r.length)),t=t[0].toLowerCase()+t.substr(1,t.length-1),P.configurationFile[t]},e}(),e.Configuration.configurationFileUrl="/app/configuration.json",e.Configuration=P=h([n.AppService({overridePriority:n.Priority.Low}),n.SingletonAppServiceContract()],e.Configuration),e.AngularAppServiceInfoRegistry=R,e.BrowserXhrFactory=C,e.HttpClientAppServiceInfoRegistry=_,e.HttpInterceptingHandler=E,e.HttpInterceptorHandler=w,e.ValueEditorBase=b,e.WidgetBase=u,e.provideValueAccessor=function(e){return{provide:r.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return e})),multi:!0}},e.provideWidget=function(e){return{provide:u,useExisting:t.forwardRef((function(){return e}))}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=kephas-angular.umd.min.js.map