@jolibox/sdk 1.1.8 → 1.1.9-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "7f17ee90c6b8d33d172f5e743a3a97c8fa8a3989",
7
- "packages/sdk/package.json": "5d53db3f018495c20958948591ff5ba3bcf0318f",
7
+ "packages/sdk/package.json": "fb72c422dca64765039fafe6f635fb8b11046359",
8
8
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
9
9
  "packages/sdk/src/api/can-i-use.ts": "4fd7efe21419d39e535584d7ab8e6a3c4e186877",
10
10
  "packages/sdk/src/api/get-system-info.ts": "c73be9f62c7055093effadaf6c48c54d6f383542",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty,qe=Object.defineProperties,Ze=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertyNames,ae=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var ce=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))me.call(t,r)&&ce(e,r,t[r]);if(ae)for(var r of ae(t))rt.call(t,r)&&ce(e,r,t[r]);return e},R=(e,t)=>qe(e,et(t));var nt=(e,t)=>{for(var r in t)L(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tt(t))!me.call(e,s)&&s!==r&&L(e,s,{get:()=>t[s],enumerable:!(n=Ze(t,s))||n.enumerable});return e};var ot=e=>st(L({},"__esModule",{value:!0}),e);var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var Qt={};nt(Qt,{JoliboxSDK:()=>$});module.exports=ot(Qt);var de=Object.defineProperty,it=Object.getOwnPropertyDescriptor,at=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,n)=>{for(var s=n>1?void 0:n?it(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&de(t,r,s),s};function ct(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Y(e){return typeof e=="string"}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function mt(e){return typeof e>"u"}function lt(e){return mt(e)||e===null}function dt(e){return typeof e=="function"}function fe(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var ut=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(ut||{}),pt=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},he=class extends pt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ge=class extends he{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends he{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var ft={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:ft});var Ee=Symbol.for("Jolibox.canIUseMap"),ht={};globalThis[Ee]=ht;var _e={get config(){return globalThis[Ee]}};function Q(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var X=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(X||{}),q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(q||{}),gt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(gt||{}),le=["name","params"],Et=["name","type","location","target","extra","timestamp","userId"],_t=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function yt(e){let t=e.location?C(e.location,le):null,r=e.target?C(e.target,le):null;return C(R(y({},e),{location:t,target:r}),Et)}function ye(e){let t=e.events.map(n=>yt(n)),r=C(e.device,_t);return[e.protocolVersion,t,r,e.project]}var St=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var k={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},xt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",vt="device_id",Rt="advertising_id",Se=e=>(localStorage.getItem(e)||localStorage.setItem(e,St()),localStorage.getItem(e)),It=()=>Se(vt),bt=()=>Se(Rt),Tt=e=>e.charAt(0).toUpperCase()+e.slice(1),At=()=>{var t;let e=new URLSearchParams(window.location.search);return Tt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},xe=e=>{let t="JoliboxWebSDK",r=xt(),n=navigator.language,s=It(),o=bt();return`${t} (${At()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),wt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Dt=0,O=class{constructor(e){this.value=e,this.id=Dt++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof O&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new O(t);this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof O?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Z=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new wt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};at(W,{None:()=>Ut,filter:()=>kt,once:()=>ve,toPromise:()=>Lt});var Ut=()=>{console.log("[Jolibox SDK] None Event")};function Lt(e){return new Promise(t=>ve(e)(t))}function ve(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function kt(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var G=Symbol.for("Jolibox.hostEmitter"),Ot=()=>{let e=new Z;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},Re=Ot();function Ct(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Pt(e[n],t[n])}function Pt(e,t){if(Y(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(dt(t)){try{if(e instanceof t)return}catch(r){}if(!lt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ct(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};P=ue([fe],P);var z=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ct(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),W.toPromise(W.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};z=ue([fe],z);var H=Symbol.for("Jolibox.commands");function E(){if(globalThis[H])return globalThis[H];let e=new P,t=new z,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[H]=r,r}var K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Kt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Mt(){return{platform:1e3,os:"h5",appVersion:"1.1.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.8",extra:{}}}var Ie={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Nt=()=>{var t;let e=(t=Ie[window.location.host])!=null?t:Ie.default;return K?e.test:e.prod},jt=Nt(),Te=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},be;(be=AbortSignal.timeout)!=null||(AbortSignal.timeout=Te);var Jt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Ft=Jt(),Bt=e=>l(void 0,null,function*(){let r=`${jt}/report`,n=xe("1.1.8"),s=Ft,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Te(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:X.ErrorTrace,location:Kt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Mt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:q.WebSDK},o=ye(s);Bt(o)})}document.addEventListener("DOMContentLoaded",()=>Re.emit("onDocumentReady",A.startTime));var Vt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Vt(),Ae=E(),ee=e=>{Ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},te=ee;window.addEventListener("unhandledrejection",ee.bind(void 0));window.addEventListener("error",ee.bind(void 0));window.onerror=(e,t,r,n,s)=>{Ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var re=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(re(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=re(e),{major:i,minor:c,patch:m,prerelease:a}=re(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var we=E(),M=(e,t)=>{we.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{we.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var ke="jolibox-sdk-loadermeta",Le,U=JSON.parse((Le=localStorage.getItem(ke))!=null?Le:"{}"),ne=Date.now(),De=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,Ue=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function $t(){return l(this,null,function*(){let t=`${K?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:ne});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(se(s))).text();Ue(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(oe(n))).text();Ue(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(ke,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Oe=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!De(ne,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new ge(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();M("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Xe=yield import(u);return URL.revokeObjectURL(u),Xe}catch(p){let u=new I(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!De(ne,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),$t()}catch(a){let h=new I(`module evaluate error: ${a}`);S({err:`${h}`})}}};var Ce=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){te(new I(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();M("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),te(new I(`module load failed ${s}`))}}};var Gt="1.1.8",N=Gt,Me=w(N),Ne=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ht=Ne?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,oe=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Wt=e=>/^\d+\.\d+\.\d+$/.test(e),je=Wt(N)?Me:N,Pe=se(je),Ke=oe(je);function zt(){Ne?Ce(Ht,{bootstrapUrl:Pe,implementUrl:Ke})():Oe({bootstrapUrl:Pe,implementUrl:Ke,currentMajorVersion:Me,currentVersion:N})()}zt();var Je=E();function Fe(){return Je.excuteCommandSync("API.getSystemInfoSync")}function Be(){return Je.excuteCommandSync("API.env")}function Ve(e,t){var r;return(r=_e.config[e])==null?void 0:r[t]}function $e(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var He="1.1.8";function v(e){var c,m;let r=(m=(c=Be().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Ve(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||Q(He,i,"<")?!1:s.length===0?!0:Ge(o,s)||Ge(o.properties,s)}function Ge(e,t){if(!e)return!1;let r=$e(e,t);return r?pe(r)?!0:Y(r)?Q(He,r,">="):!1:!1}var We=E();function ze(){return l(this,null,function*(){return v("login")?yield We.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ye(){return l(this,null,function*(){return v("checkSession")?yield We.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ie=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},Qe=window.JoliboxRuntime||ie;var f=class{constructor(){this.commands=E();this._emitter=new Z}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Yt="LifecycleSDK.onReady",j=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Yt,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var F=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var $=class{constructor(){this.jssdkVersion="1.1.8";this.runtime=new Qe;this.ads=new F;this.lifecycle=new j;this.storage=new J;this.keyboard=new B;this.task=new V;this.getSystemInfoSync=Fe.bind(this);this.canIUse=v.bind(this);this.login=ze.bind(this);this.checkSession=Ye.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=$;
1
+ "use strict";var L=Object.defineProperty,qe=Object.defineProperties,Ze=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertyNames,ae=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var ce=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))me.call(t,r)&&ce(e,r,t[r]);if(ae)for(var r of ae(t))rt.call(t,r)&&ce(e,r,t[r]);return e},R=(e,t)=>qe(e,et(t));var nt=(e,t)=>{for(var r in t)L(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tt(t))!me.call(e,s)&&s!==r&&L(e,s,{get:()=>t[s],enumerable:!(n=Ze(t,s))||n.enumerable});return e};var ot=e=>st(L({},"__esModule",{value:!0}),e);var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var Qt={};nt(Qt,{JoliboxSDK:()=>$});module.exports=ot(Qt);var de=Object.defineProperty,it=Object.getOwnPropertyDescriptor,at=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},ue=(e,t,r,n)=>{for(var s=n>1?void 0:n?it(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&de(t,r,s),s};function ct(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Y(e){return typeof e=="string"}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function mt(e){return typeof e>"u"}function lt(e){return mt(e)||e===null}function dt(e){return typeof e=="function"}function fe(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var ut=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(ut||{}),pt=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},he=class extends pt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ge=class extends he{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends he{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var ft={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:ft});var Ee=Symbol.for("Jolibox.canIUseMap"),ht={};globalThis[Ee]=ht;var _e={get config(){return globalThis[Ee]}};function Q(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var X=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(X||{}),q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(q||{}),gt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(gt||{}),le=["name","params"],Et=["name","type","location","target","extra","timestamp","userId"],_t=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function yt(e){let t=e.location?C(e.location,le):null,r=e.target?C(e.target,le):null;return C(R(y({},e),{location:t,target:r}),Et)}function ye(e){let t=e.events.map(n=>yt(n)),r=C(e.device,_t);return[e.protocolVersion,t,r,e.project]}var St=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var k={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},xt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",vt="device_id",Rt="advertising_id",Se=e=>(localStorage.getItem(e)||localStorage.setItem(e,St()),localStorage.getItem(e)),bt=()=>Se(vt),It=()=>Se(Rt),Tt=e=>e.charAt(0).toUpperCase()+e.slice(1),At=()=>{var t;let e=new URLSearchParams(window.location.search);return Tt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},xe=e=>{let t="JoliboxWebSDK",r=xt(),n=navigator.language,s=bt(),o=It();return`${t} (${At()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),wt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Dt=0,O=class{constructor(e){this.value=e,this.id=Dt++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof O&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new O(t);this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof O?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Z=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new wt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};at(W,{None:()=>Ut,filter:()=>kt,once:()=>ve,toPromise:()=>Lt});var Ut=()=>{console.log("[Jolibox SDK] None Event")};function Lt(e){return new Promise(t=>ve(e)(t))}function ve(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function kt(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var G=Symbol.for("Jolibox.hostEmitter"),Ot=()=>{let e=new Z;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},Re=Ot();function Ct(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Pt(e[n],t[n])}function Pt(e,t){if(Y(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(dt(t)){try{if(e instanceof t)return}catch(r){}if(!lt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ct(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};P=ue([fe],P);var z=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ct(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),W.toPromise(W.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};z=ue([fe],z);var H=Symbol.for("Jolibox.commands");function E(){if(globalThis[H])return globalThis[H];let e=new P,t=new z,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[H]=r,r}var K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Kt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Mt(){return{platform:1e3,os:"h5",appVersion:"1.1.9-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.9-beta.1",extra:{}}}var be={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Nt=()=>{var t;let e=(t=be[window.location.host])!=null?t:be.default;return K?e.test:e.prod},jt=Nt(),Te=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ie;(Ie=AbortSignal.timeout)!=null||(AbortSignal.timeout=Te);var Jt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Ft=Jt(),Bt=e=>l(void 0,null,function*(){let r=`${jt}/report`,n=xe("1.1.9-beta.1"),s=Ft,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Te(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:X.ErrorTrace,location:Kt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Mt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:q.WebSDK},o=ye(s);Bt(o)})}document.addEventListener("DOMContentLoaded",()=>Re.emit("onDocumentReady",A.startTime));var Vt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Vt(),Ae=E(),ee=e=>{Ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},te=ee;window.addEventListener("unhandledrejection",ee.bind(void 0));window.addEventListener("error",ee.bind(void 0));window.onerror=(e,t,r,n,s)=>{Ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var re=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(re(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=re(e),{major:i,minor:c,patch:m,prerelease:a}=re(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var we=E(),M=(e,t)=>{we.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{we.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var ke="jolibox-sdk-loadermeta",Le,U=JSON.parse((Le=localStorage.getItem(ke))!=null?Le:"{}"),ne=Date.now(),De=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,Ue=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function $t(){return l(this,null,function*(){let t=`${K?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:ne});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(se(s))).text();Ue(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(oe(n))).text();Ue(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(ke,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Oe=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!De(ne,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new ge(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();M("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Xe=yield import(u);return URL.revokeObjectURL(u),Xe}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!De(ne,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),$t()}catch(a){let h=new b(`module evaluate error: ${a}`);S({err:`${h}`})}}};var Ce=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){te(new b(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();M("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),te(new b(`module load failed ${s}`))}}};var Gt="1.1.9-beta.1",N=Gt,Me=w(N),Ne=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ht=Ne?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,oe=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Wt=e=>/^\d+\.\d+\.\d+$/.test(e),je=Wt(N)?Me:N,Pe=se(je),Ke=oe(je);function zt(){Ne?Ce(Ht,{bootstrapUrl:Pe,implementUrl:Ke})():Oe({bootstrapUrl:Pe,implementUrl:Ke,currentMajorVersion:Me,currentVersion:N})()}zt();var Je=E();function Fe(){return Je.excuteCommandSync("API.getSystemInfoSync")}function Be(){return Je.excuteCommandSync("API.env")}function Ve(e,t){var r;return(r=_e.config[e])==null?void 0:r[t]}function $e(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var He="1.1.9-beta.1";function v(e){var c,m;let r=(m=(c=Be().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Ve(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||Q(He,i,"<")?!1:s.length===0?!0:Ge(o,s)||Ge(o.properties,s)}function Ge(e,t){if(!e)return!1;let r=$e(e,t);return r?pe(r)?!0:Y(r)?Q(He,r,">="):!1:!1}var We=E();function ze(){return l(this,null,function*(){return v("login")?yield We.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ye(){return l(this,null,function*(){return v("checkSession")?yield We.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ie=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},Qe=window.JoliboxRuntime||ie;var f=class{constructor(){this.commands=E();this._emitter=new Z}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Yt="LifecycleSDK.onReady",j=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Yt,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var F=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var $=class{constructor(){this.jssdkVersion="1.1.9-beta.1";this.runtime=new Qe;this.ads=new F;this.lifecycle=new j;this.storage=new J;this.keyboard=new B;this.task=new V;this.getSystemInfoSync=Fe.bind(this);this.canIUse=v.bind(this);this.login=ze.bind(this);this.checkSession=Ye.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=$;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var Qe=Object.defineProperty,Xe=Object.defineProperties;var qe=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))Ze.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))et.call(t,r)&&ae(e,r,t[r]);return e},R=(e,t)=>Xe(e,qe(t));var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var me=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,n)=>{for(var s=n>1?void 0:n?tt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&me(t,r,s),s};function nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function W(e){return typeof e=="string"}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function st(e){return typeof e>"u"}function ot(e){return st(e)||e===null}function it(e){return typeof e=="function"}function ue(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var at=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(at||{}),ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},pe=class extends ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var fe=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var mt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:mt});var he=Symbol.for("Jolibox.canIUseMap"),lt={};globalThis[he]=lt;var ge={get config(){return globalThis[he]}};function z(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var Y=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Y||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(dt||{}),ce=["name","params"],ut=["name","type","location","target","extra","timestamp","userId"],pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function ft(e){let t=e.location?O(e.location,ce):null,r=e.target?O(e.target,ce):null;return O(R(y({},e),{location:t,target:r}),ut)}function Ee(e){let t=e.events.map(n=>ft(n)),r=O(e.device,pt);return[e.protocolVersion,t,r,e.project]}var ht=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var L={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},gt=()=>L.isiOS?"iOS":L.isAndroid?"Android":L.isMac?"Mac":L.isFacebook?"Facebook":"PC",Et="device_id",_t="advertising_id",_e=e=>(localStorage.getItem(e)||localStorage.setItem(e,ht()),localStorage.getItem(e)),yt=()=>_e(Et),St=()=>_e(_t),xt=e=>e.charAt(0).toUpperCase()+e.slice(1),vt=()=>{var t;let e=new URLSearchParams(window.location.search);return xt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},ye=e=>{let t="JoliboxWebSDK",r=gt(),n=navigator.language,s=yt(),o=St();return`${t} (${vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),Rt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},It=0,k=class{constructor(e){this.value=e,this.id=It++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof k&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new k(t);this._listeners?this._listeners instanceof k?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof k?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},X=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Rt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};rt(G,{None:()=>bt,filter:()=>At,once:()=>Se,toPromise:()=>Tt});var bt=()=>{console.log("[Jolibox SDK] None Event")};function Tt(e){return new Promise(t=>Se(e)(t))}function Se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function At(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var V=Symbol.for("Jolibox.hostEmitter"),wt=()=>{let e=new X;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},xe=wt();function Dt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ut(e[n],t[n])}function Ut(e,t){if(W(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(it(t)){try{if(e instanceof t)return}catch(r){}if(!ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var C=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Dt(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};C=le([ue],C);var H=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new C,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nt(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};H=le([ue],H);var $=Symbol.for("Jolibox.commands");function E(){if(globalThis[$])return globalThis[$];let e=new C,t=new H,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[$]=r,r}var P=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Lt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function kt(){return{platform:1e3,os:"h5",appVersion:"1.1.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.8",extra:{}}}var ve={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Ot=()=>{var t;let e=(t=ve[window.location.host])!=null?t:ve.default;return P?e.test:e.prod},Ct=Ot(),Ie=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Re;(Re=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ie);var Pt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Kt=Pt(),Mt=e=>l(void 0,null,function*(){let r=`${Ct}/report`,n=ye("1.1.8"),s=Kt,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Ie(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:Y.ErrorTrace,location:Lt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=kt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:Q.WebSDK},o=Ee(s);Mt(o)})}document.addEventListener("DOMContentLoaded",()=>xe.emit("onDocumentReady",A.startTime));var Nt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Nt(),be=E(),q=e=>{be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},Z=q;window.addEventListener("unhandledrejection",q.bind(void 0));window.addEventListener("error",q.bind(void 0));window.onerror=(e,t,r,n,s)=>{be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var ee=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(ee(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ee(e),{major:i,minor:c,patch:m,prerelease:a}=ee(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var Te=E(),K=(e,t)=>{Te.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Te.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var Ue="jolibox-sdk-loadermeta",De,U=JSON.parse((De=localStorage.getItem(Ue))!=null?De:"{}"),te=Date.now(),Ae=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,we=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function jt(){return l(this,null,function*(){let t=`${P?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:te});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(re(s))).text();we(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(ne(n))).text();we(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(Ue,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Le=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!Ae(te,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new fe(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();K("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Ye=yield import(u);return URL.revokeObjectURL(u),Ye}catch(p){let u=new I(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!Ae(te,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),jt()}catch(a){let h=new I(`module evaluate error: ${a}`);S({err:`${h}`})}}};var ke=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){Z(new I(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();K("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),Z(new I(`module load failed ${s}`))}}};var Jt="1.1.8",M=Jt,Pe=w(M),Ke=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ft=Ke?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,re=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,ne=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Bt=e=>/^\d+\.\d+\.\d+$/.test(e),Me=Bt(M)?Pe:M,Oe=re(Me),Ce=ne(Me);function Vt(){Ke?ke(Ft,{bootstrapUrl:Oe,implementUrl:Ce})():Le({bootstrapUrl:Oe,implementUrl:Ce,currentMajorVersion:Pe,currentVersion:M})()}Vt();var Ne=E();function je(){return Ne.excuteCommandSync("API.getSystemInfoSync")}function Je(){return Ne.excuteCommandSync("API.env")}function Fe(e,t){var r;return(r=ge.config[e])==null?void 0:r[t]}function Be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var $e="1.1.8";function v(e){var c,m;let r=(m=(c=Je().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Fe(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||z($e,i,"<")?!1:s.length===0?!0:Ve(o,s)||Ve(o.properties,s)}function Ve(e,t){if(!e)return!1;let r=Be(e,t);return r?de(r)?!0:W(r)?z($e,r,">="):!1:!1}var Ge=E();function He(){return l(this,null,function*(){return v("login")?yield Ge.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function We(){return l(this,null,function*(){return v("checkSession")?yield Ge.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var se=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},ze=window.JoliboxRuntime||se;var f=class{constructor(){this.commands=E();this._emitter=new X}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var $t="LifecycleSDK.onReady",N=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent($t,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var oe=class{constructor(){this.jssdkVersion="1.1.8";this.runtime=new ze;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.getSystemInfoSync=je.bind(this);this.canIUse=v.bind(this);this.login=He.bind(this);this.checkSession=We.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=oe;export{oe as JoliboxSDK};
1
+ var Qe=Object.defineProperty,Xe=Object.defineProperties;var qe=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))Ze.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))et.call(t,r)&&ae(e,r,t[r]);return e},R=(e,t)=>Xe(e,qe(t));var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var me=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,n)=>{for(var s=n>1?void 0:n?tt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&me(t,r,s),s};function nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function W(e){return typeof e=="string"}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function st(e){return typeof e>"u"}function ot(e){return st(e)||e===null}function it(e){return typeof e=="function"}function ue(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var at=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(at||{}),ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},pe=class extends ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var fe=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var mt={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:mt});var he=Symbol.for("Jolibox.canIUseMap"),lt={};globalThis[he]=lt;var ge={get config(){return globalThis[he]}};function z(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var Y=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Y||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(dt||{}),ce=["name","params"],ut=["name","type","location","target","extra","timestamp","userId"],pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function ft(e){let t=e.location?O(e.location,ce):null,r=e.target?O(e.target,ce):null;return O(R(y({},e),{location:t,target:r}),ut)}function Ee(e){let t=e.events.map(n=>ft(n)),r=O(e.device,pt);return[e.protocolVersion,t,r,e.project]}var ht=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var L={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},gt=()=>L.isiOS?"iOS":L.isAndroid?"Android":L.isMac?"Mac":L.isFacebook?"Facebook":"PC",Et="device_id",_t="advertising_id",_e=e=>(localStorage.getItem(e)||localStorage.setItem(e,ht()),localStorage.getItem(e)),yt=()=>_e(Et),St=()=>_e(_t),xt=e=>e.charAt(0).toUpperCase()+e.slice(1),vt=()=>{var t;let e=new URLSearchParams(window.location.search);return xt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},ye=e=>{let t="JoliboxWebSDK",r=gt(),n=navigator.language,s=yt(),o=St();return`${t} (${vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),Rt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},bt=0,k=class{constructor(e){this.value=e,this.id=bt++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof k&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new k(t);this._listeners?this._listeners instanceof k?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof k?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},X=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Rt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};rt(G,{None:()=>It,filter:()=>At,once:()=>Se,toPromise:()=>Tt});var It=()=>{console.log("[Jolibox SDK] None Event")};function Tt(e){return new Promise(t=>Se(e)(t))}function Se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function At(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var V=Symbol.for("Jolibox.hostEmitter"),wt=()=>{let e=new X;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},xe=wt();function Dt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ut(e[n],t[n])}function Ut(e,t){if(W(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(it(t)){try{if(e instanceof t)return}catch(r){}if(!ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var C=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Dt(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};C=le([ue],C);var H=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new C,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nt(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};H=le([ue],H);var $=Symbol.for("Jolibox.commands");function E(){if(globalThis[$])return globalThis[$];let e=new C,t=new H,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[$]=r,r}var P=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Lt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function kt(){return{platform:1e3,os:"h5",appVersion:"1.1.9-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.9-beta.1",extra:{}}}var ve={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Ot=()=>{var t;let e=(t=ve[window.location.host])!=null?t:ve.default;return P?e.test:e.prod},Ct=Ot(),be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Re;(Re=AbortSignal.timeout)!=null||(AbortSignal.timeout=be);var Pt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Kt=Pt(),Mt=e=>l(void 0,null,function*(){let r=`${Ct}/report`,n=ye("1.1.9-beta.1"),s=Kt,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:be(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:Y.ErrorTrace,location:Lt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=kt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:Q.WebSDK},o=Ee(s);Mt(o)})}document.addEventListener("DOMContentLoaded",()=>xe.emit("onDocumentReady",A.startTime));var Nt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Nt(),Ie=E(),q=e=>{Ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},Z=q;window.addEventListener("unhandledrejection",q.bind(void 0));window.addEventListener("error",q.bind(void 0));window.onerror=(e,t,r,n,s)=>{Ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var ee=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(ee(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ee(e),{major:i,minor:c,patch:m,prerelease:a}=ee(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var Te=E(),K=(e,t)=>{Te.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Te.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var Ue="jolibox-sdk-loadermeta",De,U=JSON.parse((De=localStorage.getItem(Ue))!=null?De:"{}"),te=Date.now(),Ae=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,we=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function jt(){return l(this,null,function*(){let t=`${P?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:te});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(re(s))).text();we(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(ne(n))).text();we(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(Ue,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Le=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!Ae(te,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new fe(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();K("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Ye=yield import(u);return URL.revokeObjectURL(u),Ye}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!Ae(te,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),jt()}catch(a){let h=new b(`module evaluate error: ${a}`);S({err:`${h}`})}}};var ke=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){Z(new b(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();K("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),Z(new b(`module load failed ${s}`))}}};var Jt="1.1.9-beta.1",M=Jt,Pe=w(M),Ke=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ft=Ke?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,re=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,ne=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Bt=e=>/^\d+\.\d+\.\d+$/.test(e),Me=Bt(M)?Pe:M,Oe=re(Me),Ce=ne(Me);function Vt(){Ke?ke(Ft,{bootstrapUrl:Oe,implementUrl:Ce})():Le({bootstrapUrl:Oe,implementUrl:Ce,currentMajorVersion:Pe,currentVersion:M})()}Vt();var Ne=E();function je(){return Ne.excuteCommandSync("API.getSystemInfoSync")}function Je(){return Ne.excuteCommandSync("API.env")}function Fe(e,t){var r;return(r=ge.config[e])==null?void 0:r[t]}function Be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var $e="1.1.9-beta.1";function v(e){var c,m;let r=(m=(c=Je().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Fe(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||z($e,i,"<")?!1:s.length===0?!0:Ve(o,s)||Ve(o.properties,s)}function Ve(e,t){if(!e)return!1;let r=Be(e,t);return r?de(r)?!0:W(r)?z($e,r,">="):!1:!1}var Ge=E();function He(){return l(this,null,function*(){return v("login")?yield Ge.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function We(){return l(this,null,function*(){return v("checkSession")?yield Ge.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var se=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},ze=window.JoliboxRuntime||se;var f=class{constructor(){this.commands=E();this._emitter=new X}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var $t="LifecycleSDK.onReady",N=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent($t,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var oe=class{constructor(){this.jssdkVersion="1.1.9-beta.1";this.runtime=new ze;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.getSystemInfoSync=je.bind(this);this.canIUse=v.bind(this);this.login=He.bind(this);this.checkSession=We.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=oe;export{oe as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var Qe=Object.defineProperty,Xe=Object.defineProperties;var qe=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))Ze.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))et.call(t,r)&&ae(e,r,t[r]);return e},R=(e,t)=>Xe(e,qe(t));var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var me=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,n)=>{for(var s=n>1?void 0:n?tt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&me(t,r,s),s};function nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function W(e){return typeof e=="string"}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function st(e){return typeof e>"u"}function ot(e){return st(e)||e===null}function it(e){return typeof e=="function"}function ue(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var at=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(at||{}),ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},pe=class extends ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var fe=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var mt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:mt});var he=Symbol.for("Jolibox.canIUseMap"),lt={};globalThis[he]=lt;var ge={get config(){return globalThis[he]}};function z(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var Y=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Y||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(dt||{}),ce=["name","params"],ut=["name","type","location","target","extra","timestamp","userId"],pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function ft(e){let t=e.location?O(e.location,ce):null,r=e.target?O(e.target,ce):null;return O(R(y({},e),{location:t,target:r}),ut)}function Ee(e){let t=e.events.map(n=>ft(n)),r=O(e.device,pt);return[e.protocolVersion,t,r,e.project]}var ht=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var L={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},gt=()=>L.isiOS?"iOS":L.isAndroid?"Android":L.isMac?"Mac":L.isFacebook?"Facebook":"PC",Et="device_id",_t="advertising_id",_e=e=>(localStorage.getItem(e)||localStorage.setItem(e,ht()),localStorage.getItem(e)),yt=()=>_e(Et),St=()=>_e(_t),xt=e=>e.charAt(0).toUpperCase()+e.slice(1),vt=()=>{var t;let e=new URLSearchParams(window.location.search);return xt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},ye=e=>{let t="JoliboxWebSDK",r=gt(),n=navigator.language,s=yt(),o=St();return`${t} (${vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),Rt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},It=0,k=class{constructor(e){this.value=e,this.id=It++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof k&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new k(t);this._listeners?this._listeners instanceof k?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof k?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},X=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Rt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};rt(G,{None:()=>bt,filter:()=>At,once:()=>Se,toPromise:()=>Tt});var bt=()=>{console.log("[Jolibox SDK] None Event")};function Tt(e){return new Promise(t=>Se(e)(t))}function Se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function At(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var V=Symbol.for("Jolibox.hostEmitter"),wt=()=>{let e=new X;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},xe=wt();function Dt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ut(e[n],t[n])}function Ut(e,t){if(W(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(it(t)){try{if(e instanceof t)return}catch(r){}if(!ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var C=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Dt(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};C=le([ue],C);var H=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new C,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nt(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};H=le([ue],H);var $=Symbol.for("Jolibox.commands");function E(){if(globalThis[$])return globalThis[$];let e=new C,t=new H,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[$]=r,r}var P=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Lt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function kt(){return{platform:1e3,os:"h5",appVersion:"1.1.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.8",extra:{}}}var ve={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Ot=()=>{var t;let e=(t=ve[window.location.host])!=null?t:ve.default;return P?e.test:e.prod},Ct=Ot(),Ie=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Re;(Re=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ie);var Pt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Kt=Pt(),Mt=e=>l(void 0,null,function*(){let r=`${Ct}/report`,n=ye("1.1.8"),s=Kt,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Ie(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:Y.ErrorTrace,location:Lt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=kt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:Q.WebSDK},o=Ee(s);Mt(o)})}document.addEventListener("DOMContentLoaded",()=>xe.emit("onDocumentReady",A.startTime));var Nt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Nt(),be=E(),q=e=>{be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},Z=q;window.addEventListener("unhandledrejection",q.bind(void 0));window.addEventListener("error",q.bind(void 0));window.onerror=(e,t,r,n,s)=>{be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var ee=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(ee(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ee(e),{major:i,minor:c,patch:m,prerelease:a}=ee(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var Te=E(),K=(e,t)=>{Te.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Te.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var Ue="jolibox-sdk-loadermeta",De,U=JSON.parse((De=localStorage.getItem(Ue))!=null?De:"{}"),te=Date.now(),Ae=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,we=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function jt(){return l(this,null,function*(){let t=`${P?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:te});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(re(s))).text();we(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(ne(n))).text();we(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(Ue,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Le=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!Ae(te,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new fe(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();K("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Ye=yield import(u);return URL.revokeObjectURL(u),Ye}catch(p){let u=new I(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!Ae(te,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),jt()}catch(a){let h=new I(`module evaluate error: ${a}`);S({err:`${h}`})}}};var ke=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){Z(new I(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();K("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),Z(new I(`module load failed ${s}`))}}};var Jt="1.1.8",M=Jt,Pe=w(M),Ke=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ft=Ke?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,re=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,ne=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Bt=e=>/^\d+\.\d+\.\d+$/.test(e),Me=Bt(M)?Pe:M,Oe=re(Me),Ce=ne(Me);function Vt(){Ke?ke(Ft,{bootstrapUrl:Oe,implementUrl:Ce})():Le({bootstrapUrl:Oe,implementUrl:Ce,currentMajorVersion:Pe,currentVersion:M})()}Vt();var Ne=E();function je(){return Ne.excuteCommandSync("API.getSystemInfoSync")}function Je(){return Ne.excuteCommandSync("API.env")}function Fe(e,t){var r;return(r=ge.config[e])==null?void 0:r[t]}function Be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var $e="1.1.8";function v(e){var c,m;let r=(m=(c=Je().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Fe(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||z($e,i,"<")?!1:s.length===0?!0:Ve(o,s)||Ve(o.properties,s)}function Ve(e,t){if(!e)return!1;let r=Be(e,t);return r?de(r)?!0:W(r)?z($e,r,">="):!1:!1}var Ge=E();function He(){return l(this,null,function*(){return v("login")?yield Ge.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function We(){return l(this,null,function*(){return v("checkSession")?yield Ge.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var se=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},ze=window.JoliboxRuntime||se;var f=class{constructor(){this.commands=E();this._emitter=new X}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var $t="LifecycleSDK.onReady",N=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent($t,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var oe=class{constructor(){this.jssdkVersion="1.1.8";this.runtime=new ze;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.getSystemInfoSync=je.bind(this);this.canIUse=v.bind(this);this.login=He.bind(this);this.checkSession=We.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=oe;})();
1
+ "use strict";(()=>{var Qe=Object.defineProperty,Xe=Object.defineProperties;var qe=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))Ze.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))et.call(t,r)&&ae(e,r,t[r]);return e},R=(e,t)=>Xe(e,qe(t));var l=(e,t,r)=>new Promise((n,s)=>{var o=m=>{try{c(r.next(m))}catch(a){s(a)}},i=m=>{try{c(r.throw(m))}catch(a){s(a)}},c=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,i);c((r=r.apply(e,t)).next())});var me=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,n)=>{for(var s=n>1?void 0:n?tt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&me(t,r,s),s};function nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function W(e){return typeof e=="string"}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function st(e){return typeof e>"u"}function ot(e){return st(e)||e===null}function it(e){return typeof e=="function"}function ue(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var at=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(at||{}),ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},pe=class extends ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var fe=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var mt={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:mt});var he=Symbol.for("Jolibox.canIUseMap"),lt={};globalThis[he]=lt;var ge={get config(){return globalThis[he]}};function z(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let m=parseInt(s[c],10)||0,a=parseInt(o[c],10)||0;if(m>a){n=1;break}else if(m<a){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var Y=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Y||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(dt||{}),ce=["name","params"],ut=["name","type","location","target","extra","timestamp","userId"],pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function ft(e){let t=e.location?O(e.location,ce):null,r=e.target?O(e.target,ce):null;return O(R(y({},e),{location:t,target:r}),ut)}function Ee(e){let t=e.events.map(n=>ft(n)),r=O(e.device,pt);return[e.protocolVersion,t,r,e.project]}var ht=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var L={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},gt=()=>L.isiOS?"iOS":L.isAndroid?"Android":L.isMac?"Mac":L.isFacebook?"Facebook":"PC",Et="device_id",_t="advertising_id",_e=e=>(localStorage.getItem(e)||localStorage.setItem(e,ht()),localStorage.getItem(e)),yt=()=>_e(Et),St=()=>_e(_t),xt=e=>e.charAt(0).toUpperCase()+e.slice(1),vt=()=>{var t;let e=new URLSearchParams(window.location.search);return xt((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},ye=e=>{let t="JoliboxWebSDK",r=gt(),n=navigator.language,s=yt(),o=St();return`${t} (${vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_,d=(_=class{constructor(t){this.element=t,this.next=_.Undefined,this.prev=_.Undefined}},_.Undefined=new _(void 0),_),Rt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},bt=0,k=class{constructor(e){this.value=e,this.id=bt++}},T=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof k&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,o,i,c,m,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new k(t);this._listeners?this._listeners instanceof k?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(c=(i=this.options)==null?void 0:i.onDidFirstListener)==null||c.call(i,this)),(a=(m=this.options)==null?void 0:m.onDidAddListener)==null||a.call(m,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof k?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},X=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new T,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(y({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Rt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};rt(G,{None:()=>It,filter:()=>At,once:()=>Se,toPromise:()=>Tt});var It=()=>{console.log("[Jolibox SDK] None Event")};function Tt(e){return new Promise(t=>Se(e)(t))}function Se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function At(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new T(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var V=Symbol.for("Jolibox.hostEmitter"),wt=()=>{let e=new X;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},xe=wt();function Dt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ut(e[n],t[n])}function Ut(e,t){if(W(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(it(t)){try{if(e instanceof t)return}catch(r){}if(!ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var C=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new T,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Dt(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};C=le([ue],C);var H=class{constructor(){this._onWillExecuteCommand=new T,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new T,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new C,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=nt(3e4)),this._starActivation}executeCommand(e,...t){return l(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};H=le([ue],H);var $=Symbol.for("Jolibox.commands");function E(){if(globalThis[$])return globalThis[$];let e=new C,t=new H,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[$]=r,r}var P=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Lt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function kt(){return{platform:1e3,os:"h5",appVersion:"1.1.9-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.9-beta.1",extra:{}}}var ve={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Ot=()=>{var t;let e=(t=ve[window.location.host])!=null?t:ve.default;return P?e.test:e.prod},Ct=Ot(),be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Re;(Re=AbortSignal.timeout)!=null||(AbortSignal.timeout=be);var Pt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Kt=Pt(),Mt=e=>l(void 0,null,function*(){let r=`${Ct}/report`,n=ye("1.1.9-beta.1"),s=Kt,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:be(5e3)})});function S(e){return l(this,null,function*(){let t={name:"globalJsError",type:Y.ErrorTrace,location:Lt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=kt(),s={protocolVersion:"1.0.0",events:[t],device:r,project:Q.WebSDK},o=Ee(s);Mt(o)})}document.addEventListener("DOMContentLoaded",()=>xe.emit("onDocumentReady",A.startTime));var Nt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},A=Nt(),Ie=E(),q=e=>{Ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),S({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},Z=q;window.addEventListener("unhandledrejection",q.bind(void 0));window.addEventListener("error",q.bind(void 0));window.onerror=(e,t,r,n,s)=>{Ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{S({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})})})};var ee=e=>{var c,m,a;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[(c=n[0])!=null?c:"0",(m=n[1])!=null?m:"0",(a=n[2])!=null?a:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},w=e=>parseInt(ee(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ee(e),{major:i,minor:c,patch:m,prerelease:a}=ee(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==m?s>m?1:-1:o&&!a?-1:!o&&a?1:o&&a?o>a?1:o<a?-1:0:0};var Te=E(),K=(e,t)=>{Te.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Te.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var Ue="jolibox-sdk-loadermeta",De,U=JSON.parse((De=localStorage.getItem(Ue))!=null?De:"{}"),te=Date.now(),Ae=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,we=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function jt(){return l(this,null,function*(){let t=`${P?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:s}=yield r.json(),o=R(y({},U),{timestamp:te});if(s){let{bootstrap_version:i}=U;if(!(i&&D(i,s)>=0)){let c=yield(yield fetch(re(s))).text();we(c)&&(o=R(y({},o),{bootstrap_version:s,bootstrap_script:c}))}}if(n){let{implement_version:i}=U;if(!(i&&D(i,n)>=0)){let c=yield(yield fetch(ne(n))).text();we(c)&&(o=R(y({},o),{implement_version:n,implement_script:c}))}}localStorage.setItem(Ue,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Le=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:a,bootstrap_script:h,timestamp:g}=U;if(a&&h&&g&&!Ae(te,g)&&w(a)==t&&D(a,r)>=0)return{script:h,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new fe(`Bootstrap module faile to fetch ${p}`);S({err:`${u}`})}}function i(){var p;let a=Date.now();K("jsSdkBegin",{t:a}),A.startTime=a;let{script:h,type:g}=(p=o())!=null?p:{};if(h){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=h,document.head.appendChild(u),x("bootstrapModuleLoaded",Date.now()-a,{type:g})}}function c(a){(g=>l(this,null,function*(){try{let p=new Blob([g],{type:"application/javascript"}),u=URL.createObjectURL(p),Ye=yield import(u);return URL.revokeObjectURL(u),Ye}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);S({err:`${u}`})}}))(a)}function m(){let a=Date.now(),{implement_script:h,implement_version:g,timestamp:p}=U;if(h&&g&&p&&!Ae(te,p)&&w(g)==t&&D(g,r)>=0){c(h),x("implementModuleLoaded",Date.now()-a,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=s,u.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{i(),m(),jt()}catch(a){let h=new b(`module evaluate error: ${a}`);S({err:`${h}`})}}};var ke=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>l(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),m=URL.createObjectURL(c),a=yield import(m);return URL.revokeObjectURL(m),a}catch(c){Z(new b(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();K("jsSdkBegin",{t:s}),A.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),m=r(t.implementUrl);n(m),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),Z(new b(`module load failed ${s}`))}}};var Jt="1.1.9-beta.1",M=Jt,Pe=w(M),Ke=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ft=Ke?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,re=e=>`https://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,ne=e=>`https://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,Bt=e=>/^\d+\.\d+\.\d+$/.test(e),Me=Bt(M)?Pe:M,Oe=re(Me),Ce=ne(Me);function Vt(){Ke?ke(Ft,{bootstrapUrl:Oe,implementUrl:Ce})():Le({bootstrapUrl:Oe,implementUrl:Ce,currentMajorVersion:Pe,currentVersion:M})()}Vt();var Ne=E();function je(){return Ne.excuteCommandSync("API.getSystemInfoSync")}function Je(){return Ne.excuteCommandSync("API.env")}function Fe(e,t){var r;return(r=ge.config[e])==null?void 0:r[t]}function Be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var $e="1.1.9-beta.1";function v(e){var c,m;let r=(m=(c=Je().data)==null?void 0:c.deviceInfo)==null?void 0:m.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Fe(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||z($e,i,"<")?!1:s.length===0?!0:Ve(o,s)||Ve(o.properties,s)}function Ve(e,t){if(!e)return!1;let r=Be(e,t);return r?de(r)?!0:W(r)?z($e,r,">="):!1:!1}var Ge=E();function He(){return l(this,null,function*(){return v("login")?yield Ge.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function We(){return l(this,null,function*(){return v("checkSession")?yield Ge.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var se=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},ze=window.JoliboxRuntime||se;var f=class{constructor(){this.commands=E();this._emitter=new X}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return v(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var $t="LifecycleSDK.onReady",N=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent($t,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends f{getItem(t){return l(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return l(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return l(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends f{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends f{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends f{onLevelFinished(t,r,n){return l(this,null,function*(){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return l(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return l(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var oe=class{constructor(){this.jssdkVersion="1.1.9-beta.1";this.runtime=new ze;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.getSystemInfoSync=je.bind(this);this.canIUse=v.bind(this);this.login=He.bind(this);this.checkSession=We.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task}}};window.JoliboxSDK=oe;})();
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.1.8",
4
+ "version": "1.1.9-beta.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.1.8",
11
- "@jolibox/types": "1.1.8"
10
+ "@jolibox/common": "1.1.9-beta.1",
11
+ "@jolibox/types": "1.1.9-beta.1"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.1.8 clean
3
+ > @jolibox/sdk@1.1.9-beta.1 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.8 build:cjs
7
+ > @jolibox/sdk@1.1.9-beta.1 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.1.8 build:esm
11
+ > @jolibox/sdk@1.1.9-beta.1 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.1.8 build:iife
15
+ > @jolibox/sdk@1.1.9-beta.1 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17