UNPKG

@sega-so/sega-sdk

Version:

An SDK for building applications on top of SEGA.

2 lines 1.87 kB
var O=Object.defineProperty,b=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var f=Object.getOwnPropertySymbols;var l=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable;var d=(t,s,e)=>s in t?O(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e,u=(t,s)=>{for(var e in s||(s={}))l.call(s,e)&&d(t,e,s[e]);if(f)for(var e of f(s))m.call(s,e)&&d(t,e,s[e]);return t},c=(t,s)=>b(t,N(s));var p=(t,s)=>{var e={};for(var r in t)l.call(t,r)&&s.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&f)for(var r of f(t))s.indexOf(r)<0&&m.call(t,r)&&(e[r]=t[r]);return e};var h=(t,s,e)=>new Promise((r,g)=>{var i=n=>{try{a(e.next(n))}catch(o){g(o)}},y=n=>{try{a(e.throw(n))}catch(o){g(o)}},a=n=>n.done?r(n.value):Promise.resolve(n.value).then(i,y);a((e=e.apply(t,s)).next())});var w="ray_tab_hash",S="ray_req_hash",J=()=>{if(typeof window===void 0)return"";let t=sessionStorage.getItem(w);return t||(t=`ray-${Date.now()}`,sessionStorage.setItem(w,t)),t},I=r=>h(void 0,null,function*(){var g=r,{logCount:t=1e3,removeLastLog:s}=g,e=p(g,["logCount","removeLastLog"]);if(typeof window===void 0)return new Promise(y=>y());let i=JSON.parse(localStorage.getItem(S)||"[]").slice(0,t-1);s&&i.pop(),new Blob([JSON.stringify(e.data)]).size>1024&&(e.data=JSON.stringify(e.data).substring(0,200)+"..."),i.unshift(c(u({},e),{time:Date.now(),session:J()}));try{localStorage.setItem(S,JSON.stringify(i))}catch(y){if(s){let a=!1,n=JSON.stringify(e.data).substring(0,100);for(i[0].data=n+(n.length>100?"...":"");!a;){i.pop();let o=JSON.stringify(e.data).substring(0,100);i[0].data=o+(o.length>100?"...":"");try{localStorage.setItem(S,JSON.stringify(i)),a=!0}catch(_){a=!1}}return new Promise(o=>o())}return I(c(u({},e),{logCount:t,removeLastLog:!0}))}});export{w as SESSION_KEY,S as STORAGE_KEY,J as getSessionKey,I as updateReqHistory}; //# sourceMappingURL=utils.mjs.map