@selfcommunity/utils 0.2.63 → 0.2.64-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/umd/utils.js +1 -1
  2. package/package.json +2 -3
package/lib/umd/utils.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see utils.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SelfCommunityUtils=t():e.SelfCommunityUtils=t()}(self,(()=>(()=>{"use strict";var e={469:(e,t)=>{t.__esModule=!0,t.sortByAttr=t.groupBy=t.arraysEqual=void 0,t.arraysEqual=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0},t.groupBy=(e,t)=>e.reduce((function(e,r){let n="function"==typeof t?t(r):r[t];return e.hasOwnProperty(n)||(e[n]=[]),e[n].push(r),e}),{}),t.sortByAttr=(e,t,r=!0)=>{if(!Array.isArray(e))return e;const n=r?(e,r)=>e[t]-r[t]:(e,r)=>r[t]-e[t];return e.sort(n)}},285:(e,t)=>{t.__esModule=!0,t.loadVersionBrowser=t.iOS=void 0,t.loadVersionBrowser=()=>{if("userAgentData"in navigator){const e=navigator.userAgentData;let t,r,n=null;for(let i=0;i<e.brands.length;i++){const o=e.brands[i].brand;if(r=e.brands[i].version,null!==o.match(/opera|chrome|edge|safari|firefox|msie|trident/i)){if(null===o.match(/chrome/i))return t=o.substr(o.indexOf(" ")+1),{name:t,version:r};n=r}}if(null!==n)return{name:"chrome",version:n}}let e,t=navigator.userAgent,r=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(r[1])?(e=/\brv[ :]+(\d+)/g.exec(t)||[],{name:"IE",version:e[1]||""}):"Chrome"===r[1]&&(e=t.match(/\bOPR\/(\d+)/),null!=e)?{name:"Opera",version:e[1]}:(r=r[2]?[r[1],r[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&r.splice(1,1,e[1]),{name:r[0],version:r[1]})},t.iOS=()=>["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},466:(e,t)=>{t.__esModule=!0,t.default=t.LruCache=t.CacheStrategies=void 0;class r{constructor(e=1e4){this.values=new Map,this.maxEntries=e,this.ssr="undefined"==typeof window,this.ssr||(window.__viewSCCache=this.values)}get(e,t,r={noSsr:!0}){let n;return this.values.has(e)?(n=this.values.get(e),this.values.delete(e),this.values.set(e,n)):t&&(n=t,(!this.ssr||!r.noSsr)&&this.values.set(e,n)),n}set(e,t,r={noSsr:!0}){if(!this.ssr||!r.noSsr){if(this.values.size>=this.maxEntries){const e=this.values.keys().next().value;this.values.delete(e)}this.values.set(e,t)}}hasKey(e){return this.values.has(e)}delete(e){this.values.has(e)&&this.values.delete(e)}deleteKeys(e){e.forEach((e=>{this.values.has(e)&&this.values.delete(e)}))}deleteKeysWithPrefix(e){this.values.forEach(((t,r)=>{r.startsWith(e)&&this.values.delete(r)}))}clean(){this.values=new Map}evaluate(){console.log(this.values)}}let n;t.LruCache=r,t.CacheStrategies=n,function(e){e.CACHE_FIRST="Cache-first",e.NETWORK_ONLY="Network-only",e.STALE_WHILE_REVALIDATE="Stale-While-Revalidate"}(n||(t.CacheStrategies=n={}));var i=new r;t.default=i},858:(e,t)=>{t.__esModule=!0,t.resizeImage=void 0,t.resizeImage=e=>new Promise(((t,r)=>{const n=new FileReader;n.onload=e=>{let r=new Image;r.onload=function(e){let n=document.createElement("canvas"),i=1920,o=r.width,s=r.height;o>s?o>i&&(s*=i/o,o=i):s>i&&(o*=i/s,s=i),n.width=o,n.height=s,n.getContext("2d").drawImage(r,0,0,o,s),t((e=>{let t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);let r=e.split(",")[0].split(":")[1].split(";")[0],n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Blob([n],{type:r})})(n.toDataURL("image/jpeg")))},r.src=e.target.result},n.onerror=r,n.readAsDataURL(e)}))},153:(e,t)=>{t.__esModule=!0,t.LocalStorageDB=void 0,t.LocalStorageDB=class{static set(e,t){if(this.checkifSupport())try{window.localStorage.setItem(e,t)}catch(e){console.error(e)}else console.error("No support. Use a fallback such as browser cookies or store on the server.")}static get(e){try{let t=window.localStorage.getItem(e);return t&&"object"==typeof t?JSON.parse(t):t}catch(e){return null}}static getAll(){let e=[];for(let t=0;t<window.localStorage.length;t++){let r=localStorage.key(t);e.push(this.get(r))}return e}static remove(e){try{window.localStorage.removeItem(e),0==window.localStorage.length&&this.clearAll()}catch(e){console.error(e)}finally{this.get(e)&&(delete window.localStorage[e],0==window.localStorage.length&&this.clearAll())}}static clearAll(){try{window.localStorage.clear()}catch(e){console.error(e)}}static checkifSupport(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}}},502:(e,t)=>{t.__esModule=!0,t.Logger=void 0,t.Logger=class{static info(e,t){console.info(`%c[${e}]`,"color:#008080",` ${t}`)}static warn(e,t){console.warn(`%c[${e}]`,"color:#008080",` ${t}`)}static error(e,t){console.error(`%c[${e}]`,"color:#008080",` ${t}`)}static log(e,t){console.log(`%c[${e}]`,"color:#008080",` ${t}`)}static debug(e,t){console.debug(`%c[${e}]`,"color:#008080",` ${t}`)}}},597:(e,t)=>{t.__esModule=!0,t.isInteger=function(e){return!isNaN(e)&&parseInt(String(Number(e)))==e&&!isNaN(parseInt(String(e),10))}},297:(e,t)=>{function r(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}t.__esModule=!0,t.isFunc=function(e){return"function"==typeof e},t.isObject=r,t.mergeDeep=function e(t,n){let i=Object.assign({},t);return r(t)&&r(n)&&Object.keys(n).forEach((o=>{r(n[o])?o in t?i[o]=e(t[o],n[o]):Object.assign(i,{[o]:n[o]}):Object.assign(i,{[o]:n[o]})})),i},t.objectWithoutProperties=function(e,t){let r=e?Object.assign({},e):null;return t.forEach((function(e){r&&e in r&&delete r[e]})),r}},884:(e,t)=>{function r(e){let t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch(e){return document.body.removeChild(t),Promise.reject(e)}}t.__esModule=!0,t.camelCase=function(e){return e.toLowerCase().replace(/[-_]+/g," ").replace(/[^\w\s]/g,"").replace(/ (.)/g,(e=>e.toUpperCase())).replace(/ /g,"")},t.capitalize=function(e){let t="",r=e.split(" ");for(let e=0;e<r.length;e++)t+=r[e].substring(0,1).toUpperCase()+r[e].substring(1,r[e].length);return t},t.copyTextToClipboard=function(e){return navigator.clipboard?navigator.clipboard.writeText(e):r(e)},t.fallbackCopyTextToClipboard=r,t.isString=function(e){return"string"==typeof e||e instanceof String},t.random=function(){return(Math.random()+1).toString(36).substring(7)},t.slugify=function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")},t.stripHtml=function(e){return e.replace(/<[^>]*>?/gm,"").trim()}},735:(e,t)=>{t.__esModule=!0,t.appendURLSearchParams=function(e,t){let r=e;if(t.length&&r){const e=Object.keys(t[0])[0];r+=(r.split("?")[1]?"&":"?")+`${e}=${t[0][e]}`,t.slice(1).map((e=>{const t=Object.keys(e)[0];r+=`&${t}=${e[t]}`}))}return r},t.urlReplacer=t.urlB64ToUint8Array=t.updateQueryStringParameter=t.isValidUrls=t.isValidUrl=t.getQueryStringParameter=t.getDomain=void 0,t.urlReplacer=e=>t=>function(e,t){const r=/\$\(([^)]+)?\)/g;let n=r.exec(e);for(;n;)e=e.replace(n[0],t[n[1]]),r.lastIndex=0,n=r.exec(e);return e}(e,t),t.getDomain=e=>{const t=e.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);return t&&t[1]?t[1]:""};const r=e=>/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(e);t.isValidUrl=r,t.isValidUrls=(e,t)=>e.trim().split(t).every(r),t.urlB64ToUint8Array=e=>{const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(t),n=new Uint8Array(r.length);for(let e=0;e<r.length;++e)n[e]=r.charCodeAt(e);return n},t.getQueryStringParameter=(e,t)=>e&&t?new URL(e).searchParams.get(t):null,t.updateQueryStringParameter=(e,t,r)=>{if(e&&t&&r){let n=new RegExp("([?&])"+t+"=.*?(&|$)","i"),i=-1!==e.indexOf("?")?"&":"?";return e.match(n)?e.replace(n,"$1"+t+"="+r+"$2"):e+i+t+"="+r}return e}},507:(e,t)=>{t.__esModule=!0,t.default=void 0;class r{constructor(e){this._attempts=1,this._heartbeatInterval=null,this._missedHeartbeats=0,this.isValidOptions(e)&&(this._cfg=Object.assign({},{heartbeatMsg:null,debug:!1,mustReconnect:!0},e),this.connect())}static getInstance(e){return this._instance=this._instance||new r(e),this._instance}connect(){try{if(this._ws&&(this.isConnecting()||this.isConnected()))return void(this._cfg.debug&&console.info("Websocket is connecting or already connected."));"function"==typeof this._cfg.connecting&&this._cfg.connecting(),this._cfg.debug&&console.info(`Connecting to ${this._cfg.uri} ...`),this._ws=new WebSocket(this._cfg.uri,this._cfg.protocols),this._ws.onopen=this.onOpen.bind(this),this._ws.onmessage=this.onMessage.bind(this),this._ws.onerror=this.onError.bind(this),this._ws.onclose=this.onClose.bind(this),this._timer=null}catch(e){console.error(e),this.tryToReconnect()}}isValidOptions(e){let t=!1;return e?(e.uri||(console.error("Invalid WSClient Uri options."),t=!0),e&&e.connecting&&"function"!=typeof e.connecting&&(console.error("Invalid WSClient connecting options."),t=!0),e&&e.connected&&"function"!=typeof e.connected&&(console.error("Invalid WSClient connected options."),t=!0),e&&e.receiveMessage&&"function"!=typeof e.receiveMessage&&(console.error("Invalid WSClient receiveMessage options."),t=!0),e&&e.disconnected&&"function"!=typeof e.disconnected&&(console.error("Invalid WSClient connecting options."),t=!0),e&&e.heartbeatMsg&&"string"!=typeof e.heartbeatMsg&&(console.error("Invalid WSClient heartbeatMsg options."),t=!0),e&&e.debug&&"boolean"!=typeof e.debug&&(console.error("Invalid WSClient debug options."),t=!0),!t):(console.error("Invalid WSClient options."),t)}tryToReconnect(){if(this._cfg.mustReconnect&&!this._timer){this._cfg.debug&&console.info("Reconnecting...");let e=this.generateInterval(this._attempts);this._timer=setTimeout(this.reconnect.bind(this),e)}}reconnect(){this._attempts++,this.connect()}sendHeartbeat(){try{if(this._missedHeartbeats++,this._missedHeartbeats>3)throw new Error("Too many missed heartbeats.");this._ws.send(this._cfg.heartbeatMsg)}catch(e){clearInterval(this._heartbeatInterval),this._heartbeatInterval=null,this._cfg.debug&&console.warn(`Closing connection. Reason: ${e.message}`),this.isClosing()||this.isClosed()||this.close()}}onOpen(){this._cfg.debug&&console.info("Connected!"),this._attempts=1,this._cfg.heartbeatMsg&&null===this._heartbeatInterval&&(this._missedHeartbeats=0,this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),5e3)),"function"==typeof this._cfg.connected&&this._cfg.connected()}onClose(e){this._cfg.debug&&console.info("Connection closed!"),"function"==typeof this._cfg.disconnected&&this._cfg.disconnected(e),this.tryToReconnect()}onError(e){this._cfg.debug&&console.error("Websocket connection is broken!"),this._cfg.debug&&console.error(e)}onMessage(e){if(this._cfg.heartbeatMsg&&e.data===this._cfg.heartbeatMsg)this._missedHeartbeats=0;else if("function"==typeof this._cfg.receiveMessage)return this._cfg.receiveMessage(e.data)}generateInterval(e){let t=1e3*(Math.pow(2,e)-1);return t>3e4&&(t=3e4),Math.random()*t}sendMessage(e){this._ws&&this._ws.send(e)}getState(){return this._ws&&this._ws.readyState}isConnecting(){return this._ws&&0===this._ws.readyState}isConnected(){return this._ws&&1===this._ws.readyState}isClosing(){return this._ws&&2===this._ws.readyState}isClosed(){return this._ws&&3===this._ws.readyState}close(){clearInterval(this._heartbeatInterval),this._cfg.mustReconnect=!1,this.isClosing()&&this.isClosed()||(this._ws.close(),this._cfg.debug&&console.error("Websocket closed."))}}t.default=r},474:(e,t,r)=>{t.__esModule=!0,t.getHighestSafeWindowContext=function e(t=r.g.window.self){return t===r.g.window.top||(()=>{try{return r.g.window.location.hostname!==r.g.window.parent.location.hostname}catch(e){return!0}})()?t:e(t.parent)},t.getWindowHeight=function(){return void 0!==r.g.window?r.g.window.innerHeight:0},t.getWindowWidth=function(){return void 0!==r.g.window?r.g.window.innerWidth:0},t.isClientSideRendering=function(){return"undefined"!=typeof window}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n={};return(()=>{var e=n;e.__esModule=!0;var t=r(884);e.capitalize=t.capitalize,e.isString=t.isString,e.stripHtml=t.stripHtml,e.camelCase=t.camelCase,e.copyTextToClipboard=t.copyTextToClipboard,e.fallbackCopyTextToClipboard=t.fallbackCopyTextToClipboard,e.random=t.random,e.slugify=t.slugify;var i=r(735);e.isValidUrl=i.isValidUrl,e.isValidUrls=i.isValidUrls,e.urlReplacer=i.urlReplacer,e.getDomain=i.getDomain,e.appendURLSearchParams=i.appendURLSearchParams,e.urlB64ToUint8Array=i.urlB64ToUint8Array,e.getQueryStringParameter=i.getQueryStringParameter,e.updateQueryStringParameter=i.updateQueryStringParameter;var o=r(474);e.getHighestSafeWindowContext=o.getHighestSafeWindowContext,e.getWindowWidth=o.getWindowWidth,e.getWindowHeight=o.getWindowHeight,e.isClientSideRendering=o.isClientSideRendering;var s=r(297);e.mergeDeep=s.mergeDeep,e.isObject=s.isObject,e.objectWithoutProperties=s.objectWithoutProperties,e.isFunc=s.isFunc;var a=r(597);e.isInteger=a.isInteger;var l=r(469);e.arraysEqual=l.arraysEqual,e.groupBy=l.groupBy,e.sortByAttr=l.sortByAttr;var c=r(285);e.loadVersionBrowser=c.loadVersionBrowser,e.iOS=c.iOS;var u=r(153);e.LocalStorageDB=u.LocalStorageDB;var h=w(r(466));e.LRUCache=h.default,e.LruCache=h.LruCache,e.LruCacheType=h.LruCacheType,e.CacheStrategies=h.CacheStrategies;var d=r(502);e.Logger=d.Logger;var g=w(r(507));e.WSClient=g.default,e.WSClientType=g.WSClientType,e.WSClientPropTypes=g.WSClientPropTypes;var f=r(858);function p(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(p=function(e){return e?r:t})(e)}function w(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=p(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}e.resizeImage=f.resizeImage})(),n})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SelfCommunityUtils=t():e.SelfCommunityUtils=t()}(self,(()=>(()=>{"use strict";var e={615:(e,t)=>{t.__esModule=!0,t.sortByAttr=t.groupBy=t.arraysEqual=void 0,t.arraysEqual=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},t.groupBy=function(e,t){return e.reduce((function(e,n){var r="function"==typeof t?t(n):n[t];return e.hasOwnProperty(r)||(e[r]=[]),e[r].push(n),e}),{})},t.sortByAttr=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Array.isArray(e))return e;var r=n?function(e,n){return e[t]-n[t]}:function(e,n){return n[t]-e[t]};return e.sort(r)}},391:(e,t)=>{t.__esModule=!0,t.loadVersionBrowser=t.iOS=void 0,t.loadVersionBrowser=function(){if("userAgentData"in navigator){for(var e,t=navigator.userAgentData,n=null,r=0;r<t.brands.length;r++){var o=t.brands[r].brand;if(e=t.brands[r].version,null!==o.match(/opera|chrome|edge|safari|firefox|msie|trident/i)){if(null===o.match(/chrome/i))return{name:o.substr(o.indexOf(" ")+1),version:e};n=e}}if(null!==n)return{name:"chrome",version:n}}var i,a=navigator.userAgent,s=a.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(s[1])?{name:"IE",version:(i=/\brv[ :]+(\d+)/g.exec(a)||[])[1]||""}:"Chrome"===s[1]&&null!=(i=a.match(/\bOPR\/(\d+)/))?{name:"Opera",version:i[1]}:(s=s[2]?[s[1],s[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(i=a.match(/version\/(\d+)/i))&&s.splice(1,1,i[1]),{name:s[0],version:s[1]})},t.iOS=function(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}},614:(e,t)=>{function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}t.__esModule=!0,t.default=t.LruCache=t.CacheStrategies=void 0;var o,i=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;n(this,e),this.values=new Map,this.maxEntries=void 0,this.ssr=void 0,this.maxEntries=t,this.ssr="undefined"==typeof window,this.ssr||(window.__viewSCCache=this.values)},t=[{key:"get",value:function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{noSsr:!0},o=this.values.has(e);return o?(n=this.values.get(e),this.values.delete(e),this.values.set(e,n)):t&&(n=t,(!this.ssr||!r.noSsr)&&this.values.set(e,n)),n}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{noSsr:!0};if(!this.ssr||!n.noSsr){if(this.values.size>=this.maxEntries){var r=this.values.keys().next().value;this.values.delete(r)}this.values.set(e,t)}}},{key:"hasKey",value:function(e){return this.values.has(e)}},{key:"delete",value:function(e){this.values.has(e)&&this.values.delete(e)}},{key:"deleteKeys",value:function(e){var t=this;e.forEach((function(e){t.values.has(e)&&t.values.delete(e)}))}},{key:"deleteKeysWithPrefix",value:function(e){var t=this;this.values.forEach((function(n,r){r.startsWith(e)&&t.values.delete(r)}))}},{key:"clean",value:function(){this.values=new Map}},{key:"evaluate",value:function(){console.log(this.values)}}],t&&r(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();t.LruCache=i,t.CacheStrategies=o,function(e){e.CACHE_FIRST="Cache-first",e.NETWORK_ONLY="Network-only",e.STALE_WHILE_REVALIDATE="Stale-While-Revalidate"}(o||(t.CacheStrategies=o={}));var a=new i;t.default=a},501:(e,t)=>{t.__esModule=!0,t.resizeImage=void 0,t.resizeImage=function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){var n=new Image;n.onload=function(e){var r=document.createElement("canvas"),o=1920,i=n.width,a=n.height;i>a?i>o&&(a*=o/i,i=o):a>o&&(i*=o/a,a=o),r.width=i,r.height=a,r.getContext("2d").drawImage(n,0,0,i,a),t(function(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var n=e.split(",")[0].split(":")[1].split(";")[0],r=new Uint8Array(t.length),o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new Blob([r],{type:n})}(r.toDataURL("image/jpeg")))},n.src=e.target.result},r.onerror=n,r.readAsDataURL(e)}))}},925:(e,t)=>{function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}t.__esModule=!0,t.LocalStorageDB=void 0;var o=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"set",value:function(e,t){if(this.checkifSupport())try{window.localStorage.setItem(e,t)}catch(e){console.error(e)}else console.error("No support. Use a fallback such as browser cookies or store on the server.")}},{key:"get",value:function(e){try{var t=window.localStorage.getItem(e);return t&&"object"===n(t)?JSON.parse(t):t}catch(e){return null}}},{key:"getAll",value:function(){for(var e=[],t=0;t<window.localStorage.length;t++){var n=localStorage.key(t);e.push(this.get(n))}return e}},{key:"remove",value:function(e){try{window.localStorage.removeItem(e),0==window.localStorage.length&&this.clearAll()}catch(e){console.error(e)}finally{this.get(e)&&(delete window.localStorage[e],0==window.localStorage.length&&this.clearAll())}}},{key:"clearAll",value:function(){try{window.localStorage.clear()}catch(e){console.error(e)}}},{key:"checkifSupport",value:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}}],null&&r(e.prototype,null),t&&r(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();t.LocalStorageDB=o},184:(e,t)=>{function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}t.__esModule=!0,t.Logger=void 0;var r=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"info",value:function(e,t){console.info("%c[".concat(e,"]"),"color:#008080"," ".concat(t))}},{key:"warn",value:function(e,t){console.warn("%c[".concat(e,"]"),"color:#008080"," ".concat(t))}},{key:"error",value:function(e,t){console.error("%c[".concat(e,"]"),"color:#008080"," ".concat(t))}},{key:"log",value:function(e,t){console.log("%c[".concat(e,"]"),"color:#008080"," ".concat(t))}},{key:"debug",value:function(e,t){console.debug("%c[".concat(e,"]"),"color:#008080"," ".concat(t))}}],null&&n(e.prototype,null),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();t.Logger=r},829:(e,t)=>{t.__esModule=!0,t.isInteger=function(e){return!isNaN(e)&&parseInt(String(Number(e)))==e&&!isNaN(parseInt(String(e),10))}},378:(e,t)=>{function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){return"object"===n(e)&&!Array.isArray(e)&&null!==e}t.__esModule=!0,t.isFunc=function(e){return"function"==typeof e},t.isObject=r,t.mergeDeep=function e(t,n){var o=Object.assign({},t);return r(t)&&r(n)&&Object.keys(n).forEach((function(i){r(n[i])&&i in t?o[i]=e(t[i],n[i]):Object.assign(o,function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},i,n[i]))})),o},t.objectWithoutProperties=function(e,t){var n=e?Object.assign({},e):null;return t.forEach((function(e){n&&e in n&&delete n[e]})),n}},153:(e,t)=>{function n(e){var t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch(e){return document.body.removeChild(t),Promise.reject(e)}}t.__esModule=!0,t.camelCase=function(e){return e.toLowerCase().replace(/[-_]+/g," ").replace(/[^\w\s]/g,"").replace(/ (.)/g,(function(e){return e.toUpperCase()})).replace(/ /g,"")},t.capitalize=function(e){for(var t="",n=e.split(" "),r=0;r<n.length;r++)t+=n[r].substring(0,1).toUpperCase()+n[r].substring(1,n[r].length);return t},t.copyTextToClipboard=function(e){return navigator.clipboard?navigator.clipboard.writeText(e):n(e)},t.fallbackCopyTextToClipboard=n,t.isString=function(e){return"string"==typeof e||e instanceof String},t.random=function(){return(Math.random()+1).toString(36).substring(7)},t.slugify=function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")},t.stripHtml=function(e){return e.replace(/<[^>]*>?/gm,"").trim()}},449:(e,t)=>{t.__esModule=!0,t.appendURLSearchParams=function(e,t){var n=e;if(t.length&&n){var r=Object.keys(t[0])[0];n+=(n.split("?")[1]?"&":"?")+"".concat(r,"=").concat(t[0][r]),t.slice(1).map((function(e){var t=Object.keys(e)[0];n+="&".concat(t,"=").concat(e[t])}))}return n},t.urlReplacer=t.urlB64ToUint8Array=t.updateQueryStringParameter=t.isValidUrls=t.isValidUrl=t.getQueryStringParameter=t.getDomain=void 0,t.urlReplacer=function(e){return function(t){return function(e,t){for(var n=/\$\(([^)]+)?\)/g,r=n.exec(e);r;)e=e.replace(r[0],t[r[1]]),n.lastIndex=0,r=n.exec(e);return e}(e,t)}},t.getDomain=function(e){var t=e.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);return t&&t[1]?t[1]:""};var n=function(e){return/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(e)};t.isValidUrl=n,t.isValidUrls=function(e,t){return e.trim().split(t).every(n)},t.urlB64ToUint8Array=function(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(t),r=new Uint8Array(n.length),o=0;o<n.length;++o)r[o]=n.charCodeAt(o);return r},t.getQueryStringParameter=function(e,t){return e&&t?new URL(e).searchParams.get(t):null},t.updateQueryStringParameter=function(e,t,n){if(e&&t&&n){var r=new RegExp("([?&])"+t+"=.*?(&|$)","i"),o=-1!==e.indexOf("?")?"&":"?";return e.match(r)?e.replace(r,"$1"+t+"="+n+"$2"):e+o+t+"="+n}return e}},250:(e,t)=>{function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}t.__esModule=!0,t.default=void 0;var r=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cfg=void 0,this._ws=void 0,this._timer=void 0,this._attempts=1,this._heartbeatInterval=null,this._missedHeartbeats=0,this.isValidOptions(t)&&(this._cfg=Object.assign({},{heartbeatMsg:null,debug:!1,mustReconnect:!0},t),this.connect())}return t=e,o=[{key:"getInstance",value:function(t){return this._instance=this._instance||new e(t),this._instance}}],(r=[{key:"connect",value:function(){try{if(this._ws&&(this.isConnecting()||this.isConnected()))return void(this._cfg.debug&&console.info("Websocket is connecting or already connected."));"function"==typeof this._cfg.connecting&&this._cfg.connecting(),this._cfg.debug&&console.info("Connecting to ".concat(this._cfg.uri," ...")),this._ws=new WebSocket(this._cfg.uri,this._cfg.protocols),this._ws.onopen=this.onOpen.bind(this),this._ws.onmessage=this.onMessage.bind(this),this._ws.onerror=this.onError.bind(this),this._ws.onclose=this.onClose.bind(this),this._timer=null}catch(e){console.error(e),this.tryToReconnect()}}},{key:"isValidOptions",value:function(e){var t=!1;return e?(e.uri||(console.error("Invalid WSClient Uri options."),t=!0),e&&e.connecting&&"function"!=typeof e.connecting&&(console.error("Invalid WSClient connecting options."),t=!0),e&&e.connected&&"function"!=typeof e.connected&&(console.error("Invalid WSClient connected options."),t=!0),e&&e.receiveMessage&&"function"!=typeof e.receiveMessage&&(console.error("Invalid WSClient receiveMessage options."),t=!0),e&&e.disconnected&&"function"!=typeof e.disconnected&&(console.error("Invalid WSClient connecting options."),t=!0),e&&e.heartbeatMsg&&"string"!=typeof e.heartbeatMsg&&(console.error("Invalid WSClient heartbeatMsg options."),t=!0),e&&e.debug&&"boolean"!=typeof e.debug&&(console.error("Invalid WSClient debug options."),t=!0),!t):(console.error("Invalid WSClient options."),t)}},{key:"tryToReconnect",value:function(){if(this._cfg.mustReconnect&&!this._timer){this._cfg.debug&&console.info("Reconnecting...");var e=this.generateInterval(this._attempts);this._timer=setTimeout(this.reconnect.bind(this),e)}}},{key:"reconnect",value:function(){this._attempts++,this.connect()}},{key:"sendHeartbeat",value:function(){try{if(this._missedHeartbeats++,this._missedHeartbeats>3)throw new Error("Too many missed heartbeats.");this._ws.send(this._cfg.heartbeatMsg)}catch(e){clearInterval(this._heartbeatInterval),this._heartbeatInterval=null,this._cfg.debug&&console.warn("Closing connection. Reason: ".concat(e.message)),this.isClosing()||this.isClosed()||this.close()}}},{key:"onOpen",value:function(){this._cfg.debug&&console.info("Connected!"),this._attempts=1,this._cfg.heartbeatMsg&&null===this._heartbeatInterval&&(this._missedHeartbeats=0,this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),5e3)),"function"==typeof this._cfg.connected&&this._cfg.connected()}},{key:"onClose",value:function(e){this._cfg.debug&&console.info("Connection closed!"),"function"==typeof this._cfg.disconnected&&this._cfg.disconnected(e),this.tryToReconnect()}},{key:"onError",value:function(e){this._cfg.debug&&console.error("Websocket connection is broken!"),this._cfg.debug&&console.error(e)}},{key:"onMessage",value:function(e){if(this._cfg.heartbeatMsg&&e.data===this._cfg.heartbeatMsg)this._missedHeartbeats=0;else if("function"==typeof this._cfg.receiveMessage)return this._cfg.receiveMessage(e.data)}},{key:"generateInterval",value:function(e){var t=1e3*(Math.pow(2,e)-1);return t>3e4&&(t=3e4),Math.random()*t}},{key:"sendMessage",value:function(e){this._ws&&this._ws.send(e)}},{key:"getState",value:function(){return this._ws&&this._ws.readyState}},{key:"isConnecting",value:function(){return this._ws&&0===this._ws.readyState}},{key:"isConnected",value:function(){return this._ws&&1===this._ws.readyState}},{key:"isClosing",value:function(){return this._ws&&2===this._ws.readyState}},{key:"isClosed",value:function(){return this._ws&&3===this._ws.readyState}},{key:"close",value:function(){clearInterval(this._heartbeatInterval),this._cfg.mustReconnect=!1,this.isClosing()&&this.isClosed()||(this._ws.close(),this._cfg.debug&&console.error("Websocket closed."))}}])&&n(t.prototype,r),o&&n(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,o}();t.default=r,r._instance=void 0},138:(e,t,n)=>{t.__esModule=!0,t.getHighestSafeWindowContext=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.g.window.self;return t===n.g.window.top||r()?t:e(t.parent)},t.getWindowHeight=function(){return void 0!==n.g.window?n.g.window.innerHeight:0},t.getWindowWidth=function(){return void 0!==n.g.window?n.g.window.innerWidth:0},t.isClientSideRendering=function(){return"undefined"!=typeof window};var r=function(){try{return n.g.window.location.hostname!==n.g.window.parent.location.hostname}catch(e){return!0}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var r={};return(()=>{var e=r;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}e.__esModule=!0;var o=n(153);e.capitalize=o.capitalize,e.isString=o.isString,e.stripHtml=o.stripHtml,e.camelCase=o.camelCase,e.copyTextToClipboard=o.copyTextToClipboard,e.fallbackCopyTextToClipboard=o.fallbackCopyTextToClipboard,e.random=o.random,e.slugify=o.slugify;var i=n(449);e.isValidUrl=i.isValidUrl,e.isValidUrls=i.isValidUrls,e.urlReplacer=i.urlReplacer,e.getDomain=i.getDomain,e.appendURLSearchParams=i.appendURLSearchParams,e.urlB64ToUint8Array=i.urlB64ToUint8Array,e.getQueryStringParameter=i.getQueryStringParameter,e.updateQueryStringParameter=i.updateQueryStringParameter;var a=n(138);e.getHighestSafeWindowContext=a.getHighestSafeWindowContext,e.getWindowWidth=a.getWindowWidth,e.getWindowHeight=a.getWindowHeight,e.isClientSideRendering=a.isClientSideRendering;var s=n(378);e.mergeDeep=s.mergeDeep,e.isObject=s.isObject,e.objectWithoutProperties=s.objectWithoutProperties,e.isFunc=s.isFunc;var c=n(829);e.isInteger=c.isInteger;var l=n(615);e.arraysEqual=l.arraysEqual,e.groupBy=l.groupBy,e.sortByAttr=l.sortByAttr;var u=n(391);e.loadVersionBrowser=u.loadVersionBrowser,e.iOS=u.iOS;var f=n(925);e.LocalStorageDB=f.LocalStorageDB;var h=v(n(614));e.LRUCache=h.default,e.LruCache=h.LruCache,e.LruCacheType=h.LruCacheType,e.CacheStrategies=h.CacheStrategies;var d=n(184);e.Logger=d.Logger;var g=v(n(250));e.WSClient=g.default,e.WSClientType=g.WSClientType,e.WSClientPropTypes=g.WSClientPropTypes;var p=n(501);function y(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(y=function(e){return e?n:t})(e)}function v(e,n){if(!n&&e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return{default:e};var r=y(n);if(r&&r.has(e))return r.get(e);var o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var s=i?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(o,a,s):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}e.resizeImage=p.resizeImage})(),r})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfcommunity/utils",
3
- "version": "0.2.63",
3
+ "version": "0.2.64-alpha.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "./lib/cjs/index.js",
@@ -87,7 +87,6 @@
87
87
  "tslib": "^2.6.2",
88
88
  "typescript": "^4.1.3",
89
89
  "webpack": "^5.20.1",
90
- "webpack-atoms": "^17.1.0",
91
90
  "webpack-bundle-analyzer": "^4.9.0",
92
91
  "webpack-cli": "^4.5.0"
93
92
  },
@@ -101,5 +100,5 @@
101
100
  "bugs": {
102
101
  "url": "https://github.com/selfcommunity/community-js/issues"
103
102
  },
104
- "gitHead": "f49f158891c084b84b384a5e522ac07570e2fb92"
103
+ "gitHead": "d1e76de34050080cff753b4419d7c8b85d31c75d"
105
104
  }