@ng-arthur/common
Version: 
@ng-arthur/common for Angular 7+ Components
2 lines • 6.95 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("@ng-arthur/common",["exports","@angular/core","@angular/common"],t):t(((e=e||self)["ng-arthur"]=e["ng-arthur"]||{},e["ng-arthur"].common={}),e.ng.core,e.ng.common)}(this,function(e,t,n){"use strict";function r(e,t,n,r){var o,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(u=(i<3?o(u):i>3?o(t,n,u):o(t,n))||u);return i>3&&u&&Object.defineProperty(t,n,u),u}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var i=function(){function e(){}return e.prototype.info=function(e){},e.prototype.warn=function(e){},e.prototype.error=function(e){},e.prototype.success=function(e){},e=r([t.Injectable(),o("design:paramtypes",[])],e)}(),u=function(){function e(){}return e=r([t.NgModule({imports:[n.CommonModule],providers:[i]})],e)}(),c={ipad:function(e){return y(e,/iPad/i)},iphone:function(e){return y(e,/iPhone/i)},ios:function(e){return y(e,/iPad|iPhone|iPod/i)},android:function(e){return y(e,/android|sink/i)},phablet:function(e){var t=e.innerWidth,n=e.innerHeight,r=Math.min(t,n),o=Math.max(t,n);return r>390&&r<520&&o>620&&o<800},tablet:function(e){var t=e.innerWidth,n=e.innerHeight,r=Math.min(t,n),o=Math.max(t,n);return r>460&&r<820&&o>780&&o<1400},cordova:l,capacitor:d,electron:function(e){return y(e,/electron/)},pwa:function(e){return e.matchMedia("(display-mode: standalone)").matches},mobile:p,desktop:function(e){return!p(e)},hybrid:function(e){return l(e)||d(e)},wechat:function(e){return y(e,/MicroMessenger/i)},webApp:function(e){return y(e,/Safari/i)},weibo:function(e){return y(e,/WeiBo/i)},qq:function(e){return y(e,/QQ/i)},alipay:function(e){return y(e,/alipay/i)}};function a(e){return s(e)}function f(e,t){return a(e).indexOf(t)<0}function s(e){e.Ionic=e.Ionic||{};var t=e.Ionic.platforms;return null==t&&(t=e.Ionic.platforms=function(e){return Object.keys(c).filter(function(t){return c[t](e)})}(e)),t}function p(e){return function(e,t){return e.matchMedia(t).matches}(e,"(any-pointer:coarse)")}function l(e){var t=e;return!!(t.cordova||t.phonegap||t.PhoneGap)}function d(e){var t=e.Capacitor;return!(!t||!t.isNative)}function y(e,t){return t.test(e.navigator.userAgent)}var m=function(){function e(){}return e.prototype.is=function(e){return f(window,e)},e.prototype.platforms=function(){return a(window)},Object.defineProperty(e.prototype,"isRTL",{get:function(){return"rtl"===document.dir},enumerable:!0,configurable:!0}),e.prototype.getQueryParam=function(e){return function(e,t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(e);return n?decodeURIComponent(n[1].replace(/\+/g," ")):null}(window.location.href,e)},e.prototype.isLandscape=function(){return!this.isPortrait()},e.prototype.isPortrait=function(){return window.matchMedia("(orientation: portrait)").matches},e.prototype.testUserAgent=function(e){return navigator.userAgent.indexOf(e)>=0},e.prototype.url=function(){return window.location.href},e.prototype.width=function(){return window.innerWidth},e.prototype.height=function(){return window.innerHeight},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=r([t.Injectable({providedIn:"root"}),o("design:paramtypes",[])],e)}();var g=function(){function e(){}return e=r([t.NgModule({imports:[]})],e)}(),h=function(){function e(){}return e.SYSTEM={ERR_PROMPT:"system.err.prompt",ERR_TIMEOUT:"system.err.timeout",ERR_CONNECTION_REFUSED:"system.err.connection_refused",ERR_UNKNOWN:"system.err.unknown",ERR_NETWORK:"system.err.network",EXCEPTION_SERVICES:"system.exception_services",TRANSACTION_FAILED:"system.transaction_failed",TRANSACTION_FAILED_TEMPLATE:"system.transaction_failed_template",SENDING_FAILED:"system.sending_failed",CONNECTING_FAILED:"system.connecting_failed",NOT_FOUND:"system.not_found"},e.ACCESS_TOKEN="Access-Token",e}(),O=function(){function e(){}return e.isNullOrEmpty=function(e){if(null==e||"undefined"===e||void 0===e)return!0;var t=Object.prototype.toString.call(e).toLowerCase().slice(8,-1);switch(t){case"boolean":case"number":return!1;case"string":return!e.replace(/(^\s*)|(\s*$)/g,"");case"array":return!e.length;case"map":return!e.size;case"object":return!(!Object.prototype.isPrototypeOf(e)||0!==Object.keys(e).length)||(Object.keys(e).map(function(e){return!1}),!0);default:return console.warn("unknown type:"+t+", value:"+e+", please perfect the judgment logic"),!1}},e.toBoolean=function(e){return""===e||e&&"false"!==e},e.isUndefined=function(e){return void 0===e},e.isEmpty=function(e){return null==e},e.random=function(){return Math.random()},e.equals=function(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(e!=e&&t!=t)return!0;var n,r,o,i=typeof e;if(i==typeof t&&"object"==i){if(!Array.isArray(e)){if(Array.isArray(t))return!1;for(r in o=Object.create(null),e){if(!this.equals(e[r],t[r]))return!1;o[r]=!0}for(r in t)if(!(r in o)&&"undefined"!=typeof t[r])return!1;return!0}if(!Array.isArray(t))return!1;if((n=e.length)==t.length){for(r=0;r<n;r++)if(!this.equals(e[r],t[r]))return!1;return!0}}return!1},e.isDefined=function(e){return void 0!==e&&null!=e},e.isObject=function(e){return e&&"object"==typeof e&&!Array.isArray(e)},e.mergeDeep=function(e,t){var n=this;e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));var r=Object.assign({},e);return this.isObject(e)&&this.isObject(t)&&Object.keys(t).forEach(function(o){var i,u;n.isObject(t[o])?o in e?r[o]=n.mergeDeep(e[o],t[o]):Object.assign(r,((i={})[o]=t[o],i)):Object.assign(r,((u={})[o]=t[o],u))}),r},e.getUrl=function(e){for(var t=this.getTruthRoute(e),n=[];t;)n.push(t.url.join("/")),t=t.parent;return"/"+n.filter(function(e){return e}).reverse().join("/")},e.mergeJSON=function(e,t){for(var n in t){var r=t[n];r!==undefined?this.isJSON(e[n])||this.isArray(e[n])?this.mergeJSON(e[n],t[n]):e[n]=r:e[n]=r}},e.isJSON=function(e){return"object"==typeof e&&e.constructor==Object},e.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},e.getTruthRoute=function(e){for(var t=e;t.firstChild;)t=t.firstChild;return t},e.deleteEmptyProperties=function(e){var t=Object.assign({},e);for(var n in t){var r=t[n];this.isNullOrEmpty(r)&&delete t[n]}return t},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=r([t.Injectable({providedIn:"root"})],e)}();e.NaCommonModule=g,e.NaConstant=h,e.NaLogModule=u,e.NaLogService=i,e.NaUtils=O,e.PLATFORMS_MAP=c,e.PlatformService=m,e.getPlatforms=a,e.isPlatform=f,e.setupPlatforms=s,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-arthur-common.umd.min.js.map