@sega-so/sega-sdk
Version:
An SDK for building applications on top of SEGA.
2 lines • 2.32 kB
JavaScript
;var u=Object.defineProperty,J=Object.defineProperties,I=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var p=(t,s,e)=>s in t?u(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e,d=(t,s)=>{for(var e in s||(s={}))S.call(s,e)&&p(t,e,s[e]);if(f)for(var e of f(s))h.call(s,e)&&p(t,e,s[e]);return t},l=(t,s)=>J(t,_(s));var w=(t,s)=>{var e={};for(var r in t)S.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&&h.call(t,r)&&(e[r]=t[r]);return e};var R=(t,s)=>{for(var e in s)u(t,e,{get:s[e],enumerable:!0})},E=(t,s,e,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of x(s))!S.call(t,n)&&n!==e&&u(t,n,{get:()=>s[n],enumerable:!(r=I(s,n))||r.enumerable});return t};var H=t=>E(u({},"__esModule",{value:!0}),t);var O=(t,s,e)=>new Promise((r,n)=>{var o=i=>{try{g(e.next(i))}catch(a){n(a)}},y=i=>{try{g(e.throw(i))}catch(a){n(a)}},g=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,y);g((e=e.apply(t,s)).next())});var K={};R(K,{SESSION_KEY:()=>m,STORAGE_KEY:()=>c,getSessionKey:()=>b,updateReqHistory:()=>N});module.exports=H(K);var m="ray_tab_hash",c="ray_req_hash",b=()=>{if(typeof window===void 0)return"";let t=sessionStorage.getItem(m);return t||(t=`ray-${Date.now()}`,sessionStorage.setItem(m,t)),t},N=r=>O(void 0,null,function*(){var n=r,{logCount:t=1e3,removeLastLog:s}=n,e=w(n,["logCount","removeLastLog"]);if(typeof window===void 0)return new Promise(y=>y());let o=JSON.parse(localStorage.getItem(c)||"[]").slice(0,t-1);s&&o.pop(),new Blob([JSON.stringify(e.data)]).size>1024&&(e.data=JSON.stringify(e.data).substring(0,200)+"..."),o.unshift(l(d({},e),{time:Date.now(),session:b()}));try{localStorage.setItem(c,JSON.stringify(o))}catch(y){if(s){let g=!1,i=JSON.stringify(e.data).substring(0,100);for(o[0].data=i+(i.length>100?"...":"");!g;){o.pop();let a=JSON.stringify(e.data).substring(0,100);o[0].data=a+(a.length>100?"...":"");try{localStorage.setItem(c,JSON.stringify(o)),g=!0}catch(P){g=!1}}return new Promise(a=>a())}return N(l(d({},e),{logCount:t,removeLastLog:!0}))}});0&&(module.exports={SESSION_KEY,STORAGE_KEY,getSessionKey,updateReqHistory});
//# sourceMappingURL=utils.js.map