@salla.sa/base 2.12.47 → 3.0.0

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.
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("store/src/store-engine"),t=require("store/storages/localStorage"),r=require("store/storages/sessionStorage"),i=require("store/storages/cookieStorage"),s=require("store/storages/memoryStorage"),n=require("eventemitter2"),o=require("universal-cookie");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var l=c(e),u=c(t),g=c(r),h=c(i),p=c(s),d=a(o);function f(e,t,r){if(!e)return;let i=e,s=t.split("."),n=s.length;for(let e=0;e<n-1;e++){let t=s[e];i[t]||(i[t]={}),i=i[t]}return i[s[n-1]]=r,e}function m(e,t,r){if(!e)return r;let i=function(e,t,r){if(!e||"object"!=typeof e)return r;const i=Array.isArray(t)?t:t.split(".");let s=e;for(const e of i)if(s=s[e],void 0===s)return r;return s}(e,t);return void 0!==i?i:r}function y(){return"object"==typeof document}class b{default_properties;properties_;static instance;constructor(e={},t={}){this.default_properties=t,this.properties_={...this.default_properties,...e}}static getInstance(e={},t={}){return b.instance||(b.instance=new b(e,t)),b.instance}merge(e){return this.properties_={...this.properties_,...e},this.properties_.store={...this.default_properties?.store||{},...this.properties_.store},this}set(e,t){return e.includes(".")?(f(this.properties_,e,t),this):(this.properties_[e]=t,this)}currency(e){return e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}get(e,t=null){return e.includes(".")?m(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}all(){return this.properties_}isDebug(){return this.get("debug")}isGuest(){return"user"!==this.get("user.type")}isUser(){return"user"===this.get("user.type")}}class w{c=console;config;_proxy;historyData=[];get proxy(){return this._proxy}constructor(e=console){this.c=e,this.config=b.getInstance(),this._proxy={log:(e,t)=>{if(!this.config.isDebug())return;this.historyData.push([t,e]),"trace"===this.config.get("debug")&&(t="trace");let r=this.c.log,i=t?r:this.proxy.__dict__[t]||r,s=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],n={event:"#CFF680",backend:"#7b68ee",trace:"#f9f9f9",debug:"#f9f9f9",info:"#f9f9f9",warn:"#f9f9f9",error:"#f9f9f9",history:"#f9f9f9"}[t];n&&(s[0]+="%c"+t.substring(0,1).toUpperCase()+t.substring(1),s.push(`margin-left: 5px;color: ${n};font-weight:bold; border:1px solid ${n}; padding: 2px 6px; border-radius: 5px;`)),i.call(this.c,...s.concat(...e))},__dict__:{trace:this.c.trace,debug:this.c.debug,info:this.c.info,warn:this.c.warn,error:this.c.error}}}event(...e){this.proxy.log(e,"event")}trace(...e){this.proxy.log(e,"trace")}debug(...e){this.proxy.log(e,"debug")}info(...e){this.proxy.log(e,"info")}warn(...e){this.proxy.log(e,"warn")}error(...e){this.proxy.log(e,"error")}log(...e){this.proxy.log(e,"")}backend(...e){this.proxy.log(e,"backend")}logs(e){[e].flat().forEach((e=>e&&this.proxy.log([e].flat(),"backend")))}history(){return this.historyData}}class v extends n.EventEmitter2{delimiter;loggableEvents;ignoreLogEvents;nonFireableActions;static instance;logger=new w;constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.delimiter="::",this.loggableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ignoreLogEvents=["document::click","document::keyup","document::change"],this.nonFireableActions=["document.request"]}static getInstance(){return v.instance||(v.instance=new v),v.instance}createAndDispatch(e,...t){this.dispatch(e,...t)}emit(e,...t){return super.emit(e,...t),this.trackEvents(e,...t),!0}emitAsync(e,...t){const r=super.emitAsync(e,...t);try{this.trackEvents(e,...t)}catch(r){this.logger.warn(`error on tracking event (${String(e)})`,t,r)}return r}trackEvents(e,...t){if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];let r={event:e};t.map((e=>"object"==typeof e&&(r={...r,...e}))),window.dataLayer.push(r)}catch(e){this.logger.error(e.message)}(Array.isArray(e)?e.filter((e=>this.ignoreLogEvents.includes(e))):this.ignoreLogEvents.includes(e))||this.logger.event(e,...t),this.dispatchMobileEvent(e,t)}dispatch(e,...t){return this.emit(e,...t)}dispatchEvents(e){if(e)if("object"!=typeof e||Array.isArray(e))this.logger.log("Events object is wrong, it should be object of {event:payload}",e);else for(const[t,r]of Object.entries(e))this.dispatch(t,r);else this.logger.log("No Events To Dispatch!",e)}listen(e,t){return this.on(e,t)}dispatchMobileEvent(e,t={}){if("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp)if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){this.logger.log(e,"The native context does not exist yet")}else if(window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){this.logger.log(e,"The native context does not exist yet")}}}const x=[u,g,h,p],_=l.createStore(x,[],"salla");class E{static instance;store;constructor(){this.store=_;let e=v.getInstance();e.on("storage::item.remove",(e=>this.remove(e))),e.on("storage::item.set",((e,t)=>this.set(e,t)))}static getInstance(){return E.instance||(E.instance=new E),E.instance}set(e,t){if(e.includes(".")){const r=e.split(".")[0],i=f({[r]:this.store.get(r)},e,t);this.store.set(r,i[r])}else this.store.set(e,t)}remove(e){this.store.remove(e)}clearAll(){this.store.clearAll()}get(e,t){if(e.includes(".")){const t=e.split(".")[0];return m({[t]:this.store.get(t)},e,void 0)}return this.store.get(e,t)}}class $ extends d.default{constructor(){super();let e=v.getInstance();e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}clearAll(){y()&&"string"==typeof document.cookie&&document.cookie.split(";").forEach((function(e){document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")}));const e=this.getAll();for(let t in e)this.remove(t)}}const A=new w,S=b.getInstance();function O(e,t=!1){e=String(e);const r=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],s=(t=t||!S.get("store.settings.arabic_numbers_enabled"))?r:i,n=t?i:r;let o;for(let t=0;t<s.length;t++)o=new RegExp(s[t],"g"),e=e.replace(o,n[t]);return e.replace(t?"٫":".",t?".":"٫")}function k(e){return O(e,!0).replace(/[^0-9.]/g,"").replace("..",".").replace(/\.$/,"")}function D(e){const t=(`${e}`.match(/\./g)||[]).length;return t&&1!==t?D(e.replace(/\.(.+)\./g,".$1")):e}var L={number:O,digitsOnly:k,inputDigitsOnly:function e(t,r=!1){if(!y())return;if("string"==typeof t)return void document.querySelectorAll(t).forEach((t=>e(t,r)));if(!t)return void A.warn("Can't find Object With Id: "+t);let i=k(t.value);t.min&&parseInt(i)<parseInt(t.min)?t.value=t.min:t.max&&parseInt(i)>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&i.length>t.maxLength?t.value=i.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?D(i):i.replace(/\D/g,"")},getOnlyDecimal:D,money:function(e){const t=S.currency(e.currency).symbol;return O(e="object"==typeof e?e.amount:e)+" "+t}};class j{config;constructor(){this.config=b.getInstance()}isFullUrl(e){return e.startsWith("https://")||e.startsWith("http://")}getBase(e){if(this.isFullUrl(e))return e;const{hostname:t}=new URL(this.get("/"));return`https://${t}/${e?.ltrim("/")}`}get(e){if(this.isFullUrl(e))return e;let t=this.config.get("store.url");return!t&&y()&&(t=window.location.href.split("/").slice(0,-1).join("/"),this.config.set("store.url",t)),`${t.rtrim("/")}/${e?.ltrim("/")}`}getDomain(e){return this.isFullUrl(e)?e:`${this.config.get("store.url",(y()?window.location.href:"").split("/").slice(0,-1).join("/")).rtrim("/")}/${e?.ltrim("/")}`}static addParamToUrl(e,t,r){if(!r)return"";if(!t||!e)return r;const i=new RegExp(`([?&])${e}=[^&]+[&]?`,"g");return(r=r.replace(i,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",`${r}${e}=${encodeURIComponent(t)}`.replace(/&$|\?$/,"")}baseUrl(e){return`${y()?window.location.origin:"http://localhost"}/${e?.ltrim("/")}`}asset(e){return this.isFullUrl(e)?e:this.config.get("theme.assets")?this.config.get("theme.assets").replace(":path",e?.ltrim("/")):this.baseUrl(`themes/${this.config.get("theme.name")}/${e?.ltrim("/")}`)}cdn(e){return`https://cdn.salla.network/${e?.ltrim("/")}`}api(e){return`${this.config.get("store.api",this.get(""))?.rtrim("/")}/${e?.ltrim("/")}`}isPage(e){return!!e&&this.config.get("page.slug")===e}isPlaceholder(e){return this.asset(this.config.get("theme.settings.placeholder"))===this.asset(e)}isAValidUrl(e){try{return new URL(e),!0}catch(e){return!1}}}function I(e,t,r){let i=e[0];return r&&0===e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=I(e.slice(1),t,r[i]),r):i?{[i]:I(e.slice(1),t)}:""===i?[t]:t}var U={digitsOnly:L.digitsOnly,inputDigitsOnly:L.inputDigitsOnly,number:L.number,money:L.money,getOnlyDecimal:L.getOnlyDecimal,setNested:f,getNested:m,getInputDataWithName:function(e,t,r={}){if(e.includes("[")){let i=e.split("]").join("").split("[");return{name:i[0],value:I(i.slice(1),t,r[i[0]])}}return{name:e,value:t}},hasDocument:y,url:new j,addParamToUrl:j.addParamToUrl,debounce:function(e,t){t=t||100;let r,i=[];return function(...s){return clearTimeout(r),r=setTimeout((()=>{let t=e(...s);i.forEach((e=>e(t))),i=[]}),t),new Promise((e=>i.push(e)))}}};String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(e=>e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){let r,i=this;for(let s=0;s<e.length;s++)r=new RegExp(e[s],"g"),i=i.replace(r,t[s]);return i},String.prototype.rtrim=function(e="\\s"){return this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e="\\s"){return this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return L.digitsOnly(this)};const C={Config:b,Logger:w,helpers:U,Emitter:v,Storage:E,SallaCookies:$,url:new j,log:(new w).log,money:U.money,error:(new w).error,isDebug:()=>b.getInstance().get("debug")||E.getInstance().get("debug"),status:"base",versions:{base:"[VI]{version}[/VI]"}};exports.default=C;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/helpers/utils.ts","../../src/config.ts","../../src/logger.ts","../../src/event.ts","../../src/storage.ts","../../src/cookie.ts","../../src/helpers/numbers.ts","../../src/helpers/url.ts","../../src/helpers/index.ts","../../src/helpers/string.ts","../../src/index.ts"],"sourcesContent":["// import { get } from \"lodash\";\n\n/**\n * Retrieves the value at the specified nested path of an object.\n * If the value does not exist, it returns a default value.\n * @param object - The object to extract value from.\n * @param path - The path to the desired value, can be either a string with dot notation or an array of keys.\n * @param defaultValue - The default value to return if the desired value does not exist.\n * @returns The value at the specified path or the default value if it does not exist.\n */\nexport function get(object: any, path: string | string[], defaultValue?: any): any {\n\t// If object is null, undefined or not an object, return the default value\n\tif (!object || typeof object !== 'object') {\n\t return defaultValue;\n\t}\n \n\t// Convert path to an array if it's a string with dot notation\n\tconst keys = Array.isArray(path) ? path : path.split('.');\n\tlet result = object;\n \n\t// Traverse through the keys to get the desired value\n\tfor (const key of keys) {\n\t result = result[key];\n \n\t // If the desired value does not exist, return the default value\n\t if (typeof result === 'undefined') {\n\t\treturn defaultValue;\n\t }\n\t}\n \n\treturn result;\n }\n\n/**\n * Sets the value of a nested property in an object.\n * @param object - The object to set the nested property in.\n * @param key - The key of the nested property, specified in dot notation (e.g. \"foo.bar\").\n * @param value - The value to set for the nested property.\n * @returns The modified object.\n */\nexport function setNested(object: any, key: string, value: any): any {\n\tif (!object) return;\n\n\tlet schema: any = object;\n\tlet keys: string[] = key.split(\".\");\n\tlet len: number = keys.length;\n\n\tfor (let i = 0; i < len - 1; i++) {\n\t\tlet elem: string = keys[i] as string;\n\t\tif (!schema[elem]) schema[elem] = {};\n\t\tschema = schema[elem];\n\t}\n\n\tschema[keys[len - 1]!] = value;\n\treturn object;\n}\n\n/**\n * Gets the value of a nested property in an object, or a default value if the property is undefined.\n * @param object - The object to get the nested property from.\n * @param key - The key of the nested property, specified in dot notation (e.g. \"foo.bar\").\n * @param default_ - The default value to return if the nested property is undefined.\n * @returns The value of the nested property, or the default value if undefined.\n */\nexport function getNested(object: any, key: string, default_: any): any {\n\tif (!object) return default_;\n\n\tlet data: any = get(object, key);\n\treturn data !== undefined ? data : default_;\n}\n\nexport function hasDocument() {\n\treturn typeof document === 'object';\n}","/**\n * @namespace Salla.config\n *\n * @property {any} properties_\n */\n\nimport ConfigAbstract from \"../types/config\"\nimport {Currency} from \"../types/common\"\nimport {getNested, setNested} from \"./helpers/utils\";\n\nclass Config implements ConfigAbstract {\n\n\t/**\n / Default properties for the configuration\n\t */\n\tdefault_properties: object | any;\n\n\t/**\n\t * Current properties for the configuration\n\t */\n\tproperties_: object | any;\n\n\tprivate static instance: Config;\n\n\t/**\n\t * Creates an instance of Config.\n\t * @param {object} properties - Current properties for the configuration\n\t * @param {object} default_properties - Default properties for the configuration\n\t */\n\tprivate constructor(properties: object = {}, default_properties: object = {},) {\n\t\tthis.default_properties = default_properties;\n\t\tthis.properties_ = {...this.default_properties, ...properties};\n\t}\n\n\tpublic static getInstance(properties: object = {}, default_properties: object = {}): Config {\n\t\tif (!Config.instance) {\n\t\t\tConfig.instance = new Config(properties, default_properties);\n\t\t}\n\t\treturn Config.instance;\n\t}\n\n\t/**\n\t * Merge the provided configuration into the current properties.\n\t * @param {object} config - Configuration to merge\n\t * @returns {Config} - Reference to the current Config instance\n\t */\n\tmerge(config: object): this {\n\t\tthis.properties_ = {...this.properties_, ...config};\n\t\tthis.properties_.store = {...(this.default_properties?.store || {}), ...this.properties_.store};\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a key-value pair in the configuration.\n\t * @param {string} key - Key to set\n\t * @param {any} value - Value to set\n\t * @returns {Config} - Reference to the current Config instance\n\t */\n\tset(key: string, value: any): this {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tsetNested(this.properties_, key, value);\n\t\t\treturn this;\n\t\t}\n\t\tthis.properties_[key] = value;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the currency information for the given ISO code or user's currency code.\n\t * @param {string} isoCode - ISO code of the currency (optional)\n\t * @returns {Currency} - Currency object\n\t */\n\tcurrency(isoCode?: string): Currency {\n\t\tisoCode = isoCode || this.get('user.currency_code');\n\t\treturn this.get('currencies.' + isoCode) || Object.values(this.get('currencies'))[0];\n\t}\n\n\n\tget(key: string, default_: null | any = null): any {\n\t\tif (key.includes(\".\")) {\n\t\t\treturn getNested(this.properties_, key, default_);\n\t\t}\n\t\treturn this.properties_.hasOwnProperty(key) ? this.properties_[key] || default_ : default_ || undefined;\n\t}\n\n\tall(): object | any {\n\t\treturn this.properties_;\n\t}\n\n\tisDebug(): boolean {\n\t\treturn this.get('debug');\n\t}\n\n\tisGuest(): boolean {\n\t\treturn this.get('user.type') !== 'user';\n\t}\n\n\tisUser(): boolean {\n\t\treturn this.get('user.type') === 'user';\n\t}\n\n}\n\nexport default Config;","import SallaConfig from \"../types/config\";\nimport Config from \"../src/config\"\n\n/**\n * A logger to help us to use Salla.logger.log like console.log\n *\n * @namespace Salla.logger\n *\n * @credits @Ammar Hasan\n * @see https://stackoverflow.com/a/21856736\n *\n */\n\ntype ProxyType = {\n\tlog(a: any[], type: string): void;\n\t// __dict__: {\n\t// \twarn: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \ttrace: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \tdebug: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \terror: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \tinfo: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void }\n\t// }\n\t__dict__: { [p: string]: any }\n};\n\nexport default class Logger {\n\n\tprivate c = console;\n\tprivate config: SallaConfig;\n\tprivate _proxy: ProxyType;\n\tprivate historyData: any[] = [];\n\n\tget proxy(): ProxyType {\n\t\treturn this._proxy;\n\t}\n\n\tconstructor(cons = console) {\n\t\tthis.c = cons;\n\t\tthis.config = Config.getInstance();\n\t\tthis._proxy = {\n\t\t\tlog: (a, type) => {\n\t\t\t\tif (!this.config.isDebug()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.historyData.push([type, a]);\n\n\t\t\t\t// let's force trace for all logs when the debug is trace level\n\t\t\t\tif (this.config.get('debug') === 'trace') {\n\t\t\t\t\ttype = 'trace';\n\t\t\t\t}\n\t\t\t\tlet colorableTypes: { [key: string]: any } = {\n\t\t\t\t\t\"event\": '#CFF680',\n\t\t\t\t\t\"backend\": '#7b68ee',\n\t\t\t\t\t\"trace\": '#f9f9f9',\n\t\t\t\t\t\"debug\": '#f9f9f9',\n\t\t\t\t\t\"info\": '#f9f9f9',\n\t\t\t\t\t\"warn\": '#f9f9f9',\n\t\t\t\t\t\"error\": '#f9f9f9',\n\t\t\t\t\t\"history\": '#f9f9f9'\n\t\t\t\t};\n\n\t\t\t\tlet l = this.c.log,\n\t\t\t\t f = !!type ? l : (this.proxy.__dict__[type] || l);\n\n\t\t\t\tlet style = ['%cTwilight', 'color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;'];\n\t\t\t\tlet color = colorableTypes[type];\n\t\t\t\tif (color) {\n\t\t\t\t\tstyle[0] += '%c' + type.substring(0,1).toUpperCase() + type.substring(1);\n\t\t\t\t\tstyle.push(`margin-left: 5px;color: ${color};font-weight:bold; border:1px solid ${color}; padding: 2px 6px; border-radius: 5px;`)\n\t\t\t\t}\n\n\t\t\t\tf.call(this.c, ...style.concat(...a))\n\t\t\t},\n\t\t\t__dict__: {\n\t\t\t\t\"trace\": this.c.trace,\n\t\t\t\t\"debug\": this.c.debug,\n\t\t\t\t\"info\": this.c.info,\n\t\t\t\t\"warn\": this.c.warn,\n\t\t\t\t\"error\": this.c.error\n\t\t\t} as { [key: string]: any }\n\t\t};\n\t}\n\n\tevent(...args: any[]) {\n\t\tthis.proxy.log(args, \"event\");\n\t}\n\n\ttrace(...args: any[]) {\n\t\tthis.proxy.log(args, \"trace\");\n\t}\n\n\tdebug(...args: any[]) {\n\t\tthis.proxy.log(args, \"debug\");\n\t}\n\n\tinfo(...args: any[]) {\n\t\tthis.proxy.log(args, \"info\");\n\t}\n\n\twarn(...args: any[]) {\n\t\tthis.proxy.log(args, \"warn\");\n\t}\n\n\terror(...args: any[]) {\n\t\tthis.proxy.log(args, \"error\");\n\t}\n\n\tlog(...args: any[]) {\n\t\tthis.proxy.log(args, '');\n\t}\n\n\t//use this to pass messages from backEnd, no need to add documentations, because it will no passed in production\n\tbackend(...args: any[]) {\n\t\tthis.proxy.log(args, \"backend\");\n\t}\n\n\t//this for internal usage to pass multi logs using one function, no need to add it to documentation @see \\Salla\\Core\\Traits\\WithStageLogger::debug\n\tlogs(logs: any[]) {\n\t\t//@ts-ignore\n\t\t[logs].flat().forEach(logData => logData && this.proxy.log([logData].flat(), 'backend'));\n\t}\n\n\thistory() {\n\t\treturn this.historyData;\n\t}\n}","import {\n\tevent as EventType,\n\tEventAndListener,\n\tEventEmitter2,\n\teventNS,\n\tListener,\n\tListenerFn,\n\tOnOptions,\n} from 'eventemitter2';\nimport Logger from './logger';\nimport EmitterInterface, {typeSafeEvents} from \"../types/event\"\n\n/**\n * @namespace Salla.event\n *\n * @property {string} delimiter\n * @property {array} loggableEvents - log errors or important events.\n */\nexport default class Emitter extends EventEmitter2 implements EmitterInterface {\n\tdelimiter: string;\n\tloggableEvents: string[];\n\tignoreLogEvents: string[];\n\tnonFireableActions: string[];\n\n\tprivate static instance: Emitter;\n\n\tlogger = new Logger();\n\n\tprivate constructor() {\n\t\tconst delimiter = '::';\n\t\tsuper({\n\t\t\twildcard: true,\n\t\t\tdelimiter,\n\t\t\tnewListener: false,\n\t\t\tremoveListener: false,\n\t\t\tmaxListeners: 10,\n\t\t\tverboseMemoryLeak: false,\n\t\t\tignoreErrors: false,\n\t\t});\n\t\tthis.delimiter = delimiter;\n\n\t\tthis.loggableEvents = ['cart::item.added.failed', 'cart::item.deleted.failed'];\n\n\t\tthis.ignoreLogEvents = [\n\t\t\t'document::click',\n\t\t\t'document::keyup',\n\t\t\t'document::change',\n\t\t\t//'document::submit',\n\t\t];\n\n\t\tthis.nonFireableActions = ['document.request'];\n\t}\n\n\tpublic static getInstance(): Emitter {\n\t\tif (!Emitter.instance) {\n\t\t\tEmitter.instance = new Emitter();\n\t\t}\n\t\treturn Emitter.instance;\n\t}\n\n\t/**\n\t * @param {string} event_name\n\t * @param data\n\t *\n\t * @deprecated , legacy code, use dispatch() instead\n\t */\n\tcreateAndDispatch<Event extends string | symbol>(event_name: Event | Event[], ...data: any): void {\n\t\tthis.dispatch(event_name, ...data);\n\t}\n\n\temit<Event extends string | symbol>(event: Event | Event[], ...data: any): boolean {\n\t\t/**\n\t\t * if the event, is api/event method, call it,\n\t\t * ex: cart::quick.add call Salla.api.cart.quickAdd(...data)\n\t\t * we don't used Salla.call(actionName)(...data), to avoid losing this scope in our apis.\n\t\t *\n\t\t * @deprecated don't use it anymore\n\t\t */\n\t\tsuper.emit(event, ...data);\n\t\tthis.trackEvents(event, ...data);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Return the results of the listeners via Promise.all.\n\t * Only this method doesn't work IE.\n\t * @param event_name\n\t * @param data\n\t */\n\temitAsync<Event extends string | symbol>(event_name: Event | Event[], ...data: any): any {\n\t\t// to make sure that data object will not be affected by track process\n\t\tconst result = super.emitAsync(event_name, ...data);\n\t\ttry {\n\t\t\tthis.trackEvents(event_name, ...data);\n\t\t} catch (e) {\n\t\t\tthis.logger.warn(`error on tracking event (${String(event_name)})`, data, e);\n\t\t}\n\t\treturn result;\n\t}\n\n\ttrackEvents<Event extends string | symbol>(event_name: Event | Event[], ...data: any): void {\n\t\t// let's send the event to data layer\n\t\tif (typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\twindow.dataLayer = window.dataLayer || [];\n\t\t\t\t/**\n\t\t\t\t * data is coming as an array like this:\n\t\t\t\t * [{\"services\": {\"intercom\": {\"app_id\": \"***\"}}}]\n\t\t\t\t * we will merge itf into one object like this:\n\t\t\t\t * {event: event_name, \"services\": {\"intercom\": {\"app_id\": \"***\"}}}\n\t\t\t\t */\n\t\t\t\tlet dataLayerObject = {event: event_name};\n\t\t\t\tdata.map((item: any) => typeof item === 'object' && (dataLayerObject = {...dataLayerObject, ...item}));\n\t\t\t\twindow.dataLayer.push(dataLayerObject);\n\t\t\t} catch (e: any) {\n\t\t\t\tthis.logger.error(e.message);\n\t\t\t}\n\t\t}\n\n\t\t// if there is need to log errors, or events, lets do it here.\n\t\tif (Array.isArray(event_name) ? !event_name.filter((item) => this.ignoreLogEvents.includes(item as string)) : !this.ignoreLogEvents.includes(event_name as string)) {\n\t\t\tthis.logger.event(event_name, ...data);\n\t\t}\n\t\tthis.dispatchMobileEvent(event_name, data);\n\t}\n\n\t/**\n\t * Fire Event with data\n\t *\n\t * @param {string} event_name - action name like `cart::addItem` or event name like `cart::item.added`\n\t * @param {any|undefined} data\n\t * @data {{payload}} data\n\t */\n\tdispatch<Event extends string | symbol>(event_name: Event | Event[], ...data: any): boolean {\n\t\treturn this.emit(event_name, ...data);\n\t}\n\n\t/**\n\t * Fire multi events using object of events\n\t *\n\t * @param {Object.<string, *>} events\n\t */\n\tdispatchEvents(events: { [key: string]: any }): void {\n\t\tif (!events) {\n\t\t\tthis.logger.log('No Events To Dispatch!', events);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof events !== 'object' || Array.isArray(events)) {\n\t\t\tthis.logger.log('Events object is wrong, it should be object of {event:payload}', events);\n\t\t\treturn;\n\t\t}\n\n\t\t//@ts-ignore\n\t\tfor (const [event_name, payload] of Object.entries(events)) {\n\t\t\tthis.dispatch(event_name, payload);\n\t\t}\n\t}\n\n\t/**\n\t * Alias for this.addListener\n\t * @param {string} eventName\n\t * @param {function} callback\n\t */\n\tlisten(eventName: EventType | eventNS, callback: ListenerFn): this | Listener {\n\t\treturn this.on(eventName, callback);\n\t}\n\n\t/**\n\t * This help to push an event to mobile app.\n\t *\n\t * @param eventName\n\t * @param details\n\t * @returns {string}\n\t */\n\tdispatchMobileEvent<Event extends string | symbol>(eventName: Event | Event[], details = {}): void {\n\t\tif (\n\t\t typeof window === 'undefined' ||\n\t\t !window.dataLayer ||\n\t\t !window.dataLayer[0] ||\n\t\t !window.dataLayer[0].page ||\n\t\t !window.dataLayer[0].page.mobileApp\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!!window.webkit) {\n\t\t\ttry {\n\t\t\t\twindow.webkit.messageHandlers.callbackHandler.postMessage(\n\t\t\t\t JSON.stringify({\n\t\t\t\t\t event: eventName,\n\t\t\t\t\t details: details,\n\t\t\t\t })\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tthis.logger.log(err, 'The native context does not exist yet');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!!window.Android) {\n\t\t\ttry {\n\t\t\t\twindow.Android.customEventWithData(eventName, JSON.stringify({details: details}));\n\t\t\t} catch (err) {\n\t\t\t\tthis.logger.log(err, 'The native context does not exist yet');\n\t\t\t}\n\t\t}\n\t}\n}","import * as createStore from \"store/src/store-engine\"\nimport * as localStorage from \"store/storages/localStorage\"\nimport * as sessionStorage from \"store/storages/sessionStorage\"\nimport * as cookieStorage from \"store/storages/cookieStorage\"\nimport * as memoryStorage from \"store/storages/memoryStorage\"\nimport {getNested, setNested} from \"./helpers/utils\"\nimport Emitter from \"./event\";\n\n// Define storage engines\nconst storageEngines: any[] = [\n\tlocalStorage,\n\tsessionStorage,\n\tcookieStorage,\n\tmemoryStorage,\n];\n\n// Create the store engine with the storage engines and the namespace\nconst localStore = createStore.createStore(storageEngines, [], \"salla\");\n\nexport default class Storage {\n\tprivate static instance: Storage;\n\tstore: typeof localStore;\n\n\tprivate constructor() {\n\t\tthis.store = localStore;\n\n\t\tlet sallaEvent = Emitter.getInstance();\n\t\tsallaEvent.on(\"storage::item.remove\", (key) => this.remove(key));\n\t\tsallaEvent.on(\"storage::item.set\", (key, value) => this.set(key, value));\n\t}\n\n\tpublic static getInstance(): Storage {\n\t\tif (!Storage.instance) {\n\t\t\tStorage.instance = new Storage();\n\t\t}\n\t\treturn Storage.instance;\n\t}\n\n\tpublic set(key: string, value: any): void {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tconst firstKey: string = key.split(\".\")[0] as string;\n\t\t\tconst parentObject = {[firstKey]: this.store.get(firstKey)};\n\t\t\tconst updatedParentObject = setNested(parentObject, key, value);\n\t\t\tthis.store.set(firstKey, updatedParentObject[firstKey]);\n\t\t} else {\n\t\t\tthis.store.set(key, value);\n\t\t}\n\t}\n\n\tpublic remove(key: string): void {\n\t\tthis.store.remove(key);\n\t}\n\n\tpublic clearAll(): void {\n\t\tthis.store.clearAll();\n\t}\n\n\tpublic get(key: string, value?: any): any {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tconst firstKey: string = key.split(\".\")[0] as string;\n\t\t\treturn getNested({[firstKey]: this.store.get(firstKey)}, key, undefined);\n\t\t} else {\n\t\t\treturn this.store.get(key, value);\n\t\t}\n\t}\n}","import Cookies from \"universal-cookie\";\nimport { hasDocument } from \"./helpers/utils\";\nimport Emitter from \"./event\";\n\nexport default class SallaCookies extends Cookies {\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet sallaEvent = Emitter.getInstance();\n\t\tsallaEvent.on(\"cookies::remove\", (key) => this.remove(key));\n\t\tsallaEvent.on(\"cookies::add\", (key, value) => this.set(key, value));\n\t}\n\n\tclearAll() {\n\t\tif (hasDocument() && typeof document.cookie === 'string')\n\t\t\tdocument.cookie.split(';').forEach(function (c) {\n\t\t\t\tdocument.cookie = c\n\t\t\t\t\t.replace(/^ +/, '')\n\t\t\t\t\t.replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');\n\t\t\t});\n\t\tconst allCookies = this.getAll();\n\t\tfor (let cookieName in allCookies) {\n\t\t\tthis.remove(cookieName);\n\t\t}\n\t}\n}","import { Price } from \"../../types/common\";\nimport SallaConfig from \"../../types/config\";\nimport LoggerType from \"../../types/logger\";\n\nimport Logger from \"../logger\";\nimport Config from \"../config\"\nimport { hasDocument } from \"./utils\";\n\nconst sallaLogger = new Logger();\nconst config = Config.getInstance();\n\n\n/**\n * Converts a number to a string and replaces Arabic numerals with English numerals.\n * @param num - The number to convert.\n * @param isToEnglish - Whether to convert Arabic numerals to English numerals.\n * @returns The converted number as a string.\n */\nfunction number(num: number | string, isToEnglish = false): string {\n\tnum = String(num); // make sure that number will be converted to string.\n\tisToEnglish =\n\t\tisToEnglish ||\n\t\t!config.get(\"store.settings.arabic_numbers_enabled\");\n\tconst ar = [\"٠\", \"١\", \"٢\", \"٣\", \"٤\", \"٥\", \"٦\", \"٧\", \"٨\", \"٩\"];\n\tconst en = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\tconst find = isToEnglish ? ar : en;\n\tconst replace = isToEnglish ? en : ar;\n\tlet regex;\n\tfor (let i = 0; i < find.length; i++) {\n\t\t//@ts-ignore\n\t\tregex = new RegExp(find[i], \"g\");\n\t\t//@ts-ignore\n\t\tnum = (num as String).replace(regex, replace[i]);\n\t}\n\t// todo: replace dots between two digits only, to avoid replacing the period.\n\treturn (num as String).replace(isToEnglish ? \"٫\" : \".\", isToEnglish ? \".\" : \"٫\");\n}\n\nfunction digitsOnly(num: string): string {\n\treturn number(num, true)\n\t\t.replace(/[^0-9.]/g, \"\")\n\t\t.replace(\"..\", \".\")\n\t\t.replace(/\\.$/, \"\"); // without this: `Salla.helpers.digitsOnly('١٬٦٠٠ ر.س')` => `1600`\n}\n\nfunction inputDigitsOnly(input: HTMLInputElement | string, is_decimal = false): void {\n\tif (!hasDocument()) return;\n\tif (typeof input === \"string\") {\n\t\tdocument\n\t\t\t.querySelectorAll(input)\n\t\t\t.forEach((el) => inputDigitsOnly(el as HTMLInputElement, is_decimal));\n\t\treturn;\n\t}\n\tif (!input) {\n\t\tsallaLogger.warn(\"Can't find Object With Id: \" + input);\n\t\treturn;\n\t}\n\tlet new_val = digitsOnly(input.value);\n\tif (input.min && parseInt(new_val) < parseInt(input.min)) {\n\t\tinput.value = input.min;\n\t\treturn;\n\t}\n\tif (input.max && parseInt(new_val) > parseInt(input.max)) {\n\t\tinput.value = input.max\n\t\treturn;\n\t}\n\tif (input.maxLength >= 1 && new_val.length > input.maxLength) {\n\t\tinput.value = new_val.toString().substring(0, input.maxLength);\n\t\treturn;\n\t}\n\tinput.value = is_decimal || input.dataset.hasOwnProperty(\"digitsWithDecimal\")\n\t\t? getOnlyDecimal(new_val)\n\t\t: new_val.replace(/\\D/g, \"\");\n}\n\nfunction getOnlyDecimal(value: string): string {\n\tconst dotsCount = (`${value}`.match(/\\./g) || []).length;\n\tif (!dotsCount || dotsCount === 1) {\n\t\treturn value;\n\t}\n\t// if there is more than one dot, remove the last dot.\n\t// Ex: 123.545.66 => 123.54566\n\treturn getOnlyDecimal(value.replace(/\\.(.+)\\./g, \".$1\"));\n}\n\nfunction money(money: string | number | Price): string {\n\tconst currency = config.currency((money as Price).currency).symbol;\n\tmoney =\n\t\ttypeof money === \"object\" ? money.amount : money as unknown as number;\n\treturn number(money) + \" \" + currency;\n}\n\nexport default {\n\tnumber,\n\tdigitsOnly,\n\tinputDigitsOnly,\n\tgetOnlyDecimal,\n\tmoney,\n};","import SallaConfig from \"../../types/config\";\nimport {hasDocument} from \"./utils\";\nimport {UrlHelpers} from \"../../types/helpers\";\n\nimport Config from \"../config\"\n\nexport default class UrlHelper implements UrlHelpers{\n\tconfig: SallaConfig;\n\n\tconstructor() {\n\t\tthis.config = Config.getInstance();\n\t}\n\n\t/**\n\t * Check if the url is a full url.\n\t * @param {string} url - The url to check.\n\t * @returns {boolean} - True if the url is a full url.\n\t */\n\tisFullUrl(url: string): boolean {\n\t\treturn url.startsWith(\"https://\") || url.startsWith(\"http://\");\n\t}\n\n\t/**\n\t * Get the base url for the given url.\n\t * @param {string} url - The url to get the base url for.\n\t * @returns string - The base url for the given url.\n\t */\n\tgetBase(url: string): string {\n\t\tif (this.isFullUrl(url)) {\n\t\t\treturn url;\n\t\t}\n\n\t\tconst {hostname} = new URL(this.get(\"/\"));\n\n\t\treturn `https://${hostname}/${url?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Get the full url for the given path.\n\t * @param {string} path - The path to get the full url for.\n\t * @returns {string} - The full url the given path.\n\t */\n\tget(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\tlet storeUrl = this.config.get(\"store.url\");\n\n\t\tif (!storeUrl && hasDocument()) {\n\t\t\tstoreUrl = window.location.href.split(\"/\").slice(0, -1).join(\"/\");\n\t\t\tthis.config.set(\"store.url\", storeUrl);\n\t\t}\n\n\t\treturn `${storeUrl.rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Get the domain for the given path.\n\t * @param {string} path - The path to get the domain for.\n\t * @returns {string} - The domain for the given path.\n\t */\n\tgetDomain(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\treturn `${this.config.get(\n\t\t \"store.url\",\n\t\t (hasDocument() ? window.location.href : '').split(\"/\").slice(0, -1).join(\"/\")\n\t\t).rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Add a parameter to a URL.\n\t * @param {string} key - The key of the parameter to add.\n\t * @param {string} value - The value of the parameter to add.\n\t * @param {string} [url] - The URL to add the parameter to. Defaults to window.location.href.\n\t * @returns {string} - The URL with the added parameter.\n\t */\n\tstatic addParamToUrl(key: string, value: string, url: any): string {\n\t\t//TODO: check when there is no url param provided (from the clinet side)\n\t\t// for the time being return empty string\n\t\t// url = url;\n\t\tif(!url) return \"\"\n\n\t\t// assuming url is a string type\n\n\t\tif (!value || !key) {\n\t\t\treturn url;\n\t\t}\n\n\t\tconst regex = new RegExp(`([?&])${key}=[^&]+[&]?`, \"g\");\n\n\t\turl = url\n\t\t .replace(regex, \"$1\") //remove old one\n\t\t .split(\"#\")[0] //remove any hash values ex 'https://my_site.test/brands#brand-section-1'\n\t\t .replace(/&$|\\?$/, \"\"); // remove the `?` or `&` if it's the last char\n\n\t\tif (url.includes(\"?\")) {\n\t\t\turl += \"&\";\n\t\t} else {\n\t\t\t//avoid cases like this: 'https://my_store.test/ar?test=hi'\n\t\t\turl += (url.endsWith(\"/\") ? \"\" : \"/\") + \"?\";\n\t\t}\n\n\t\treturn `${url}${key}=${encodeURIComponent(value)}`.replace(/&$|\\?$/, \"\");\n\t}\n\n\t/**\n\t * Get the base URL for a given path without username if it's salla domain ex: Salla.sa/test will ignore test.\n\t * @param {string} path - The path to get the base URL for.\n\t * @returns {string} - The base URL for the given path without username if it's salla domain ex: Salla.sa/test will ignore test.\n\t */\n\tbaseUrl(path: string): string {\n\t\t//TODO: check what to use for SSR\n\t\treturn `${hasDocument() ? window.location.origin : \"http://localhost\"}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns the asset path.\n\t * @param path - The path to the asset.\n\t * @returns The asset path.\n\t */\n\tasset(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\tif (this.config.get(\"theme.assets\")) {\n\t\t\treturn this.config.get(\"theme.assets\").replace(\":path\", path?.ltrim(\"/\"));\n\t\t}\n\n\t\treturn this.baseUrl(`themes/${this.config.get(\"theme.name\")}/${path?.ltrim(\"/\")}`);\n\t}\n\n\t/**\n\t * Returns the CDN path.\n\t * @param path - The path to the CDN.\n\t * @returns The CDN path.\n\t */\n\tcdn(path: string): string {\n\t\treturn `https://cdn.salla.network/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns the API URL.\n\t * @example Salla.url.api('test') => https://my_store.test/api/v1/test\n\t * @param path - The API endpoint.\n\t * @returns The API URL.\n\t */\n\tapi(path: string): string {\n\t\treturn `${this.config.get(\"store.api\", this.get(\"\"))?.rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns whether the page name matches the current page slug.\n\t * @param pageName - The name of the page to check against.\n\t * @returns Whether the page name matches the current page slug.\n\t */\n\tisPage(pageName: string): boolean {\n\t\treturn !!pageName && this.config.get(\"page.slug\") === pageName;\n\t}\n\n\t/**\n\t * Returns whether the URL is a placeholder.\n\t * @param url - The URL to check.\n\t * @returns Whether the URL is a placeholder.\n\t */\n\tisPlaceholder(url: string): boolean {\n\t\treturn this.asset(this.config.get(\"theme.settings.placeholder\")) === this.asset(url);\n\t}\n\n\t/**\n\t * Check if a string is a valid URL or not.\n\t * @param value - url string\n\t * @returns boolean.\n\t */\n\tisAValidUrl(value: string): boolean {\n\t\ttry {\n\t\t\tnew URL(value);\n\t\t\treturn true;\n\t\t} catch (TypeError) {\n\t\t\treturn false;\n\t\t}\n\t}\n}","import NumbersHelper from \"./numbers\";\n\nimport UrlHelper from \"./url\";\nimport {getNested, setNested, hasDocument} from \"./utils\";\n\n/**\n * To use it, you need some moves:\n * 1- First : you should have global variable: `let my_debounce;`\n * 2- Next : make your own function: `function my_debounce_fn(callback,...data){...}`\n * 3- Next : in your method, check if it's not existed yet, use this helper method to create it: `if(!my_debounce){my_debounce=Salla.helpers.debounce((fn, ...inner_data) => fn(...inner_data), 500)}`\n * 4- Next : then delay the passed callback: `my_debounce(callback, ...data);`\n * 5- Finally : use it: `my_debounce(() =>{...yourRepeatableLogic})`\n * will be something like:\n *\n * ```\n * let my_debounce;\n * function my_debounce_fn(callback,...data){\n * if(!my_debounce){\n * // inline method\n * my_debounce=Salla.helpers.debounce((fn, ...inner_data) => fn(...inner_data), 500);\n * }\n * return my_debounce(callback, ...data);\n * }\n * // use it like:\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 1');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 2');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 3');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 4');\n * // output=> `hello there - 4`\n * ```\n * 😎Or just use Salla appHelpers:`app.debounce((my_data)=>Salla.log(my_data), 'hello there - *')`\n *\n * @param fn\n * @param delay\n * @return Promise\n */\nfunction debounce(fn: Function, delay: number): Function {\n\tdelay = delay || 100;\n\tlet resolves: Function[] = [];\n\tlet timer: NodeJS.Timeout;\n\n\treturn function (...args: any[]): Promise<unknown> {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => {\n\t\t\tlet result = fn(...args);\n\t\t\tresolves.forEach((r) => r(result));\n\t\t\tresolves = [];\n\t\t}, delay);\n\t\t//@ts-ignore\n\t\treturn new Promise((r) => resolves.push(r));\n\t};\n}\n\n/**\n * Use It When You want to grab data from input names with brackets Ex.\n * <input name=\"products[0][id]\" value...>\n * <input name=\"products[0][name]\" value...>\n * <input name=\"products[1][id]\" value...>\n * <input name=\"products[1][name]\" value...>\n * will be like: {products:[{id:.., name:..},{id:.., name:..}]}\n * @param name\n * @param value\n * @param dataset\n * @return {name, value}|{name, value: (*|[*, *]|[string, *]|{}|[*])}\n */\nfunction getInputDataWithName(name: string, value: any, dataset: object = {}): object {\n\t//@ts-ignore\n\tif (name.includes(\"[\")) {\n\t\tlet nameLevels = name.split(\"]\").join(\"\").split(\"[\");\n\t\t//@ts-ignore\n\t\treturn {name: nameLevels[0], value: getLabeledData(nameLevels.slice(1), value, dataset[nameLevels[0]])};\n\t}\n\treturn {name: name, value: value};\n}\n\n/**\n * in case input name is array for example \"jamal[4655]\" let's fix it\n * This Helper method to get suitable array data, Ex.\n * jamal[]=1\n * jamal[]=2\n * final result will be: {jamal:[1,2]}\n *\n * @param nameLabels\n * @param value\n * @param existedData\n * @return *[]|*|(string|*)[]|{}\n */\nfunction getLabeledData(nameLabels: string[], value: string | any, existedData: object | undefined): any[] | any {\n\tlet currentName = nameLabels[0];\n\n\t// it's an array, so add value as array\n\tif (existedData && nameLabels.length === 0) {\n\t\tif (Array.isArray(existedData)) {\n\t\t\texistedData.push(value);\n\t\t\treturn existedData;\n\t\t}\n\n\t\t// todo: handle in case it's object\n\t\treturn [existedData, value];\n\t}\n\n\tif (Array.isArray(existedData)) {\n\t\texistedData.push(value);\n\t\treturn existedData;\n\t}\n\n\tif (typeof existedData === \"string\") {\n\t\treturn [existedData, value];\n\t}\n\n\t// it's nested data\n\tif (existedData) {\n\t\t//@ts-ignore\n\t\texistedData[currentName] = getLabeledData(nameLabels.slice(1), value, existedData[currentName]);\n\t\treturn existedData;\n\t}\n\n\tif (currentName) {\n\t\t//@ts-ignore\n\t\treturn {[currentName]: getLabeledData(nameLabels.slice(1), value)};\n\t}\n\n\t// handling \"[]\" without name\n\treturn currentName === \"\" ? [value] : value;\n}\n\n/**\n * @type { debouce: (function(*, *=): function(...[*]): Promise<unknown>), getInputDataWithName: ((function(*=, *=, *): ({name, value}|{name, value: (*|*[]|(string|*)[]|{})}))|*), digitsOnly: ((function(*=, *=): (undefined|*))|*) }}\n */\nexport default {\n\t// Numbers helpers\n\tdigitsOnly: NumbersHelper.digitsOnly,\n\tinputDigitsOnly: NumbersHelper.inputDigitsOnly,\n\tnumber: NumbersHelper.number,\n\tmoney: NumbersHelper.money,\n\tgetOnlyDecimal: NumbersHelper.getOnlyDecimal,\n\n\t// Nested objects helpers\n\tsetNested,\n\tgetNested,\n\tgetInputDataWithName,\n\thasDocument,\n\n\t// Url helpers\n\turl: new UrlHelper(),\n\taddParamToUrl: UrlHelper.addParamToUrl,\n\n\t// other\n\tdebounce,\n};","import NumbersHelper from \"./numbers\";\n\ndeclare global {\n\tinterface String {\n\t\ttoStudlyCase(): string;\n\n\t\ttoDatasetName(): string;\n\n\t\ttoSelector(): string;\n\n\t\treplaceArray(find: string[], replace: string[]): string;\n\n\t\trtrim(s?: string): string;\n\n\t\tltrim(s?: string): string;\n\n\t\tdigitsOnly(): string;\n\t}\n}\n\n/**\n * Convert string to StudlyCase.\n * @returns {string} - The string in StudlyCase.\n */\nString.prototype.toStudlyCase = function (): string {\n\treturn this.trim().replace(/([^a-zA-Z\\d].)/g, (t: string) => {\n\t\treturn t.toUpperCase().replace(/[^a-zA-Z\\d]/g, '');\n\t});\n};\n\n/**\n * Convert a string to dataset name format.\n * @returns {string} - The string in dataset name format.\n */\nString.prototype.toDatasetName = function (): string {\n\t//@ts-ignore\n\treturn this.startsWith('data-')\n\t ? this.substr(5).toStudlyCase()\n\t : this.toStudlyCase();\n};\n\n/**\n * Get string as selector by adding \"#\" to the beginning if it doesn't start with \"#\" or \".\".\n * @returns {string} - The string as a selector.\n */\nString.prototype.toSelector = function (): string {\n\t//@ts-ignore\n\treturn this.trim().startsWith(\".\") || this.trim().startsWith(\"#\")\n\t ? this.toString()\n\t : \"#\" + this.toString();\n};\n\n/**\n * Replace an array of strings with another array of strings.\n * @param {string[]} find - The array of strings to be replaced.\n * @param {string[]} replace - The array of strings to replace with.\n * @returns {string} - The replaced string.\n */\nString.prototype.replaceArray = function (find: string[] | string, replace: string[] | string): string {\n\tlet replaceString = this;\n\tlet regex: RegExp;\n\tfor (let i = 0; i < find.length; i++) {\n\t\t//@ts-ignore\n\t\tregex = new RegExp(find[i], \"g\");\n\t\t//@ts-ignore\n\t\treplaceString = replaceString.replace(regex, replace[i]);\n\t}\n\t//@ts-ignore\n\treturn replaceString;\n};\n\n/**\n * Remove trailing spaces from the string.\n * @param {string} s - The character to remove from the end of the string. Default is a whitespace character.\n * @returns {string} - The string without trailing spaces.\n */\nString.prototype.rtrim = function (s: string = \"\\\\s\"): string {\n\treturn this.replace(new RegExp(\"[\" + s + \"]*$\"), '');\n};\n\n/**\n * Remove leading spaces from the string.\n * @param {string} s - The character to remove from the beginning of the string. Default is a whitespace character.\n * @returns {string} - The string without leading spaces.\n */\nString.prototype.ltrim = function (s: string = \"\\\\s\"): string {\n\treturn this.replace(new RegExp(\"^[\" + s + \"]*\"), '');\n};\n\n/**\n * Get only the digits from the string.\n * @returns {string} - The digits only from the string.\n */\nString.prototype.digitsOnly = function (): string {\n\t//@ts-ignore\n\treturn NumbersHelper.digitsOnly(this);\n};","\"use strict\";\n\nimport Config from \"./config\"\nimport Storage from \"./storage\"\nimport SallaCookies from \"./cookie\";\nimport Logger from \"./logger\";\nimport Emitter from \"./event\";\nimport helpers from \"./helpers\";\nimport UrlHelper from \"./helpers/url\";\nimport \"./helpers/string\"\n\nconst SallaBase = {\n Config,\n Logger,\n helpers,\n Emitter,\n Storage,\n SallaCookies,\n url: new UrlHelper(),\n log: new Logger().log,\n money: helpers.money,\n error: new Logger().error,\n isDebug: () => Config.getInstance().get('debug') || Storage.getInstance().get('debug'),\n status:'base',\n versions: {\n base: '[VI]{version}[/VI]'\n }\n}\n\nexport default SallaBase"],"names":["setNested","object","key","value","schema","keys","split","len","length","i","elem","getNested","default_","data","path","defaultValue","Array","isArray","result","get","hasDocument","document","Config","default_properties","properties_","static","constructor","properties","this","getInstance","instance","merge","config","store","set","includes","currency","isoCode","Object","values","hasOwnProperty","all","isDebug","isGuest","isUser","Logger","c","console","_proxy","historyData","proxy","cons","log","a","type","push","l","f","__dict__","style","color","event","backend","trace","debug","info","warn","error","history","substring","toUpperCase","call","concat","args","logs","flat","forEach","logData","Emitter","EventEmitter2","delimiter","loggableEvents","ignoreLogEvents","nonFireableActions","logger","super","wildcard","newListener","removeListener","maxListeners","verboseMemoryLeak","ignoreErrors","createAndDispatch","event_name","dispatch","emit","trackEvents","emitAsync","e","String","window","dataLayer","dataLayerObject","map","item","message","filter","dispatchMobileEvent","dispatchEvents","events","payload","entries","listen","eventName","callback","on","details","page","mobileApp","webkit","messageHandlers","callbackHandler","postMessage","JSON","stringify","err","Android","customEventWithData","storageEngines","localStorage","sessionStorage","cookieStorage","memoryStorage","localStore","createStore","Storage","sallaEvent","remove","firstKey","updatedParentObject","clearAll","SallaCookies","Cookies","cookie","replace","Date","toUTCString","allCookies","getAll","cookieName","sallaLogger","number","num","isToEnglish","ar","en","find","regex","RegExp","digitsOnly","getOnlyDecimal","dotsCount","match","NumbersHelper","inputDigitsOnly","input","is_decimal","querySelectorAll","el","new_val","min","parseInt","max","maxLength","toString","dataset","money","symbol","amount","UrlHelper","isFullUrl","url","startsWith","getBase","hostname","URL","ltrim","storeUrl","location","href","slice","join","rtrim","getDomain","addParamToUrl","endsWith","encodeURIComponent","baseUrl","origin","asset","cdn","api","isPage","pageName","isPlaceholder","isAValidUrl","TypeError","getLabeledData","nameLabels","existedData","currentName","helpers","getInputDataWithName","name","nameLevels","debounce","fn","delay","timer","resolves","clearTimeout","setTimeout","r","Promise","prototype","toStudlyCase","trim","t","toDatasetName","substr","toSelector","replaceArray","replaceString","s","SallaBase","status","versions","base"],"mappings":"kuBAwCgB,SAAAA,EAAUC,EAAaC,EAAaC,GACnD,IAAKF,EAAQ,OAEb,IAAIG,EAAcH,EACdI,EAAiBH,EAAII,MAAM,KAC3BC,EAAcF,EAAKG,OAEvB,IAAA,IAASC,EAAI,EAAGA,EAAIF,EAAM,EAAGE,IAAK,CAC7B,IAAAC,EAAeL,EAAKI,GACnBL,EAAOM,K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WAE7B,OAAO1M,KAAKsM,OAAO5C,WAAW,MAAQ1J,KAAKsM,OAAO5C,WAAW,KACzD1J,KAAKkJ,WACL,IAAMlJ,KAAKkJ,UAChB,EAQA3E,OAAO6H,UAAUO,aAAe,SAAU3E,EAAyBZ,GAClE,IACIa,EADA2E,EAAgB5M,KAEpB,IAAA,IAASnB,EAAI,EAAGA,EAAImJ,EAAKpJ,OAAQC,IAEhCoJ,EAAQ,IAAIC,OAAOF,EAAKnJ,GAAI,KAE5B+N,EAAgBA,EAAcxF,QAAQa,EAAOb,EAAQvI,IAG/C,OAAA+N,CACR,EAOArI,OAAO6H,UAAUhC,MAAQ,SAAUyC,EAAY,OACvC,OAAA7M,KAAKoH,QAAQ,IAAIc,OAAO,IAAM2E,EAAI,OAAQ,GAClD,EAOAtI,OAAO6H,UAAUtC,MAAQ,SAAU+C,EAAY,OACvC,OAAA7M,KAAKoH,QAAQ,IAAIc,OAAO,KAAO2E,EAAI,MAAO,GAClD,EAMAtI,OAAO6H,UAAUjE,WAAa,WAEtB,OAAAI,EAAcJ,WAAWnI,KACjC,ECrFA,MAAM8M,EAAY,CACdpN,SACAuB,SACAsK,UACArI,UACAyD,UACAM,eACAwC,IAAK,IAAIF,EACT/H,KAAK,IAAIP,GAASO,IAClB4H,MAAOmC,EAAQnC,MACf7G,OAAO,IAAItB,GAASsB,MACpBzB,QAAS,IAAMpB,EAAOO,cAAcV,IAAI,UAAYoH,EAAQ1G,cAAcV,IAAI,SAC9EwN,OAAO,OACPC,SAAU,CACNC,KAAM"}
@@ -0,0 +1,2 @@
1
+ import*as t from"store/src/store-engine";import*as e from"store/storages/localStorage";import*as r from"store/storages/sessionStorage";import*as i from"store/storages/cookieStorage";import*as s from"store/storages/memoryStorage";import{EventEmitter2 as n}from"eventemitter2";import o from"universal-cookie";function a(t,e,r){if(!t)return;let i=t,s=e.split("."),n=s.length;for(let t=0;t<n-1;t++){let e=s[t];i[e]||(i[e]={}),i=i[e]}return i[s[n-1]]=r,t}function c(t,e,r){if(!t)return r;let i=function(t,e,r){if(!t||"object"!=typeof t)return r;const i=Array.isArray(e)?e:e.split(".");let s=t;for(const t of i)if(s=s[t],void 0===s)return r;return s}(t,e);return void 0!==i?i:r}function l(){return"object"==typeof document}class g{default_properties;properties_;static instance;constructor(t={},e={}){this.default_properties=e,this.properties_={...this.default_properties,...t}}static getInstance(t={},e={}){return g.instance||(g.instance=new g(t,e)),g.instance}merge(t){return this.properties_={...this.properties_,...t},this.properties_.store={...this.default_properties?.store||{},...this.properties_.store},this}set(t,e){return t.includes(".")?(a(this.properties_,t,e),this):(this.properties_[t]=e,this)}currency(t){return t=t||this.get("user.currency_code"),this.get("currencies."+t)||Object.values(this.get("currencies"))[0]}get(t,e=null){return t.includes(".")?c(this.properties_,t,e):this.properties_.hasOwnProperty(t)?this.properties_[t]||e:e||void 0}all(){return this.properties_}isDebug(){return this.get("debug")}isGuest(){return"user"!==this.get("user.type")}isUser(){return"user"===this.get("user.type")}}class u{c=console;config;_proxy;historyData=[];get proxy(){return this._proxy}constructor(t=console){this.c=t,this.config=g.getInstance(),this._proxy={log:(t,e)=>{if(!this.config.isDebug())return;this.historyData.push([e,t]),"trace"===this.config.get("debug")&&(e="trace");let r=this.c.log,i=e?r:this.proxy.__dict__[e]||r,s=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],n={event:"#CFF680",backend:"#7b68ee",trace:"#f9f9f9",debug:"#f9f9f9",info:"#f9f9f9",warn:"#f9f9f9",error:"#f9f9f9",history:"#f9f9f9"}[e];n&&(s[0]+="%c"+e.substring(0,1).toUpperCase()+e.substring(1),s.push(`margin-left: 5px;color: ${n};font-weight:bold; border:1px solid ${n}; padding: 2px 6px; border-radius: 5px;`)),i.call(this.c,...s.concat(...t))},__dict__:{trace:this.c.trace,debug:this.c.debug,info:this.c.info,warn:this.c.warn,error:this.c.error}}}event(...t){this.proxy.log(t,"event")}trace(...t){this.proxy.log(t,"trace")}debug(...t){this.proxy.log(t,"debug")}info(...t){this.proxy.log(t,"info")}warn(...t){this.proxy.log(t,"warn")}error(...t){this.proxy.log(t,"error")}log(...t){this.proxy.log(t,"")}backend(...t){this.proxy.log(t,"backend")}logs(t){[t].flat().forEach((t=>t&&this.proxy.log([t].flat(),"backend")))}history(){return this.historyData}}class h extends n{delimiter;loggableEvents;ignoreLogEvents;nonFireableActions;static instance;logger=new u;constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.delimiter="::",this.loggableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ignoreLogEvents=["document::click","document::keyup","document::change"],this.nonFireableActions=["document.request"]}static getInstance(){return h.instance||(h.instance=new h),h.instance}createAndDispatch(t,...e){this.dispatch(t,...e)}emit(t,...e){return super.emit(t,...e),this.trackEvents(t,...e),!0}emitAsync(t,...e){const r=super.emitAsync(t,...e);try{this.trackEvents(t,...e)}catch(r){this.logger.warn(`error on tracking event (${String(t)})`,e,r)}return r}trackEvents(t,...e){if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];let r={event:t};e.map((t=>"object"==typeof t&&(r={...r,...t}))),window.dataLayer.push(r)}catch(t){this.logger.error(t.message)}(Array.isArray(t)?t.filter((t=>this.ignoreLogEvents.includes(t))):this.ignoreLogEvents.includes(t))||this.logger.event(t,...e),this.dispatchMobileEvent(t,e)}dispatch(t,...e){return this.emit(t,...e)}dispatchEvents(t){if(t)if("object"!=typeof t||Array.isArray(t))this.logger.log("Events object is wrong, it should be object of {event:payload}",t);else for(const[e,r]of Object.entries(t))this.dispatch(e,r);else this.logger.log("No Events To Dispatch!",t)}listen(t,e){return this.on(t,e)}dispatchMobileEvent(t,e={}){if("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp)if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){this.logger.log(t,"The native context does not exist yet")}else if(window.Android)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){this.logger.log(t,"The native context does not exist yet")}}}const p=[e,r,i,s],d=t.createStore(p,[],"salla");class f{static instance;store;constructor(){this.store=d;let t=h.getInstance();t.on("storage::item.remove",(t=>this.remove(t))),t.on("storage::item.set",((t,e)=>this.set(t,e)))}static getInstance(){return f.instance||(f.instance=new f),f.instance}set(t,e){if(t.includes(".")){const r=t.split(".")[0],i=a({[r]:this.store.get(r)},t,e);this.store.set(r,i[r])}else this.store.set(t,e)}remove(t){this.store.remove(t)}clearAll(){this.store.clearAll()}get(t,e){if(t.includes(".")){const e=t.split(".")[0];return c({[e]:this.store.get(e)},t,void 0)}return this.store.get(t,e)}}const m=new u,y=g.getInstance();function w(t,e=!1){t=String(t);const r=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],s=(e=e||!y.get("store.settings.arabic_numbers_enabled"))?r:i,n=e?i:r;let o;for(let e=0;e<s.length;e++)o=new RegExp(s[e],"g"),t=t.replace(o,n[e]);return t.replace(e?"٫":".",e?".":"٫")}function b(t){return w(t,!0).replace(/[^0-9.]/g,"").replace("..",".").replace(/\.$/,"")}function v(t){const e=(`${t}`.match(/\./g)||[]).length;return e&&1!==e?v(t.replace(/\.(.+)\./g,".$1")):t}var x={number:w,digitsOnly:b,inputDigitsOnly:function t(e,r=!1){if(!l())return;if("string"==typeof e)return void document.querySelectorAll(e).forEach((e=>t(e,r)));if(!e)return void m.warn("Can't find Object With Id: "+e);let i=b(e.value);e.min&&parseInt(i)<parseInt(e.min)?e.value=e.min:e.max&&parseInt(i)>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&i.length>e.maxLength?e.value=i.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?v(i):i.replace(/\D/g,"")},getOnlyDecimal:v,money:function(t){const e=y.currency(t.currency).symbol;return w(t="object"==typeof t?t.amount:t)+" "+e}};class _{config;constructor(){this.config=g.getInstance()}isFullUrl(t){return t.startsWith("https://")||t.startsWith("http://")}getBase(t){if(this.isFullUrl(t))return t;const{hostname:e}=new URL(this.get("/"));return`https://${e}/${t?.ltrim("/")}`}get(t){if(this.isFullUrl(t))return t;let e=this.config.get("store.url");return!e&&l()&&(e=window.location.href.split("/").slice(0,-1).join("/"),this.config.set("store.url",e)),`${e.rtrim("/")}/${t?.ltrim("/")}`}getDomain(t){return this.isFullUrl(t)?t:`${this.config.get("store.url",(l()?window.location.href:"").split("/").slice(0,-1).join("/")).rtrim("/")}/${t?.ltrim("/")}`}static addParamToUrl(t,e,r){if(!r)return"";if(!e||!t)return r;const i=new RegExp(`([?&])${t}=[^&]+[&]?`,"g");return(r=r.replace(i,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",`${r}${t}=${encodeURIComponent(e)}`.replace(/&$|\?$/,"")}baseUrl(t){return`${l()?window.location.origin:"http://localhost"}/${t?.ltrim("/")}`}asset(t){return this.isFullUrl(t)?t:this.config.get("theme.assets")?this.config.get("theme.assets").replace(":path",t?.ltrim("/")):this.baseUrl(`themes/${this.config.get("theme.name")}/${t?.ltrim("/")}`)}cdn(t){return`https://cdn.salla.network/${t?.ltrim("/")}`}api(t){return`${this.config.get("store.api",this.get(""))?.rtrim("/")}/${t?.ltrim("/")}`}isPage(t){return!!t&&this.config.get("page.slug")===t}isPlaceholder(t){return this.asset(this.config.get("theme.settings.placeholder"))===this.asset(t)}isAValidUrl(t){try{return new URL(t),!0}catch(t){return!1}}}function $(t,e,r){let i=t[0];return r&&0===t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[i]=$(t.slice(1),e,r[i]),r):i?{[i]:$(t.slice(1),e)}:""===i?[e]:e}var A={digitsOnly:x.digitsOnly,inputDigitsOnly:x.inputDigitsOnly,number:x.number,money:x.money,getOnlyDecimal:x.getOnlyDecimal,setNested:a,getNested:c,getInputDataWithName:function(t,e,r={}){if(t.includes("[")){let i=t.split("]").join("").split("[");return{name:i[0],value:$(i.slice(1),e,r[i[0]])}}return{name:t,value:e}},hasDocument:l,url:new _,addParamToUrl:_.addParamToUrl,debounce:function(t,e){e=e||100;let r,i=[];return function(...s){return clearTimeout(r),r=setTimeout((()=>{let e=t(...s);i.forEach((t=>t(e))),i=[]}),e),new Promise((t=>i.push(t)))}}};String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(t=>t.toUpperCase().replace(/[^a-zA-Z\d]/g,"")))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(t,e){let r,i=this;for(let s=0;s<t.length;s++)r=new RegExp(t[s],"g"),i=i.replace(r,e[s]);return i},String.prototype.rtrim=function(t="\\s"){return this.replace(new RegExp("["+t+"]*$"),"")},String.prototype.ltrim=function(t="\\s"){return this.replace(new RegExp("^["+t+"]*"),"")},String.prototype.digitsOnly=function(){return x.digitsOnly(this)};const S={Config:g,Logger:u,helpers:A,Emitter:h,Storage:f,SallaCookies:class extends o{constructor(){super();let t=h.getInstance();t.on("cookies::remove",(t=>this.remove(t))),t.on("cookies::add",((t,e)=>this.set(t,e)))}clearAll(){l()&&"string"==typeof document.cookie&&document.cookie.split(";").forEach((function(t){document.cookie=t.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")}));const t=this.getAll();for(let e in t)this.remove(e)}},url:new _,log:(new u).log,money:A.money,error:(new u).error,isDebug:()=>g.getInstance().get("debug")||f.getInstance().get("debug"),status:"base",versions:{base:"[VI]{version}[/VI]"}};export{S as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/helpers/utils.ts","../../src/config.ts","../../src/logger.ts","../../src/event.ts","../../src/storage.ts","../../src/helpers/numbers.ts","../../src/helpers/url.ts","../../src/helpers/index.ts","../../src/helpers/string.ts","../../src/index.ts","../../src/cookie.ts"],"sourcesContent":["// import { get } from \"lodash\";\n\n/**\n * Retrieves the value at the specified nested path of an object.\n * If the value does not exist, it returns a default value.\n * @param object - The object to extract value from.\n * @param path - The path to the desired value, can be either a string with dot notation or an array of keys.\n * @param defaultValue - The default value to return if the desired value does not exist.\n * @returns The value at the specified path or the default value if it does not exist.\n */\nexport function get(object: any, path: string | string[], defaultValue?: any): any {\n\t// If object is null, undefined or not an object, return the default value\n\tif (!object || typeof object !== 'object') {\n\t return defaultValue;\n\t}\n \n\t// Convert path to an array if it's a string with dot notation\n\tconst keys = Array.isArray(path) ? path : path.split('.');\n\tlet result = object;\n \n\t// Traverse through the keys to get the desired value\n\tfor (const key of keys) {\n\t result = result[key];\n \n\t // If the desired value does not exist, return the default value\n\t if (typeof result === 'undefined') {\n\t\treturn defaultValue;\n\t }\n\t}\n \n\treturn result;\n }\n\n/**\n * Sets the value of a nested property in an object.\n * @param object - The object to set the nested property in.\n * @param key - The key of the nested property, specified in dot notation (e.g. \"foo.bar\").\n * @param value - The value to set for the nested property.\n * @returns The modified object.\n */\nexport function setNested(object: any, key: string, value: any): any {\n\tif (!object) return;\n\n\tlet schema: any = object;\n\tlet keys: string[] = key.split(\".\");\n\tlet len: number = keys.length;\n\n\tfor (let i = 0; i < len - 1; i++) {\n\t\tlet elem: string = keys[i] as string;\n\t\tif (!schema[elem]) schema[elem] = {};\n\t\tschema = schema[elem];\n\t}\n\n\tschema[keys[len - 1]!] = value;\n\treturn object;\n}\n\n/**\n * Gets the value of a nested property in an object, or a default value if the property is undefined.\n * @param object - The object to get the nested property from.\n * @param key - The key of the nested property, specified in dot notation (e.g. \"foo.bar\").\n * @param default_ - The default value to return if the nested property is undefined.\n * @returns The value of the nested property, or the default value if undefined.\n */\nexport function getNested(object: any, key: string, default_: any): any {\n\tif (!object) return default_;\n\n\tlet data: any = get(object, key);\n\treturn data !== undefined ? data : default_;\n}\n\nexport function hasDocument() {\n\treturn typeof document === 'object';\n}","/**\n * @namespace Salla.config\n *\n * @property {any} properties_\n */\n\nimport ConfigAbstract from \"../types/config\"\nimport {Currency} from \"../types/common\"\nimport {getNested, setNested} from \"./helpers/utils\";\n\nclass Config implements ConfigAbstract {\n\n\t/**\n / Default properties for the configuration\n\t */\n\tdefault_properties: object | any;\n\n\t/**\n\t * Current properties for the configuration\n\t */\n\tproperties_: object | any;\n\n\tprivate static instance: Config;\n\n\t/**\n\t * Creates an instance of Config.\n\t * @param {object} properties - Current properties for the configuration\n\t * @param {object} default_properties - Default properties for the configuration\n\t */\n\tprivate constructor(properties: object = {}, default_properties: object = {},) {\n\t\tthis.default_properties = default_properties;\n\t\tthis.properties_ = {...this.default_properties, ...properties};\n\t}\n\n\tpublic static getInstance(properties: object = {}, default_properties: object = {}): Config {\n\t\tif (!Config.instance) {\n\t\t\tConfig.instance = new Config(properties, default_properties);\n\t\t}\n\t\treturn Config.instance;\n\t}\n\n\t/**\n\t * Merge the provided configuration into the current properties.\n\t * @param {object} config - Configuration to merge\n\t * @returns {Config} - Reference to the current Config instance\n\t */\n\tmerge(config: object): this {\n\t\tthis.properties_ = {...this.properties_, ...config};\n\t\tthis.properties_.store = {...(this.default_properties?.store || {}), ...this.properties_.store};\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a key-value pair in the configuration.\n\t * @param {string} key - Key to set\n\t * @param {any} value - Value to set\n\t * @returns {Config} - Reference to the current Config instance\n\t */\n\tset(key: string, value: any): this {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tsetNested(this.properties_, key, value);\n\t\t\treturn this;\n\t\t}\n\t\tthis.properties_[key] = value;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the currency information for the given ISO code or user's currency code.\n\t * @param {string} isoCode - ISO code of the currency (optional)\n\t * @returns {Currency} - Currency object\n\t */\n\tcurrency(isoCode?: string): Currency {\n\t\tisoCode = isoCode || this.get('user.currency_code');\n\t\treturn this.get('currencies.' + isoCode) || Object.values(this.get('currencies'))[0];\n\t}\n\n\n\tget(key: string, default_: null | any = null): any {\n\t\tif (key.includes(\".\")) {\n\t\t\treturn getNested(this.properties_, key, default_);\n\t\t}\n\t\treturn this.properties_.hasOwnProperty(key) ? this.properties_[key] || default_ : default_ || undefined;\n\t}\n\n\tall(): object | any {\n\t\treturn this.properties_;\n\t}\n\n\tisDebug(): boolean {\n\t\treturn this.get('debug');\n\t}\n\n\tisGuest(): boolean {\n\t\treturn this.get('user.type') !== 'user';\n\t}\n\n\tisUser(): boolean {\n\t\treturn this.get('user.type') === 'user';\n\t}\n\n}\n\nexport default Config;","import SallaConfig from \"../types/config\";\nimport Config from \"../src/config\"\n\n/**\n * A logger to help us to use Salla.logger.log like console.log\n *\n * @namespace Salla.logger\n *\n * @credits @Ammar Hasan\n * @see https://stackoverflow.com/a/21856736\n *\n */\n\ntype ProxyType = {\n\tlog(a: any[], type: string): void;\n\t// __dict__: {\n\t// \twarn: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \ttrace: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \tdebug: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \terror: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void };\n\t// \tinfo: { (message?: any, ...optionalParams: any[]): void; (...data: any[]): void }\n\t// }\n\t__dict__: { [p: string]: any }\n};\n\nexport default class Logger {\n\n\tprivate c = console;\n\tprivate config: SallaConfig;\n\tprivate _proxy: ProxyType;\n\tprivate historyData: any[] = [];\n\n\tget proxy(): ProxyType {\n\t\treturn this._proxy;\n\t}\n\n\tconstructor(cons = console) {\n\t\tthis.c = cons;\n\t\tthis.config = Config.getInstance();\n\t\tthis._proxy = {\n\t\t\tlog: (a, type) => {\n\t\t\t\tif (!this.config.isDebug()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.historyData.push([type, a]);\n\n\t\t\t\t// let's force trace for all logs when the debug is trace level\n\t\t\t\tif (this.config.get('debug') === 'trace') {\n\t\t\t\t\ttype = 'trace';\n\t\t\t\t}\n\t\t\t\tlet colorableTypes: { [key: string]: any } = {\n\t\t\t\t\t\"event\": '#CFF680',\n\t\t\t\t\t\"backend\": '#7b68ee',\n\t\t\t\t\t\"trace\": '#f9f9f9',\n\t\t\t\t\t\"debug\": '#f9f9f9',\n\t\t\t\t\t\"info\": '#f9f9f9',\n\t\t\t\t\t\"warn\": '#f9f9f9',\n\t\t\t\t\t\"error\": '#f9f9f9',\n\t\t\t\t\t\"history\": '#f9f9f9'\n\t\t\t\t};\n\n\t\t\t\tlet l = this.c.log,\n\t\t\t\t f = !!type ? l : (this.proxy.__dict__[type] || l);\n\n\t\t\t\tlet style = ['%cTwilight', 'color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;'];\n\t\t\t\tlet color = colorableTypes[type];\n\t\t\t\tif (color) {\n\t\t\t\t\tstyle[0] += '%c' + type.substring(0,1).toUpperCase() + type.substring(1);\n\t\t\t\t\tstyle.push(`margin-left: 5px;color: ${color};font-weight:bold; border:1px solid ${color}; padding: 2px 6px; border-radius: 5px;`)\n\t\t\t\t}\n\n\t\t\t\tf.call(this.c, ...style.concat(...a))\n\t\t\t},\n\t\t\t__dict__: {\n\t\t\t\t\"trace\": this.c.trace,\n\t\t\t\t\"debug\": this.c.debug,\n\t\t\t\t\"info\": this.c.info,\n\t\t\t\t\"warn\": this.c.warn,\n\t\t\t\t\"error\": this.c.error\n\t\t\t} as { [key: string]: any }\n\t\t};\n\t}\n\n\tevent(...args: any[]) {\n\t\tthis.proxy.log(args, \"event\");\n\t}\n\n\ttrace(...args: any[]) {\n\t\tthis.proxy.log(args, \"trace\");\n\t}\n\n\tdebug(...args: any[]) {\n\t\tthis.proxy.log(args, \"debug\");\n\t}\n\n\tinfo(...args: any[]) {\n\t\tthis.proxy.log(args, \"info\");\n\t}\n\n\twarn(...args: any[]) {\n\t\tthis.proxy.log(args, \"warn\");\n\t}\n\n\terror(...args: any[]) {\n\t\tthis.proxy.log(args, \"error\");\n\t}\n\n\tlog(...args: any[]) {\n\t\tthis.proxy.log(args, '');\n\t}\n\n\t//use this to pass messages from backEnd, no need to add documentations, because it will no passed in production\n\tbackend(...args: any[]) {\n\t\tthis.proxy.log(args, \"backend\");\n\t}\n\n\t//this for internal usage to pass multi logs using one function, no need to add it to documentation @see \\Salla\\Core\\Traits\\WithStageLogger::debug\n\tlogs(logs: any[]) {\n\t\t//@ts-ignore\n\t\t[logs].flat().forEach(logData => logData && this.proxy.log([logData].flat(), 'backend'));\n\t}\n\n\thistory() {\n\t\treturn this.historyData;\n\t}\n}","import {\n\tevent as EventType,\n\tEventAndListener,\n\tEventEmitter2,\n\teventNS,\n\tListener,\n\tListenerFn,\n\tOnOptions,\n} from 'eventemitter2';\nimport Logger from './logger';\nimport EmitterInterface, {typeSafeEvents} from \"../types/event\"\n\n/**\n * @namespace Salla.event\n *\n * @property {string} delimiter\n * @property {array} loggableEvents - log errors or important events.\n */\nexport default class Emitter extends EventEmitter2 implements EmitterInterface {\n\tdelimiter: string;\n\tloggableEvents: string[];\n\tignoreLogEvents: string[];\n\tnonFireableActions: string[];\n\n\tprivate static instance: Emitter;\n\n\tlogger = new Logger();\n\n\tprivate constructor() {\n\t\tconst delimiter = '::';\n\t\tsuper({\n\t\t\twildcard: true,\n\t\t\tdelimiter,\n\t\t\tnewListener: false,\n\t\t\tremoveListener: false,\n\t\t\tmaxListeners: 10,\n\t\t\tverboseMemoryLeak: false,\n\t\t\tignoreErrors: false,\n\t\t});\n\t\tthis.delimiter = delimiter;\n\n\t\tthis.loggableEvents = ['cart::item.added.failed', 'cart::item.deleted.failed'];\n\n\t\tthis.ignoreLogEvents = [\n\t\t\t'document::click',\n\t\t\t'document::keyup',\n\t\t\t'document::change',\n\t\t\t//'document::submit',\n\t\t];\n\n\t\tthis.nonFireableActions = ['document.request'];\n\t}\n\n\tpublic static getInstance(): Emitter {\n\t\tif (!Emitter.instance) {\n\t\t\tEmitter.instance = new Emitter();\n\t\t}\n\t\treturn Emitter.instance;\n\t}\n\n\t/**\n\t * @param {string} event_name\n\t * @param data\n\t *\n\t * @deprecated , legacy code, use dispatch() instead\n\t */\n\tcreateAndDispatch<Event extends string | symbol>(event_name: Event | Event[], ...data: any): void {\n\t\tthis.dispatch(event_name, ...data);\n\t}\n\n\temit<Event extends string | symbol>(event: Event | Event[], ...data: any): boolean {\n\t\t/**\n\t\t * if the event, is api/event method, call it,\n\t\t * ex: cart::quick.add call Salla.api.cart.quickAdd(...data)\n\t\t * we don't used Salla.call(actionName)(...data), to avoid losing this scope in our apis.\n\t\t *\n\t\t * @deprecated don't use it anymore\n\t\t */\n\t\tsuper.emit(event, ...data);\n\t\tthis.trackEvents(event, ...data);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Return the results of the listeners via Promise.all.\n\t * Only this method doesn't work IE.\n\t * @param event_name\n\t * @param data\n\t */\n\temitAsync<Event extends string | symbol>(event_name: Event | Event[], ...data: any): any {\n\t\t// to make sure that data object will not be affected by track process\n\t\tconst result = super.emitAsync(event_name, ...data);\n\t\ttry {\n\t\t\tthis.trackEvents(event_name, ...data);\n\t\t} catch (e) {\n\t\t\tthis.logger.warn(`error on tracking event (${String(event_name)})`, data, e);\n\t\t}\n\t\treturn result;\n\t}\n\n\ttrackEvents<Event extends string | symbol>(event_name: Event | Event[], ...data: any): void {\n\t\t// let's send the event to data layer\n\t\tif (typeof window !== 'undefined') {\n\t\t\ttry {\n\t\t\t\twindow.dataLayer = window.dataLayer || [];\n\t\t\t\t/**\n\t\t\t\t * data is coming as an array like this:\n\t\t\t\t * [{\"services\": {\"intercom\": {\"app_id\": \"***\"}}}]\n\t\t\t\t * we will merge itf into one object like this:\n\t\t\t\t * {event: event_name, \"services\": {\"intercom\": {\"app_id\": \"***\"}}}\n\t\t\t\t */\n\t\t\t\tlet dataLayerObject = {event: event_name};\n\t\t\t\tdata.map((item: any) => typeof item === 'object' && (dataLayerObject = {...dataLayerObject, ...item}));\n\t\t\t\twindow.dataLayer.push(dataLayerObject);\n\t\t\t} catch (e: any) {\n\t\t\t\tthis.logger.error(e.message);\n\t\t\t}\n\t\t}\n\n\t\t// if there is need to log errors, or events, lets do it here.\n\t\tif (Array.isArray(event_name) ? !event_name.filter((item) => this.ignoreLogEvents.includes(item as string)) : !this.ignoreLogEvents.includes(event_name as string)) {\n\t\t\tthis.logger.event(event_name, ...data);\n\t\t}\n\t\tthis.dispatchMobileEvent(event_name, data);\n\t}\n\n\t/**\n\t * Fire Event with data\n\t *\n\t * @param {string} event_name - action name like `cart::addItem` or event name like `cart::item.added`\n\t * @param {any|undefined} data\n\t * @data {{payload}} data\n\t */\n\tdispatch<Event extends string | symbol>(event_name: Event | Event[], ...data: any): boolean {\n\t\treturn this.emit(event_name, ...data);\n\t}\n\n\t/**\n\t * Fire multi events using object of events\n\t *\n\t * @param {Object.<string, *>} events\n\t */\n\tdispatchEvents(events: { [key: string]: any }): void {\n\t\tif (!events) {\n\t\t\tthis.logger.log('No Events To Dispatch!', events);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof events !== 'object' || Array.isArray(events)) {\n\t\t\tthis.logger.log('Events object is wrong, it should be object of {event:payload}', events);\n\t\t\treturn;\n\t\t}\n\n\t\t//@ts-ignore\n\t\tfor (const [event_name, payload] of Object.entries(events)) {\n\t\t\tthis.dispatch(event_name, payload);\n\t\t}\n\t}\n\n\t/**\n\t * Alias for this.addListener\n\t * @param {string} eventName\n\t * @param {function} callback\n\t */\n\tlisten(eventName: EventType | eventNS, callback: ListenerFn): this | Listener {\n\t\treturn this.on(eventName, callback);\n\t}\n\n\t/**\n\t * This help to push an event to mobile app.\n\t *\n\t * @param eventName\n\t * @param details\n\t * @returns {string}\n\t */\n\tdispatchMobileEvent<Event extends string | symbol>(eventName: Event | Event[], details = {}): void {\n\t\tif (\n\t\t typeof window === 'undefined' ||\n\t\t !window.dataLayer ||\n\t\t !window.dataLayer[0] ||\n\t\t !window.dataLayer[0].page ||\n\t\t !window.dataLayer[0].page.mobileApp\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!!window.webkit) {\n\t\t\ttry {\n\t\t\t\twindow.webkit.messageHandlers.callbackHandler.postMessage(\n\t\t\t\t JSON.stringify({\n\t\t\t\t\t event: eventName,\n\t\t\t\t\t details: details,\n\t\t\t\t })\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tthis.logger.log(err, 'The native context does not exist yet');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!!window.Android) {\n\t\t\ttry {\n\t\t\t\twindow.Android.customEventWithData(eventName, JSON.stringify({details: details}));\n\t\t\t} catch (err) {\n\t\t\t\tthis.logger.log(err, 'The native context does not exist yet');\n\t\t\t}\n\t\t}\n\t}\n}","import * as createStore from \"store/src/store-engine\"\nimport * as localStorage from \"store/storages/localStorage\"\nimport * as sessionStorage from \"store/storages/sessionStorage\"\nimport * as cookieStorage from \"store/storages/cookieStorage\"\nimport * as memoryStorage from \"store/storages/memoryStorage\"\nimport {getNested, setNested} from \"./helpers/utils\"\nimport Emitter from \"./event\";\n\n// Define storage engines\nconst storageEngines: any[] = [\n\tlocalStorage,\n\tsessionStorage,\n\tcookieStorage,\n\tmemoryStorage,\n];\n\n// Create the store engine with the storage engines and the namespace\nconst localStore = createStore.createStore(storageEngines, [], \"salla\");\n\nexport default class Storage {\n\tprivate static instance: Storage;\n\tstore: typeof localStore;\n\n\tprivate constructor() {\n\t\tthis.store = localStore;\n\n\t\tlet sallaEvent = Emitter.getInstance();\n\t\tsallaEvent.on(\"storage::item.remove\", (key) => this.remove(key));\n\t\tsallaEvent.on(\"storage::item.set\", (key, value) => this.set(key, value));\n\t}\n\n\tpublic static getInstance(): Storage {\n\t\tif (!Storage.instance) {\n\t\t\tStorage.instance = new Storage();\n\t\t}\n\t\treturn Storage.instance;\n\t}\n\n\tpublic set(key: string, value: any): void {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tconst firstKey: string = key.split(\".\")[0] as string;\n\t\t\tconst parentObject = {[firstKey]: this.store.get(firstKey)};\n\t\t\tconst updatedParentObject = setNested(parentObject, key, value);\n\t\t\tthis.store.set(firstKey, updatedParentObject[firstKey]);\n\t\t} else {\n\t\t\tthis.store.set(key, value);\n\t\t}\n\t}\n\n\tpublic remove(key: string): void {\n\t\tthis.store.remove(key);\n\t}\n\n\tpublic clearAll(): void {\n\t\tthis.store.clearAll();\n\t}\n\n\tpublic get(key: string, value?: any): any {\n\t\t//@ts-ignore\n\t\tif (key.includes(\".\")) {\n\t\t\tconst firstKey: string = key.split(\".\")[0] as string;\n\t\t\treturn getNested({[firstKey]: this.store.get(firstKey)}, key, undefined);\n\t\t} else {\n\t\t\treturn this.store.get(key, value);\n\t\t}\n\t}\n}","import { Price } from \"../../types/common\";\nimport SallaConfig from \"../../types/config\";\nimport LoggerType from \"../../types/logger\";\n\nimport Logger from \"../logger\";\nimport Config from \"../config\"\nimport { hasDocument } from \"./utils\";\n\nconst sallaLogger = new Logger();\nconst config = Config.getInstance();\n\n\n/**\n * Converts a number to a string and replaces Arabic numerals with English numerals.\n * @param num - The number to convert.\n * @param isToEnglish - Whether to convert Arabic numerals to English numerals.\n * @returns The converted number as a string.\n */\nfunction number(num: number | string, isToEnglish = false): string {\n\tnum = String(num); // make sure that number will be converted to string.\n\tisToEnglish =\n\t\tisToEnglish ||\n\t\t!config.get(\"store.settings.arabic_numbers_enabled\");\n\tconst ar = [\"٠\", \"١\", \"٢\", \"٣\", \"٤\", \"٥\", \"٦\", \"٧\", \"٨\", \"٩\"];\n\tconst en = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\tconst find = isToEnglish ? ar : en;\n\tconst replace = isToEnglish ? en : ar;\n\tlet regex;\n\tfor (let i = 0; i < find.length; i++) {\n\t\t//@ts-ignore\n\t\tregex = new RegExp(find[i], \"g\");\n\t\t//@ts-ignore\n\t\tnum = (num as String).replace(regex, replace[i]);\n\t}\n\t// todo: replace dots between two digits only, to avoid replacing the period.\n\treturn (num as String).replace(isToEnglish ? \"٫\" : \".\", isToEnglish ? \".\" : \"٫\");\n}\n\nfunction digitsOnly(num: string): string {\n\treturn number(num, true)\n\t\t.replace(/[^0-9.]/g, \"\")\n\t\t.replace(\"..\", \".\")\n\t\t.replace(/\\.$/, \"\"); // without this: `Salla.helpers.digitsOnly('١٬٦٠٠ ر.س')` => `1600`\n}\n\nfunction inputDigitsOnly(input: HTMLInputElement | string, is_decimal = false): void {\n\tif (!hasDocument()) return;\n\tif (typeof input === \"string\") {\n\t\tdocument\n\t\t\t.querySelectorAll(input)\n\t\t\t.forEach((el) => inputDigitsOnly(el as HTMLInputElement, is_decimal));\n\t\treturn;\n\t}\n\tif (!input) {\n\t\tsallaLogger.warn(\"Can't find Object With Id: \" + input);\n\t\treturn;\n\t}\n\tlet new_val = digitsOnly(input.value);\n\tif (input.min && parseInt(new_val) < parseInt(input.min)) {\n\t\tinput.value = input.min;\n\t\treturn;\n\t}\n\tif (input.max && parseInt(new_val) > parseInt(input.max)) {\n\t\tinput.value = input.max\n\t\treturn;\n\t}\n\tif (input.maxLength >= 1 && new_val.length > input.maxLength) {\n\t\tinput.value = new_val.toString().substring(0, input.maxLength);\n\t\treturn;\n\t}\n\tinput.value = is_decimal || input.dataset.hasOwnProperty(\"digitsWithDecimal\")\n\t\t? getOnlyDecimal(new_val)\n\t\t: new_val.replace(/\\D/g, \"\");\n}\n\nfunction getOnlyDecimal(value: string): string {\n\tconst dotsCount = (`${value}`.match(/\\./g) || []).length;\n\tif (!dotsCount || dotsCount === 1) {\n\t\treturn value;\n\t}\n\t// if there is more than one dot, remove the last dot.\n\t// Ex: 123.545.66 => 123.54566\n\treturn getOnlyDecimal(value.replace(/\\.(.+)\\./g, \".$1\"));\n}\n\nfunction money(money: string | number | Price): string {\n\tconst currency = config.currency((money as Price).currency).symbol;\n\tmoney =\n\t\ttypeof money === \"object\" ? money.amount : money as unknown as number;\n\treturn number(money) + \" \" + currency;\n}\n\nexport default {\n\tnumber,\n\tdigitsOnly,\n\tinputDigitsOnly,\n\tgetOnlyDecimal,\n\tmoney,\n};","import SallaConfig from \"../../types/config\";\nimport {hasDocument} from \"./utils\";\nimport {UrlHelpers} from \"../../types/helpers\";\n\nimport Config from \"../config\"\n\nexport default class UrlHelper implements UrlHelpers{\n\tconfig: SallaConfig;\n\n\tconstructor() {\n\t\tthis.config = Config.getInstance();\n\t}\n\n\t/**\n\t * Check if the url is a full url.\n\t * @param {string} url - The url to check.\n\t * @returns {boolean} - True if the url is a full url.\n\t */\n\tisFullUrl(url: string): boolean {\n\t\treturn url.startsWith(\"https://\") || url.startsWith(\"http://\");\n\t}\n\n\t/**\n\t * Get the base url for the given url.\n\t * @param {string} url - The url to get the base url for.\n\t * @returns string - The base url for the given url.\n\t */\n\tgetBase(url: string): string {\n\t\tif (this.isFullUrl(url)) {\n\t\t\treturn url;\n\t\t}\n\n\t\tconst {hostname} = new URL(this.get(\"/\"));\n\n\t\treturn `https://${hostname}/${url?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Get the full url for the given path.\n\t * @param {string} path - The path to get the full url for.\n\t * @returns {string} - The full url the given path.\n\t */\n\tget(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\tlet storeUrl = this.config.get(\"store.url\");\n\n\t\tif (!storeUrl && hasDocument()) {\n\t\t\tstoreUrl = window.location.href.split(\"/\").slice(0, -1).join(\"/\");\n\t\t\tthis.config.set(\"store.url\", storeUrl);\n\t\t}\n\n\t\treturn `${storeUrl.rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Get the domain for the given path.\n\t * @param {string} path - The path to get the domain for.\n\t * @returns {string} - The domain for the given path.\n\t */\n\tgetDomain(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\treturn `${this.config.get(\n\t\t \"store.url\",\n\t\t (hasDocument() ? window.location.href : '').split(\"/\").slice(0, -1).join(\"/\")\n\t\t).rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Add a parameter to a URL.\n\t * @param {string} key - The key of the parameter to add.\n\t * @param {string} value - The value of the parameter to add.\n\t * @param {string} [url] - The URL to add the parameter to. Defaults to window.location.href.\n\t * @returns {string} - The URL with the added parameter.\n\t */\n\tstatic addParamToUrl(key: string, value: string, url: any): string {\n\t\t//TODO: check when there is no url param provided (from the clinet side)\n\t\t// for the time being return empty string\n\t\t// url = url;\n\t\tif(!url) return \"\"\n\n\t\t// assuming url is a string type\n\n\t\tif (!value || !key) {\n\t\t\treturn url;\n\t\t}\n\n\t\tconst regex = new RegExp(`([?&])${key}=[^&]+[&]?`, \"g\");\n\n\t\turl = url\n\t\t .replace(regex, \"$1\") //remove old one\n\t\t .split(\"#\")[0] //remove any hash values ex 'https://my_site.test/brands#brand-section-1'\n\t\t .replace(/&$|\\?$/, \"\"); // remove the `?` or `&` if it's the last char\n\n\t\tif (url.includes(\"?\")) {\n\t\t\turl += \"&\";\n\t\t} else {\n\t\t\t//avoid cases like this: 'https://my_store.test/ar?test=hi'\n\t\t\turl += (url.endsWith(\"/\") ? \"\" : \"/\") + \"?\";\n\t\t}\n\n\t\treturn `${url}${key}=${encodeURIComponent(value)}`.replace(/&$|\\?$/, \"\");\n\t}\n\n\t/**\n\t * Get the base URL for a given path without username if it's salla domain ex: Salla.sa/test will ignore test.\n\t * @param {string} path - The path to get the base URL for.\n\t * @returns {string} - The base URL for the given path without username if it's salla domain ex: Salla.sa/test will ignore test.\n\t */\n\tbaseUrl(path: string): string {\n\t\t//TODO: check what to use for SSR\n\t\treturn `${hasDocument() ? window.location.origin : \"http://localhost\"}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns the asset path.\n\t * @param path - The path to the asset.\n\t * @returns The asset path.\n\t */\n\tasset(path: string): string {\n\t\tif (this.isFullUrl(path)) {\n\t\t\treturn path;\n\t\t}\n\n\t\tif (this.config.get(\"theme.assets\")) {\n\t\t\treturn this.config.get(\"theme.assets\").replace(\":path\", path?.ltrim(\"/\"));\n\t\t}\n\n\t\treturn this.baseUrl(`themes/${this.config.get(\"theme.name\")}/${path?.ltrim(\"/\")}`);\n\t}\n\n\t/**\n\t * Returns the CDN path.\n\t * @param path - The path to the CDN.\n\t * @returns The CDN path.\n\t */\n\tcdn(path: string): string {\n\t\treturn `https://cdn.salla.network/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns the API URL.\n\t * @example Salla.url.api('test') => https://my_store.test/api/v1/test\n\t * @param path - The API endpoint.\n\t * @returns The API URL.\n\t */\n\tapi(path: string): string {\n\t\treturn `${this.config.get(\"store.api\", this.get(\"\"))?.rtrim(\"/\")}/${path?.ltrim(\"/\")}`;\n\t}\n\n\t/**\n\t * Returns whether the page name matches the current page slug.\n\t * @param pageName - The name of the page to check against.\n\t * @returns Whether the page name matches the current page slug.\n\t */\n\tisPage(pageName: string): boolean {\n\t\treturn !!pageName && this.config.get(\"page.slug\") === pageName;\n\t}\n\n\t/**\n\t * Returns whether the URL is a placeholder.\n\t * @param url - The URL to check.\n\t * @returns Whether the URL is a placeholder.\n\t */\n\tisPlaceholder(url: string): boolean {\n\t\treturn this.asset(this.config.get(\"theme.settings.placeholder\")) === this.asset(url);\n\t}\n\n\t/**\n\t * Check if a string is a valid URL or not.\n\t * @param value - url string\n\t * @returns boolean.\n\t */\n\tisAValidUrl(value: string): boolean {\n\t\ttry {\n\t\t\tnew URL(value);\n\t\t\treturn true;\n\t\t} catch (TypeError) {\n\t\t\treturn false;\n\t\t}\n\t}\n}","import NumbersHelper from \"./numbers\";\n\nimport UrlHelper from \"./url\";\nimport {getNested, setNested, hasDocument} from \"./utils\";\n\n/**\n * To use it, you need some moves:\n * 1- First : you should have global variable: `let my_debounce;`\n * 2- Next : make your own function: `function my_debounce_fn(callback,...data){...}`\n * 3- Next : in your method, check if it's not existed yet, use this helper method to create it: `if(!my_debounce){my_debounce=Salla.helpers.debounce((fn, ...inner_data) => fn(...inner_data), 500)}`\n * 4- Next : then delay the passed callback: `my_debounce(callback, ...data);`\n * 5- Finally : use it: `my_debounce(() =>{...yourRepeatableLogic})`\n * will be something like:\n *\n * ```\n * let my_debounce;\n * function my_debounce_fn(callback,...data){\n * if(!my_debounce){\n * // inline method\n * my_debounce=Salla.helpers.debounce((fn, ...inner_data) => fn(...inner_data), 500);\n * }\n * return my_debounce(callback, ...data);\n * }\n * // use it like:\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 1');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 2');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 3');\n * my_debounce_fn((my_data)=>Salla.log(my_data), 'hello there - 4');\n * // output=> `hello there - 4`\n * ```\n * 😎Or just use Salla appHelpers:`app.debounce((my_data)=>Salla.log(my_data), 'hello there - *')`\n *\n * @param fn\n * @param delay\n * @return Promise\n */\nfunction debounce(fn: Function, delay: number): Function {\n\tdelay = delay || 100;\n\tlet resolves: Function[] = [];\n\tlet timer: NodeJS.Timeout;\n\n\treturn function (...args: any[]): Promise<unknown> {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => {\n\t\t\tlet result = fn(...args);\n\t\t\tresolves.forEach((r) => r(result));\n\t\t\tresolves = [];\n\t\t}, delay);\n\t\t//@ts-ignore\n\t\treturn new Promise((r) => resolves.push(r));\n\t};\n}\n\n/**\n * Use It When You want to grab data from input names with brackets Ex.\n * <input name=\"products[0][id]\" value...>\n * <input name=\"products[0][name]\" value...>\n * <input name=\"products[1][id]\" value...>\n * <input name=\"products[1][name]\" value...>\n * will be like: {products:[{id:.., name:..},{id:.., name:..}]}\n * @param name\n * @param value\n * @param dataset\n * @return {name, value}|{name, value: (*|[*, *]|[string, *]|{}|[*])}\n */\nfunction getInputDataWithName(name: string, value: any, dataset: object = {}): object {\n\t//@ts-ignore\n\tif (name.includes(\"[\")) {\n\t\tlet nameLevels = name.split(\"]\").join(\"\").split(\"[\");\n\t\t//@ts-ignore\n\t\treturn {name: nameLevels[0], value: getLabeledData(nameLevels.slice(1), value, dataset[nameLevels[0]])};\n\t}\n\treturn {name: name, value: value};\n}\n\n/**\n * in case input name is array for example \"jamal[4655]\" let's fix it\n * This Helper method to get suitable array data, Ex.\n * jamal[]=1\n * jamal[]=2\n * final result will be: {jamal:[1,2]}\n *\n * @param nameLabels\n * @param value\n * @param existedData\n * @return *[]|*|(string|*)[]|{}\n */\nfunction getLabeledData(nameLabels: string[], value: string | any, existedData: object | undefined): any[] | any {\n\tlet currentName = nameLabels[0];\n\n\t// it's an array, so add value as array\n\tif (existedData && nameLabels.length === 0) {\n\t\tif (Array.isArray(existedData)) {\n\t\t\texistedData.push(value);\n\t\t\treturn existedData;\n\t\t}\n\n\t\t// todo: handle in case it's object\n\t\treturn [existedData, value];\n\t}\n\n\tif (Array.isArray(existedData)) {\n\t\texistedData.push(value);\n\t\treturn existedData;\n\t}\n\n\tif (typeof existedData === \"string\") {\n\t\treturn [existedData, value];\n\t}\n\n\t// it's nested data\n\tif (existedData) {\n\t\t//@ts-ignore\n\t\texistedData[currentName] = getLabeledData(nameLabels.slice(1), value, existedData[currentName]);\n\t\treturn existedData;\n\t}\n\n\tif (currentName) {\n\t\t//@ts-ignore\n\t\treturn {[currentName]: getLabeledData(nameLabels.slice(1), value)};\n\t}\n\n\t// handling \"[]\" without name\n\treturn currentName === \"\" ? [value] : value;\n}\n\n/**\n * @type { debouce: (function(*, *=): function(...[*]): Promise<unknown>), getInputDataWithName: ((function(*=, *=, *): ({name, value}|{name, value: (*|*[]|(string|*)[]|{})}))|*), digitsOnly: ((function(*=, *=): (undefined|*))|*) }}\n */\nexport default {\n\t// Numbers helpers\n\tdigitsOnly: NumbersHelper.digitsOnly,\n\tinputDigitsOnly: NumbersHelper.inputDigitsOnly,\n\tnumber: NumbersHelper.number,\n\tmoney: NumbersHelper.money,\n\tgetOnlyDecimal: NumbersHelper.getOnlyDecimal,\n\n\t// Nested objects helpers\n\tsetNested,\n\tgetNested,\n\tgetInputDataWithName,\n\thasDocument,\n\n\t// Url helpers\n\turl: new UrlHelper(),\n\taddParamToUrl: UrlHelper.addParamToUrl,\n\n\t// other\n\tdebounce,\n};","import NumbersHelper from \"./numbers\";\n\ndeclare global {\n\tinterface String {\n\t\ttoStudlyCase(): string;\n\n\t\ttoDatasetName(): string;\n\n\t\ttoSelector(): string;\n\n\t\treplaceArray(find: string[], replace: string[]): string;\n\n\t\trtrim(s?: string): string;\n\n\t\tltrim(s?: string): string;\n\n\t\tdigitsOnly(): string;\n\t}\n}\n\n/**\n * Convert string to StudlyCase.\n * @returns {string} - The string in StudlyCase.\n */\nString.prototype.toStudlyCase = function (): string {\n\treturn this.trim().replace(/([^a-zA-Z\\d].)/g, (t: string) => {\n\t\treturn t.toUpperCase().replace(/[^a-zA-Z\\d]/g, '');\n\t});\n};\n\n/**\n * Convert a string to dataset name format.\n * @returns {string} - The string in dataset name format.\n */\nString.prototype.toDatasetName = function (): string {\n\t//@ts-ignore\n\treturn this.startsWith('data-')\n\t ? this.substr(5).toStudlyCase()\n\t : this.toStudlyCase();\n};\n\n/**\n * Get string as selector by adding \"#\" to the beginning if it doesn't start with \"#\" or \".\".\n * @returns {string} - The string as a selector.\n */\nString.prototype.toSelector = function (): string {\n\t//@ts-ignore\n\treturn this.trim().startsWith(\".\") || this.trim().startsWith(\"#\")\n\t ? this.toString()\n\t : \"#\" + this.toString();\n};\n\n/**\n * Replace an array of strings with another array of strings.\n * @param {string[]} find - The array of strings to be replaced.\n * @param {string[]} replace - The array of strings to replace with.\n * @returns {string} - The replaced string.\n */\nString.prototype.replaceArray = function (find: string[] | string, replace: string[] | string): string {\n\tlet replaceString = this;\n\tlet regex: RegExp;\n\tfor (let i = 0; i < find.length; i++) {\n\t\t//@ts-ignore\n\t\tregex = new RegExp(find[i], \"g\");\n\t\t//@ts-ignore\n\t\treplaceString = replaceString.replace(regex, replace[i]);\n\t}\n\t//@ts-ignore\n\treturn replaceString;\n};\n\n/**\n * Remove trailing spaces from the string.\n * @param {string} s - The character to remove from the end of the string. Default is a whitespace character.\n * @returns {string} - The string without trailing spaces.\n */\nString.prototype.rtrim = function (s: string = \"\\\\s\"): string {\n\treturn this.replace(new RegExp(\"[\" + s + \"]*$\"), '');\n};\n\n/**\n * Remove leading spaces from the string.\n * @param {string} s - The character to remove from the beginning of the string. Default is a whitespace character.\n * @returns {string} - The string without leading spaces.\n */\nString.prototype.ltrim = function (s: string = \"\\\\s\"): string {\n\treturn this.replace(new RegExp(\"^[\" + s + \"]*\"), '');\n};\n\n/**\n * Get only the digits from the string.\n * @returns {string} - The digits only from the string.\n */\nString.prototype.digitsOnly = function (): string {\n\t//@ts-ignore\n\treturn NumbersHelper.digitsOnly(this);\n};","\"use strict\";\n\nimport Config from \"./config\"\nimport Storage from \"./storage\"\nimport SallaCookies from \"./cookie\";\nimport Logger from \"./logger\";\nimport Emitter from \"./event\";\nimport helpers from \"./helpers\";\nimport UrlHelper from \"./helpers/url\";\nimport \"./helpers/string\"\n\nconst SallaBase = {\n Config,\n Logger,\n helpers,\n Emitter,\n Storage,\n SallaCookies,\n url: new UrlHelper(),\n log: new Logger().log,\n money: helpers.money,\n error: new Logger().error,\n isDebug: () => Config.getInstance().get('debug') || Storage.getInstance().get('debug'),\n status:'base',\n versions: {\n base: '[VI]{version}[/VI]'\n }\n}\n\nexport default SallaBase","import Cookies from \"universal-cookie\";\nimport { hasDocument } from \"./helpers/utils\";\nimport Emitter from \"./event\";\n\nexport default class SallaCookies extends Cookies {\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet sallaEvent = Emitter.getInstance();\n\t\tsallaEvent.on(\"cookies::remove\", (key) => this.remove(key));\n\t\tsallaEvent.on(\"cookies::add\", (key, value) => this.set(key, value));\n\t}\n\n\tclearAll() {\n\t\tif (hasDocument() && typeof document.cookie === 'string')\n\t\t\tdocument.cookie.split(';').forEach(function (c) {\n\t\t\t\tdocument.cookie = c\n\t\t\t\t\t.replace(/^ +/, '')\n\t\t\t\t\t.replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');\n\t\t\t});\n\t\tconst allCookies = this.getAll();\n\t\tfor (let cookieName in allCookies) {\n\t\t\tthis.remove(cookieName);\n\t\t}\n\t}\n}"],"names":["setNested","object","key","value","schema","keys","split","len","length","i","elem","getNested","default_","data","path","defaultValue","Array","isArray","result","get","hasDocument","document","Config","default_properties","properties_","static","constructor","properties","this","getInstance","instance","merge","config","store","set","includes","currency","isoCode","Object","values","hasOwnProperty","all","isDebug","isGuest","isUser","Logger","c","console","_proxy","historyData","proxy","cons","log","a","type","push","l","f","__dict__","style","color","event","backend","trace","debug","info","warn","error","history","substring","toUpperCase","call","concat","args","logs","flat","forEach","logData","Emitter","EventEmitter2","delimiter","loggableEvents","ignoreLogEvents","nonFireableActions","logger","super","wildcard","newListener","removeListener","maxListeners","verboseMemoryLeak","ignoreErrors","createAndDispatch","event_name","dispatch","emit","trackEvents","emitAsync","e","String","window","dataLayer","dataLayerObject","map","item","message","filter","dispatchMobileEvent","dispatchEvents","events","payload","entries","listen","eventName","callback","on","details","page","mobileApp","webkit","messageHandlers","callbackHandler","postMessage","JSON","stringify","err","Android","customEventWithData","storageEngines","localStorage","sessionStorage","cookieStorage","memoryStorage","localStore","createStore","Storage","sallaEvent","remove","firstKey","updatedParentObject","clearAll","sallaLogger","number","num","isToEnglish","ar","en","find","replace","regex","RegExp","digitsOnly","getOnlyDecimal","dotsCount","match","NumbersHelper","inputDigitsOnly","input","is_decimal","querySelectorAll","el","new_val","min","parseInt","max","maxLength","toString","dataset","money","symbol","amount","UrlHelper","isFullUrl","url","startsWith","getBase","hostname","URL","ltrim","storeUrl","location","href","slice","join","rtrim","getDomain","addParamToUrl","endsWith","encodeURIComponent","baseUrl","origin","asset","cdn","api","isPage","pageName","isPlaceholder","isAValidUrl","TypeError","getLabeledData","nameLabels","existedData","currentName","helpers","getInputDataWithName","name","nameLevels","debounce","fn","delay","timer","resolves","clearTimeout","setTimeout","r","Promise","prototype","toStudlyCase","trim","t","toDatasetName","substr","toSelector","replaceArray","replaceString","s","SallaBase","SallaCookies","Cookies","cookie","Date","toUTCString","allCookies","getAll","cookieName","status","versions","base"],"mappings":"mTAwCgB,SAAAA,EAAUC,EAAaC,EAAaC,GACnD,IAAKF,EAAQ,OAEb,IAAIG,EAAcH,EACdI,EAAiBH,EAAII,MAAM,KAC3BC,EAAcF,EAAKG,OAEvB,IAAA,IAASC,EAAI,EAAGA,EAAIF,EAAM,EAAGE,IAAK,CAC7B,IAAAC,EAAeL,EAAKI,GACnBL,EAAOM,KAAcN,EAAAM,GAAQ,IAClCN,EAASA,EAAOM,EAChB,CAGM,OADPN,EAAOC,EAAKE,EAAM,IAAOJ,EAClBF,CACR,CASgB,SAAAU,EAAUV,EAAaC,EAAaU,GACnD,IAAKX,EAAe,OAAAW,EAEhB,IAAAC,EAzDW,SAAIZ,EAAaa,EAAyBC,GAEzD,IAAKd,GAA4B,iBAAXA,EACb,OAAAc,EAIH,MAAAV,EAAOW,MAAMC,QAAQH,GAAQA,EAAOA,EAAKR,MAAM,KACrD,IAAIY,EAASjB,EAGb,IAAA,MAAWC,KAAOG,EAIZ,GAHJa,EAASA,EAAOhB,QAGM,IAAXgB,EACL,OAAAH,EAID,OAAAG,CACN,CAoCeC,CAAIlB,EAAQC,GACrB,YAAS,IAATW,EAAqBA,EAAOD,CACpC,UAEgBQ,IACf,MAA2B,iBAAbC,QACf,CC/DA,MAAMC,EAKLC,mBAKAC,YAEQC,gBAOR,WAAAC,CAAoBC,EAAqB,GAAIJ,EAA6B,CAAA,GACzEK,KAAKL,mBAAqBA,EAC1BK,KAAKJ,YAAc,IAAII,KAAKL,s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,KAAcF,EACtB5M,KAAK6G,OAAOiG,EAEd,GDPG7D,IAAK,IAAIF,EACTvH,KAAK,IAAIP,GAASO,IAClBoH,MAAOmC,EAAQnC,MACfrG,OAAO,IAAItB,GAASsB,MACpBzB,QAAS,IAAMpB,EAAOO,cAAcV,IAAI,UAAYoH,EAAQ1G,cAAcV,IAAI,SAC9EwN,OAAO,OACPC,SAAU,CACNC,KAAM"}
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@salla.sa/base",
3
- "version": "2.12.47",
3
+ "version": "3.0.0",
4
4
  "description": "Salla Base",
5
- "main": "dist/cjs/",
6
- "module": "dist/esm/",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
7
  "types": "types/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "npx rollup --config --preserveSymlinks=true",
10
+ "build-wp": "npx webpack",
10
11
  "serve": "npx rollup --watch --serve --config --preserveSymlinks=true",
11
12
  "watch": "npx rollup --watch --config --preserveSymlinks=true",
12
- "test": "jest --detectOpenHandles -- storage.test"
13
+ "test": "jest --detectOpenHandles",
14
+ "build-tsup": "tsup src/index.ts --format esm,cjs,iife --dts --d dist/@salla.sa/base",
15
+ "lint": "tsc",
16
+ "browserify": "browserify dist/index.js > dist/sallaBase.js"
13
17
  },
14
18
  "repository": {
15
19
  "type": "git",
@@ -36,30 +40,48 @@
36
40
  "package.json"
37
41
  ],
38
42
  "dependencies": {
43
+ "@rollup/plugin-node-resolve": "^15.1.0",
44
+ "@types/universal-cookie": "^3.0.0",
39
45
  "eventemitter2": "^6.4.7",
40
46
  "lodash": "^4.17.21",
41
- "store": "^2.0.12"
47
+ "store": "^2.0.12",
48
+ "universal-cookie": "^6.1.0"
42
49
  },
43
50
  "devDependencies": {
44
51
  "@babel/core": "^7.18.10",
45
52
  "@babel/preset-env": "^7.18.10",
46
53
  "@optimize-lodash/rollup-plugin": "^4.0.3",
47
54
  "@rollup/plugin-babel": "^5.3.1",
48
- "@rollup/plugin-commonjs": "^25.0.4",
49
- "@rollup/plugin-typescript": "^11.1.1",
55
+ "@rollup/plugin-commonjs": "^22.0.2",
56
+ "@rollup/plugin-typescript": "^11.1.3",
57
+ "@types/jest": "^29.5.1",
58
+ "@types/lodash": "^4.14.195",
59
+ "@types/node": "^20.8.2",
60
+ "@types/store": "^2.0.2",
61
+ "browserify": "^17.0.0",
62
+ "esbuild": "^0.19.2",
63
+ "html-webpack-plugin": "^5.5.3",
50
64
  "jest": "^29.3.1",
51
65
  "jest-environment-jsdom": "^29.3.1",
52
66
  "rollup": "^2.79.1",
53
67
  "rollup-jest": "^3.1.0",
54
68
  "rollup-plugin-analyzer": "^4.0.0",
55
69
  "rollup-plugin-cleaner": "^1.0.0",
70
+ "rollup-plugin-esbuild": "^5.0.0",
56
71
  "rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
57
72
  "rollup-plugin-node-polyfills": "^0.2.1",
58
73
  "rollup-plugin-serve": "^2.0.1",
59
74
  "rollup-plugin-terser": "^7.0.2",
75
+ "rollup-plugin-typescript2": "^0.36.0",
60
76
  "rollup-plugin-version-injector": "^1.3.3",
61
77
  "sinon": "^15.0.1",
62
- "tslib": "^2.6.1"
78
+ "ts-jest": "^29.1.0",
79
+ "ts-loader": "^9.4.4",
80
+ "tslib": "^2.6.2",
81
+ "tsup": "^7.2.0",
82
+ "typescript": "^5.2.2",
83
+ "webpack": "^5.88.2",
84
+ "webpack-cli": "^5.1.4"
63
85
  },
64
- "gitHead": "1ce2fb8a15ad48237110009b5cc49acead2e61cd"
86
+ "gitHead": "e43ccbe0086ed916ecad8ac8cf952ece4e035e2e"
65
87
  }
package/types/config.d.ts CHANGED
@@ -1,53 +1,60 @@
1
+ import {Currency} from "./common";
2
+
1
3
  export type ConfigKey =
2
- 'maintenance'
3
- | 'debug'
4
- | 'events'
5
- | 'sdk'
6
- | 'sdk.notifier_handler_disabled'
7
- | 'store'
8
- | 'store.url'
9
- | 'store.id'
10
- | 'store.logo'
11
- | 'store.name'
12
- | 'store.api'
13
- | 'store.settings'
14
- | 'store.settings.auth'
15
- | 'store.settings.auth.email_allowed'
16
- | 'store.settings.auth.mobile_allowed'
17
- | 'store.settings.auth.is_email_required'
18
- | 'store.arabic_numbers_enabled'
19
- | 'store.payments'
20
- | 'store.installments'
21
- | 'user.type'
22
- | 'user.id'
23
- | 'user.email'
24
- | 'user.mobile'
25
- | 'user.language_code'
26
- | 'user.currency_code'
27
- | 'user.country_code'
28
- | 'theme.name'
29
- | 'theme.mode'
30
- | 'theme.translations_hash'
31
- | 'theme.color'
32
- | 'theme.color.primary'
33
- | 'theme.color.text'
34
- | 'theme.color.is_dark'
35
- | 'theme.color.reverse_primary'
36
- | 'theme.color.reverse_text'
37
- | 'languages.ar'
38
- | 'languages.en'
39
- | '`languages.${string}`'
40
- | 'currencies.SAR'
41
- | 'currencies.USD'
42
- | '`currencies.${string}`'
43
- | 'page.title'
44
- | 'page.slug'
45
- | 'page.id';
4
+ 'maintenance'
5
+ | 'debug'
6
+ | 'events'
7
+ | 'sdk'
8
+ | 'sdk.notifier_handler_disabled'
9
+ | 'store'
10
+ | 'store.url'
11
+ | 'store.id'
12
+ | 'store.logo'
13
+ | 'store.name'
14
+ | 'store.api'
15
+ | 'store.settings'
16
+ | 'store.settings.auth'
17
+ | 'store.settings.auth.email_allowed'
18
+ | 'store.settings.auth.mobile_allowed'
19
+ | 'store.settings.auth.is_email_required'
20
+ | 'store.arabic_numbers_enabled'
21
+ | 'store.payments'
22
+ | 'store.installments'
23
+ | 'user.type'
24
+ | 'user.id'
25
+ | 'user.email'
26
+ | 'user.mobile'
27
+ | 'user.language_code'
28
+ | 'user.currency_code'
29
+ | 'user.country_code'
30
+ | 'theme.name'
31
+ | 'theme.mode'
32
+ | 'theme.translations_hash'
33
+ | 'theme.color'
34
+ | 'theme.color.primary'
35
+ | 'theme.color.text'
36
+ | 'theme.color.is_dark'
37
+ | 'theme.color.reverse_primary'
38
+ | 'theme.color.reverse_text'
39
+ | 'languages.ar'
40
+ | 'languages.en'
41
+ | '`languages.${string}`'
42
+ | 'currencies.SAR'
43
+ | 'currencies.USD'
44
+ | '`currencies.${string}`'
45
+ | 'page.title'
46
+ | 'page.slug'
47
+ | 'page.id';
46
48
 
47
- export default interface Config {
48
- merge: (config: any) => Config;
49
- set: (key: ConfigKey | string, value: string | any) => Config;
50
- get: (key: ConfigKey | string, default_?: any) => any;
51
- all: () => any;
52
- isDebug: () => boolean; // you can make it debug in all requests using salla.storage.set('debug',true)
49
+ export default interface SallaConfig {
50
+ merge: (config: any) => SallaConfig;
51
+ set: (key: ConfigKey | string, value: string | any) => SallaConfig;
52
+ get: (key: ConfigKey | string, default_?: any) => any;
53
+ all: () => any;
54
+ currency: (isoCode?: string) => Currency;
55
+ isDebug: () => boolean; // you can make it debug in all requests using salla.storage.set('debug',true)
56
+ isUser: () => boolean;
57
+ isGuest: () => boolean;
58
+ languages?: () => any;
59
+ currencies?: () => any;
53
60
  }
package/types/event.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EventEmitter2 } from "eventemitter2";
1
+ import {EventEmitter2, Listener} from "eventemitter2";
2
2
 
3
3
  export type event = symbol | string;
4
4
  export type EventName =
@@ -111,22 +111,22 @@ export type EventName =
111
111
  | "booking::addition.failed";
112
112
 
113
113
  export type typeSafeEvents = {
114
- [key: event]: (...args: any[]) => void
114
+ [key: event]: (...args: any[]) => void
115
115
  }
116
116
 
117
117
  /**
118
118
  * @property string delimiter
119
119
  */
120
120
  export default interface Emitter extends EventEmitter2 {
121
- delimiter: string;
121
+ delimiter: string;
122
122
 
123
- dispatchEvents: (events: { [event_name: string]: any }) => void;
123
+ dispatchEvents: (events: { [event_name: string]: any }) => void;
124
124
 
125
- dispatch: (event_name: EventName, ...data: undefined | any) => void;
125
+ dispatch: (event_name: EventName, ...data: undefined | any) => void;
126
126
 
127
- on(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this;
127
+ on(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this|Listener;
128
128
 
129
- once(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this;
129
+ once(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this|Listener;
130
130
 
131
- listen(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this;
131
+ listen(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this | Listener;
132
132
  }
package/types/global.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- import SallaType from "../types";
1
+ import SallaBaseInterface from "../types";
2
2
 
3
3
  declare global {
4
4
  interface Window {
5
5
  dataLayer?: Array<any>;
6
6
  webkit?: any;
7
7
  Android?: any;
8
- salla: SallaType|any;
9
- Salla: SallaType|any;
8
+ salla: any|SallaBaseInterface;//todo:: remove any
9
+ Salla: any|SallaBaseInterface;//todo:: remove any
10
10
  }
11
+
11
12
  interface String {
12
13
  toStudlyCase(): string;
13
14
  toDatasetName(): string;
@@ -17,6 +18,6 @@ declare global {
17
18
  ltrim(s?:string): string;
18
19
  digitsOnly(): string;
19
20
  }
20
- let salla: SallaType|any;
21
- let Salla: SallaType|any;
21
+ let Salla:any|SallaBaseInterface;//todo:: remove any
22
+ let salla:any|SallaBaseInterface;//todo:: remove any
22
23
  }