@jolibox/sdk 1.1.13-beta.8 → 1.1.13-beta.9
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.
- package/.rush/temp/package-deps_build.json +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +176 -168
- package/package.json +3 -3
- package/sdk.build.log +4 -4
|
@@ -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": "1725a85515499085a7c9799b834c6f632073401c",
|
|
7
|
-
"packages/sdk/package.json": "
|
|
7
|
+
"packages/sdk/package.json": "d13ddd1c87418e1b30b8dcf4006ed266e80ee6b5",
|
|
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,st=Object.defineProperties,it=Object.getOwnPropertyDescriptor,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var de=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ue.call(t,r)&&de(e,r,t[r]);if(me)for(var r of me(t))lt.call(t,r)&&de(e,r,t[r]);return e},D=(e,t)=>st(e,at(t));var mt=(e,t)=>{for(var r in t)L(e,r,{get:t[r],enumerable:!0})},dt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!ue.call(e,o)&&o!==r&&L(e,o,{get:()=>t[o],enumerable:!(n=it(t,o))||n.enumerable});return e};var ut=e=>dt(L({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});var mr={};mt(mr,{JoliboxSDK:()=>$});module.exports=ut(mr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Q=Object.defineProperty,pt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,ht=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))gt.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))_t.call(t,r)&&fe(e,r,t[r]);return e},Et=(e,t)=>pt(e,ht(t)),yt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{for(var o=n>1?void 0:n?ft(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(o=(n?c(t,r,o):c(o))||o);return n&&o&&Q(t,r,o),o},vt=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function bt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function St(e){return typeof e=="undefined"}function xt(e){return St(e)||e===null}function Rt(e){return typeof e=="function"}function ye(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var wt=(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))(wt||{}),It=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}},ve=class extends It{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var be=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Tt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Tt});var Se=Symbol.for("Jolibox.canIUseMap"),Lt={};globalThis[Se]=Lt;var xe={get config(){return globalThis[Se]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),c=Math.max(o.length,s.length);for(let a=0;a<c;a++){let l=parseInt(o[a],10)||0,i=parseInt(s[a],10)||0;if(l>i){n=1;break}else if(l<i){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 ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),At=(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))(At||{}),he=["name","params"],Dt=["name","type","location","target","extra","timestamp","userId"],Ut=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function P(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ot(e){let t=e.location?P(e.location,he):null,r=e.target?P(e.target,he):null;return P(Et(ge({},e),{location:t,target:r}),Dt)}function Re(e){let t=e.events.map(n=>Ot(n)),r=P(e.device,Ut);return[e.protocolVersion,t,r,e.project]}var Pt=()=>"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 U={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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ct="device_id",Kt="advertising_id",we=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>we(Ct),jt=()=>we(Kt),Nt=e=>e.charAt(0).toUpperCase()+e.slice(1),Jt=()=>{var e;let t=new URLSearchParams(window.location.search);return Nt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ie=e=>{let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Jt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Te(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}var W=class z{constructor(t){this.element=t,this.next=z.Undefined,this.prev=z.Undefined}};W.Undefined=new W(void 0);var d=W,Ft=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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,O=class{constructor(e){this.value=e,this.id=Bt++}},x=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 n,o,s,c,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new O(t);this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(c=(s=this.options)==null?void 0:s.onDidFirstListener)==null||c.call(s,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}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}},re=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(ge({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 Ft,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},q={};yt(q,{None:()=>Vt,filter:()=>Gt,once:()=>Le,toPromise:()=>$t});var Vt=()=>{console.log("[Jolibox SDK] None Event")};function $t(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Gt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),Ht=()=>{let e=new re;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},Ae=Ht();function Wt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)zt(e[n],t[n])}function zt(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Rt(t)){try{if(e instanceof t)return}catch(r){}if(!xt(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 k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Wt(o,r),n(...o)}}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}};k=_e([ye],k);var Y=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=bt(3e4)),this._starActivation}executeCommand(e,...t){return vt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),q.toPromise(q.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}}};Y=_e([ye],Y);var H=Symbol.for("Jolibox.commands");function h(){if(globalThis[H])return globalThis[H];let e=new k,t=new Y,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[H]=r,r}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function qt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Yt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.8",extra:{}}}var De={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"}},Qt=()=>{var t;let e=(t=De[window.location.host])!=null?t:De.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Zt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},er=Zt(),tr=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Ie("1.1.13-beta.8"),o=er,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:qt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Yt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=Re(o);yield tr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ae.emit("onDocumentReady",R.startTime));var rr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=rr(),Pe=h(),ne=e=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),y({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},oe=ne;window.addEventListener("unhandledrejection",ne.bind(void 0));window.addEventListener("error",ne.bind(void 0));window.onerror=(e,t,r,n,o)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{y({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var se=e=>{var a,l,i;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),[o,s,c]=[(a=n[0])!=null?a:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:c,prerelease:t,build:r}},w=e=>parseInt(se(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=se(e),{major:c,minor:a,patch:l,prerelease:i}=se(t);return r!==c?r>c?1:-1:n!==a?n>a?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var ke=h(),K=(e,t)=>{ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Te();var je="jolibox-sdk-loadermeta",Me,T=JSON.parse((Me=window.__joliboxLocalStorage__.getItem(je))!=null?Me:"{}"),ie=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,Ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function nr(){return m(this,null,function*(){let t=`${C?"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:o}=yield r.json(),s=D(A({},T),{timestamp:ie});if(o){let{bootstrap_version:c}=T;if(!(c&&I(c,o)>=0)){let a=yield(yield fetch(ae(o))).text();Ke(a)&&(s=D(A({},s),{bootstrap_version:o,bootstrap_script:a}))}}if(n){let{implement_version:c}=T;if(!(c&&I(c,n)>=0)){let a=yield(yield fetch(ce(n))).text();Ke(a)&&(s=D(A({},s),{implement_version:n,implement_script:a}))}}window.__joliboxLocalStorage__.setItem(je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ne=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Ce(ie,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 be(`Bootstrap module faile to fetch ${p}`);y({err:`${u}`})}}function c(){var p;let i=Date.now();K("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function a(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),ot=yield import(u);return URL.revokeObjectURL(u),ot}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);y({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Ce(ie,p)&&w(_)==t&&I(_,r)>=0){a(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{c(),l(),nr()}catch(i){let g=new b(`module evaluate error: ${i}`);y({err:`${g}`})}}};var Je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(c=>m(this,null,function*(){try{let a=new Blob([c],{type:"application/javascript"}),l=URL.createObjectURL(a),i=yield import(l);return URL.revokeObjectURL(l),i}catch(a){oe(new b(`implement module evaluate error in native:${a} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),c=document.createElement("script");c.type="text/javascript",c.innerHTML=s,document.head.appendChild(c),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let a=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-a,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new b(`module load failed ${o}`))}}};var or="1.1.13-beta.8",M=or,Ve=w(M),$e=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),sr=$e?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,ae=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,ir=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=ir(M)?Ve:M,Fe=ae(Ge),Be=ce(Ge);function ar(){$e?Je(sr,{bootstrapUrl:Fe,implementUrl:Be})():Ne({bootstrapUrl:Fe,implementUrl:Be,currentMajorVersion:Ve,currentVersion:M})()}ar();var He=h();function We(){return He.excuteCommandSync("API.getSystemInfoSync")}function ze(){return He.excuteCommandSync("API.env")}function qe(e,t){var r;return(r=xe.config[e])==null?void 0:r[t]}function Ye(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.13-beta.8";function E(e){var a,l;let r=(l=(a=ze().data)==null?void 0:a.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=qe(r=="h5"?r:"native",n);if(!s)return!1;let c=s.version;return typeof c!="string"||Z(Xe,c,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=Ye(e,t);return r?Ee(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ze=h();function et(){return m(this,null,function*(){return E("login")?yield Ze.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function tt(){return m(this,null,function*(){return E("checkSession")?yield Ze.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var cr=h();function rt(e){return m(this,null,function*(){return E("request")?yield cr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var le=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)}}},nt=window.JoliboxRuntime||le;var f=class{constructor(){this.commands=h();this._emitter=new re}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var lr="LifecycleSDK.onReady",j=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(lr,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,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends f{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(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 m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var $=class{constructor(){this.jssdkVersion="1.1.13-beta.8";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=We.bind(this);this.canIUse=E.bind(this);this.login=et.bind(this);this.checkSession=tt.bind(this);this.request=rt.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=$;
|
|
1
|
+
"use strict";var L=Object.defineProperty,st=Object.defineProperties,it=Object.getOwnPropertyDescriptor,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var de=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ue.call(t,r)&&de(e,r,t[r]);if(me)for(var r of me(t))lt.call(t,r)&&de(e,r,t[r]);return e},D=(e,t)=>st(e,at(t));var mt=(e,t)=>{for(var r in t)L(e,r,{get:t[r],enumerable:!0})},dt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!ue.call(e,o)&&o!==r&&L(e,o,{get:()=>t[o],enumerable:!(n=it(t,o))||n.enumerable});return e};var ut=e=>dt(L({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});var ur={};mt(ur,{JoliboxSDK:()=>$});module.exports=ut(ur);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Y=Object.defineProperty,pt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,ht=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))gt.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))_t.call(t,r)&&fe(e,r,t[r]);return e},yt=(e,t)=>pt(e,ht(t)),Et=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{for(var o=n>1?void 0:n?ft(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Y(t,r,o),o},vt=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function bt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Q(e){return typeof e=="string"}function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function St(e){return typeof e=="undefined"}function xt(e){return St(e)||e===null}function Rt(e){return typeof e=="function"}function Ee(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var wt=(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))(wt||{}),It=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}},ve=class extends It{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var be=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Tt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Tt});var Se=Symbol.for("Jolibox.canIUseMap"),Lt={};globalThis[Se]=Lt;var xe={get config(){return globalThis[Se]}};function X(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Z=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Z||{}),ee=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ee||{}),At=(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))(At||{}),he=["name","params"],Dt=["name","type","location","target","extra","timestamp","userId"],Ut=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function P(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ot(e){let t=e.location?P(e.location,he):null,r=e.target?P(e.target,he):null;return P(yt(ge({},e),{location:t,target:r}),Dt)}function Re(e){let t=e.events.map(n=>Ot(n)),r=P(e.device,Ut);return[e.protocolVersion,t,r,e.project]}var Pt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function te(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}te();var U={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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ct="device_id",Kt="advertising_id",we=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>we(Ct),jt=()=>we(Kt),Nt=e=>e.charAt(0).toUpperCase()+e.slice(1),Jt=()=>{var e;let t=new URLSearchParams(window.location.search);return Nt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ie=e=>{let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Jt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},H=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};H.Undefined=new H(void 0);var d=H,Ft=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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,O=class{constructor(e){this.value=e,this.id=Bt++}},x=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 n,o,s,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new O(t);this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}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}},re=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(ge({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 Ft,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},z={};Et(z,{None:()=>Vt,filter:()=>Gt,once:()=>Te,toPromise:()=>$t});var Vt=()=>{console.log("[Jolibox SDK] None Event")};function $t(e){return new Promise(t=>Te(e)(t))}function Te(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Gt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),Ht=()=>{let e=new re;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},Le=Ht();function Wt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)zt(e[n],t[n])}function zt(e,t){if(Q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Rt(t)){try{if(e instanceof t)return}catch(r){}if(!xt(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 k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Wt(o,r),n(...o)}}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}};k=_e([Ee],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=bt(3e4)),this._starActivation}executeCommand(e,...t){return vt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.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}}};q=_e([Ee],q);var Ae=Symbol.for("Jolibox.commands");function qt(){return typeof globalThis!="undefined"?globalThis[Ae]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ae]=e)}function h(){let e=qt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Yt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Qt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Xt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.9",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.9",extra:{}}}var De={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"}},Zt=()=>{var t;let e=(t=De[window.location.host])!=null?t:De.default;return C?e.test:e.prod},er=Zt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var tr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},rr=tr(),nr=e=>m(void 0,null,function*(){try{let r=`${er}/report`,n=Ie("1.1.13-beta.9"),o=rr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Z.ErrorTrace,location:Qt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Xt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ee.WebSDK},s=Re(o);yield nr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Le.emit("onDocumentReady",R.startTime));var or=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=or(),Pe=h(),ne=e=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},oe=ne;window.addEventListener("unhandledrejection",ne.bind(void 0));window.addEventListener("error",ne.bind(void 0));window.onerror=(e,t,r,n,o)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var se=e=>{var c,l,i;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),[o,s,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(se(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=se(e),{major:a,minor:c,patch:l,prerelease:i}=se(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var ke=h(),K=(e,t)=>{ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};te();var je="jolibox-sdk-loadermeta",Me,T=JSON.parse((Me=window.__joliboxLocalStorage__.getItem(je))!=null?Me:"{}"),ie=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,Ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function sr(){return m(this,null,function*(){let t=`${C?"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:o}=yield r.json(),s=D(A({},T),{timestamp:ie});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(ae(o))).text();Ke(c)&&(s=D(A({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ce(n))).text();Ke(c)&&(s=D(A({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ne=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Ce(ie,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 be(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();K("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),ot=yield import(u);return URL.revokeObjectURL(u),ot}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Ce(ie,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),sr()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var Je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){oe(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new b(`module load failed ${o}`))}}};var ir="1.1.13-beta.9",M=ir,Ve=w(M),$e=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),ar=$e?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,ae=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,cr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=cr(M)?Ve:M,Fe=ae(Ge),Be=ce(Ge);function lr(){$e?Je(ar,{bootstrapUrl:Fe,implementUrl:Be})():Ne({bootstrapUrl:Fe,implementUrl:Be,currentMajorVersion:Ve,currentVersion:M})()}lr();var He=h();function We(){return He.excuteCommandSync("API.getSystemInfoSync")}function ze(){return He.excuteCommandSync("API.env")}function qe(e,t){var r;return(r=xe.config[e])==null?void 0:r[t]}function Ye(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Xe="1.1.13-beta.9";function y(e){var c,l;let r=(l=(c=ze().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||X(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=Ye(e,t);return r?ye(r)?!0:Q(r)?X(Xe,r,">="):!1:!1}var Ze=h();function et(){return m(this,null,function*(){return y("login")?yield Ze.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function tt(){return m(this,null,function*(){return y("checkSession")?yield Ze.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var mr=h();function rt(e){return m(this,null,function*(){return y("request")?yield mr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var le=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)}}},nt=window.JoliboxRuntime||le;var f=class{constructor(){this.commands=h();this._emitter=new re}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var dr="LifecycleSDK.onReady",j=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(dr,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,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var N=class extends f{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(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 m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var $=class{constructor(){this.jssdkVersion="1.1.13-beta.9";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=We.bind(this);this.canIUse=y.bind(this);this.login=et.bind(this);this.checkSession=tt.bind(this);this.request=rt.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=$;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var q=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(o=(n?c(t,r,o):c(o))||o);return n&&o&&q(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Y(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function Et(e){return _t(e)||e===null}function yt(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},Ee=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ye=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Q(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),c=Math.max(o.length,s.length);for(let a=0;a<c;a++){let l=parseInt(o[a],10)||0,i=parseInt(s[a],10)||0;if(l>i){n=1;break}else if(l<i){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||{}),Z=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Z||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"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 D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function we(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}var G=class H{constructor(t){this.element=t,this.next=H.Undefined,this.prev=H.Undefined}};G.Undefined=new G(void 0);var d=G,Kt=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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 n,o,s,c,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(c=(s=this.options)==null?void 0:s.onDidFirstListener)==null||c.call(s,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({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 Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};ft(W,{None:()=>jt,filter:()=>Jt,once:()=>Ie,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>Ie(e)(t))}function Ie(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Te=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(Y(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(yt(t)){try{if(e instanceof t)return}catch(r){}if(!Et(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 x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Bt(o,r),n(...o)}}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=he([_e],P);var z=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(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=he([_e],z);var $=Symbol.for("Jolibox.commands");function h(){if(globalThis[$])return globalThis[$];let e=new P,t=new z,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[$]=r,r}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function $t(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Gt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.8",extra:{}}}var Le={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"}},Ht=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},Wt=Ht(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var zt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},qt=zt(),Yt=e=>m(void 0,null,function*(){try{let r=`${Wt}/report`,n=Re("1.1.13-beta.8"),o=qt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:X.ErrorTrace,location:$t(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Gt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:Z.WebSDK},s=Se(o);yield Yt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Te.emit("onDocumentReady",R.startTime));var Qt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Qt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),y({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{y({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var a,l,i;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),[o,s,c]=[(a=n[0])!=null?a:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:c,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:c,minor:a,patch:l,prerelease:i}=ne(t);return r!==c?r>c?1:-1:n!==a?n>a?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};we();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function Xt(){return m(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:o}=yield r.json(),s=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:c}=T;if(!(c&&I(c,o)>=0)){let a=yield(yield fetch(se(o))).text();ke(a)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:a}))}}if(n){let{implement_version:c}=T;if(!(c&&I(c,n)>=0)){let a=yield(yield fetch(ie(n))).text();ke(a)&&(s=A(L({},s),{implement_version:n,implement_script:a}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 ye(`Bootstrap module faile to fetch ${p}`);y({err:`${u}`})}}function c(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function a(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);y({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){a(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{c(),l(),Xt()}catch(i){let g=new b(`module evaluate error: ${i}`);y({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(c=>m(this,null,function*(){try{let a=new Blob([c],{type:"application/javascript"}),l=URL.createObjectURL(a),i=yield import(l);return URL.revokeObjectURL(l),i}catch(a){re(new b(`implement module evaluate error in native:${a} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),c=document.createElement("script");c.type="text/javascript",c.innerHTML=s,document.head.appendChild(c),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let a=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-a,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var Zt="1.1.13-beta.8",K=Zt,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),er=Be?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://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,tr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=tr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function rr(){Be?je(er,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}rr();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ye="1.1.13-beta.8";function E(e){var a,l;let r=(l=(a=He().data)==null?void 0:a.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let c=s.version;return typeof c!="string"||Q(Ye,c,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:Y(r)?Q(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return E("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return E("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var nr=h();function et(e){return m(this,null,function*(){return E("request")?yield nr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=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)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var or="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(or,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,t.shouldStay)}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 m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=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 J=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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.13-beta.8";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=E.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;export{ce as JoliboxSDK};
|
|
1
|
+
var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var z=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&z(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function q(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function yt(e){return _t(e)||e===null}function Et(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},ye=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ee=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function Z(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}Z();var D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},$=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};$.Undefined=new $(void 0);var d=$,Kt=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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 n,o,s,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({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 Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},H={};ft(H,{None:()=>jt,filter:()=>Jt,once:()=>we,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>we(e)(t))}function we(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Ie=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Et(t)){try{if(e instanceof t)return}catch(r){}if(!yt(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 x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Bt(o,r),n(...o)}}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=he([_e],P);var W=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),H.toPromise(H.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}}};W=he([_e],W);var Te=Symbol.for("Jolibox.commands");function $t(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function h(){let e=$t();if(e)return e;let t=new P,r=new W,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Gt(n),n}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Ht(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Wt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.9",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.9",extra:{}}}var Le={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"}},zt=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},qt=zt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Qt=Yt(),Xt=e=>m(void 0,null,function*(){try{let r=`${qt}/report`,n=Re("1.1.13-beta.9"),o=Qt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Ht(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Wt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=Se(o);yield Xt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ie.emit("onDocumentReady",R.startTime));var Zt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Zt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var c,l,i;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),[o,s,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:c,patch:l,prerelease:i}=ne(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function er(){return m(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:o}=yield r.json(),s=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(se(o))).text();ke(c)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ie(n))).text();ke(c)&&(s=A(L({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 Ee(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),er()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){re(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var tr="1.1.13-beta.9",K=tr,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),rr=Be?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://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,nr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=nr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function or(){Be?je(rr,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}or();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ye="1.1.13-beta.9";function y(e){var c,l;let r=(l=(c=He().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(Ye,a,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:q(r)?Y(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return y("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return y("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var sr=h();function et(e){return m(this,null,function*(){return y("request")?yield sr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=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)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ir="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ir,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,t.shouldStay)}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 m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=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 J=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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.13-beta.9";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=y.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;export{ce as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var q=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(o=(n?c(t,r,o):c(o))||o);return n&&o&&q(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(i){o(i)}},c=l=>{try{a(r.throw(l))}catch(i){o(i)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Y(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function Et(e){return _t(e)||e===null}function yt(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},Ee=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ye=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Q(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),c=Math.max(o.length,s.length);for(let a=0;a<c;a++){let l=parseInt(o[a],10)||0,i=parseInt(s[a],10)||0;if(l>i){n=1;break}else if(l<i){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||{}),Z=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Z||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"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 D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function we(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}var G=class H{constructor(t){this.element=t,this.next=H.Undefined,this.prev=H.Undefined}};G.Undefined=new G(void 0);var d=G,Kt=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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 n,o,s,c,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(c=(s=this.options)==null?void 0:s.onDidFirstListener)==null||c.call(s,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({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 Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};ft(W,{None:()=>jt,filter:()=>Jt,once:()=>Ie,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>Ie(e)(t))}function Ie(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Te=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(Y(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(yt(t)){try{if(e instanceof t)return}catch(r){}if(!Et(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 x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Bt(o,r),n(...o)}}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=he([_e],P);var z=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(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=he([_e],z);var $=Symbol.for("Jolibox.commands");function h(){if(globalThis[$])return globalThis[$];let e=new P,t=new z,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[$]=r,r}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function $t(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Gt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.8",extra:{}}}var Le={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"}},Ht=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},Wt=Ht(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var zt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},qt=zt(),Yt=e=>m(void 0,null,function*(){try{let r=`${Wt}/report`,n=Re("1.1.13-beta.8"),o=qt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:X.ErrorTrace,location:$t(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Gt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:Z.WebSDK},s=Se(o);yield Yt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Te.emit("onDocumentReady",R.startTime));var Qt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Qt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),y({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{y({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var a,l,i;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),[o,s,c]=[(a=n[0])!=null?a:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:c,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:c,minor:a,patch:l,prerelease:i}=ne(t);return r!==c?r>c?1:-1:n!==a?n>a?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};we();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function Xt(){return m(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:o}=yield r.json(),s=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:c}=T;if(!(c&&I(c,o)>=0)){let a=yield(yield fetch(se(o))).text();ke(a)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:a}))}}if(n){let{implement_version:c}=T;if(!(c&&I(c,n)>=0)){let a=yield(yield fetch(ie(n))).text();ke(a)&&(s=A(L({},s),{implement_version:n,implement_script:a}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 ye(`Bootstrap module faile to fetch ${p}`);y({err:`${u}`})}}function c(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function a(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);y({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){a(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{c(),l(),Xt()}catch(i){let g=new b(`module evaluate error: ${i}`);y({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(c=>m(this,null,function*(){try{let a=new Blob([c],{type:"application/javascript"}),l=URL.createObjectURL(a),i=yield import(l);return URL.revokeObjectURL(l),i}catch(a){re(new b(`implement module evaluate error in native:${a} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),c=document.createElement("script");c.type="text/javascript",c.innerHTML=s,document.head.appendChild(c),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let a=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-a,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var Zt="1.1.13-beta.8",K=Zt,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),er=Be?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://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,tr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=tr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function rr(){Be?je(er,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}rr();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ye="1.1.13-beta.8";function E(e){var a,l;let r=(l=(a=He().data)==null?void 0:a.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let c=s.version;return typeof c!="string"||Q(Ye,c,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:Y(r)?Q(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return E("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return E("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var nr=h();function et(e){return m(this,null,function*(){return E("request")?yield nr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=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)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var or="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(or,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,t.shouldStay)}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 m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=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 J=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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.13-beta.8";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=E.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;})();
|
|
1
|
+
"use strict";(()=>{var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var z=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&z(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function q(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function yt(e){return _t(e)||e===null}function Et(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},ye=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ee=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function Z(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}Z();var D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},$=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};$.Undefined=new $(void 0);var d=$,Kt=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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.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}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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 n,o,s,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({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 Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},H={};ft(H,{None:()=>jt,filter:()=>Jt,once:()=>we,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>we(e)(t))}function we(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Ie=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Et(t)){try{if(e instanceof t)return}catch(r){}if(!yt(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 x,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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Bt(o,r),n(...o)}}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=he([_e],P);var W=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),H.toPromise(H.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}}};W=he([_e],W);var Te=Symbol.for("Jolibox.commands");function $t(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function h(){let e=$t();if(e)return e;let t=new P,r=new W,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Gt(n),n}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Ht(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Wt(){return{platform:1e3,os:"h5",appVersion:"1.1.13-beta.9",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.13-beta.9",extra:{}}}var Le={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"}},zt=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},qt=zt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Qt=Yt(),Xt=e=>m(void 0,null,function*(){try{let r=`${qt}/report`,n=Re("1.1.13-beta.9"),o=Qt,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Ht(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Wt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=Se(o);yield Xt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ie.emit("onDocumentReady",R.startTime));var Zt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Zt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var c,l,i;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),[o,s,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:c,patch:l,prerelease:i}=ne(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function er(){return m(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:o}=yield r.json(),s=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(se(o))).text();ke(c)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ie(n))).text();ke(c)&&(s=A(L({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,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 Ee(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),er()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){re(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var tr="1.1.13-beta.9",K=tr,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),rr=Be?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://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,nr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=nr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function or(){Be?je(rr,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}or();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ye="1.1.13-beta.9";function y(e){var c,l;let r=(l=(c=He().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(Ye,a,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:q(r)?Y(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return y("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return y("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var sr=h();function et(e){return m(this,null,function*(){return y("request")?yield sr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=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)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ir="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ir,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,t.shouldStay)}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 m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(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 m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=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 J=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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.13-beta.9";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=y.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;})();
|
package/dist/index.js
CHANGED
|
@@ -5,50 +5,50 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
5
5
|
(() => {
|
|
6
6
|
// ../common/dist/index.es.js
|
|
7
7
|
var P = Object.defineProperty;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
8
|
+
var ye = Object.defineProperties;
|
|
9
|
+
var Te = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var xe = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var V = Object.getOwnPropertySymbols;
|
|
12
|
+
var Ee = Object.prototype.hasOwnProperty;
|
|
13
|
+
var _e = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var F = (n, e, t) => e in n ? P(n, e, {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
configurable: true,
|
|
17
17
|
writable: true,
|
|
18
18
|
value: t
|
|
19
19
|
}) : n[e] = t;
|
|
20
20
|
var f = (n, e) => {
|
|
21
|
-
for (var t in e || (e = {}))
|
|
22
|
-
if (
|
|
21
|
+
for (var t in e || (e = {})) Ee.call(e, t) && F(n, t, e[t]);
|
|
22
|
+
if (V) for (var t of V(e)) _e.call(e, t) && F(n, t, e[t]);
|
|
23
23
|
return n;
|
|
24
24
|
};
|
|
25
|
-
var b = (n, e) =>
|
|
26
|
-
var
|
|
25
|
+
var b = (n, e) => ye(n, xe(e));
|
|
26
|
+
var he = (n, e) => {
|
|
27
27
|
for (var t in e) P(n, t, {
|
|
28
28
|
get: e[t],
|
|
29
29
|
enumerable: true
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
var I = (n, e, t, r) => {
|
|
33
|
-
for (var o = r > 1 ? void 0 : r ?
|
|
33
|
+
for (var o = r > 1 ? void 0 : r ? Te(e, t) : e, i = n.length - 1, s; i >= 0; i--) (s = n[i]) && (o = (r ? s(e, t, o) : s(o)) || o);
|
|
34
34
|
return r && o && P(e, t, o), o;
|
|
35
35
|
};
|
|
36
|
-
var
|
|
37
|
-
var i =
|
|
36
|
+
var C = (n, e, t) => new Promise((r, o) => {
|
|
37
|
+
var i = a => {
|
|
38
38
|
try {
|
|
39
|
-
c(t.next(
|
|
39
|
+
c(t.next(a));
|
|
40
40
|
} catch (m) {
|
|
41
41
|
o(m);
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
|
|
44
|
+
s = a => {
|
|
45
45
|
try {
|
|
46
|
-
c(t.throw(
|
|
46
|
+
c(t.throw(a));
|
|
47
47
|
} catch (m) {
|
|
48
48
|
o(m);
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
c =
|
|
51
|
+
c = a => a.done ? r(a.value) : Promise.resolve(a.value).then(i, s);
|
|
52
52
|
c((t = t.apply(n, e)).next());
|
|
53
53
|
});
|
|
54
54
|
if (typeof window != "undefined" && !window.AbortController) {
|
|
@@ -77,7 +77,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
77
77
|
if (this._eventListeners[t.type]) for (let r of this._eventListeners[t.type]) r.call(this, t);
|
|
78
78
|
}, window.AbortController = n, window.AbortSignal = e;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function H(n) {
|
|
81
81
|
return new Promise(e => {
|
|
82
82
|
setTimeout(() => {
|
|
83
83
|
e();
|
|
@@ -90,16 +90,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
90
90
|
function Re(n) {
|
|
91
91
|
return typeof n == "object" && n !== null && !Array.isArray(n) && !(n instanceof RegExp) && !(n instanceof Date);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function ve(n) {
|
|
94
94
|
return typeof n == "undefined";
|
|
95
95
|
}
|
|
96
96
|
function k(n) {
|
|
97
|
-
return
|
|
97
|
+
return ve(n) || n === null;
|
|
98
98
|
}
|
|
99
99
|
function M(n) {
|
|
100
100
|
return typeof n == "function";
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function A(n) {
|
|
103
103
|
let e = n,
|
|
104
104
|
t = null,
|
|
105
105
|
r = function () {
|
|
@@ -110,8 +110,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
110
110
|
};
|
|
111
111
|
return r.prototype = e.prototype, r;
|
|
112
112
|
}
|
|
113
|
-
var
|
|
114
|
-
var
|
|
113
|
+
var be = (a => (a[a.DEVELOPER_FILE_NOT_FOUND = 0] = "DEVELOPER_FILE_NOT_FOUND", a[a.INTERNAL_IOS_CAN_NOT_FOUND_PKG = 1] = "INTERNAL_IOS_CAN_NOT_FOUND_PKG", a[a.USER_IOS_LOAD_TIMEOUT = 2] = "USER_IOS_LOAD_TIMEOUT", a[a.INTERNAL_IOS_PKG_LOAD_ERROR = 3] = "INTERNAL_IOS_PKG_LOAD_ERROR", a[a.INTERNAL_IOS_PKG_PARSE_FAIL = 4] = "INTERNAL_IOS_PKG_PARSE_FAIL", a[a.USER_IOS_GET_EMPTY_DATA = 5] = "USER_IOS_GET_EMPTY_DATA", a[a.USER_ANDROID_GET_PKG_FAIL = 6] = "USER_ANDROID_GET_PKG_FAIL", a[a.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE = 7] = "DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE", a))(be || {});
|
|
114
|
+
var h = class extends Error {
|
|
115
115
|
constructor(e) {
|
|
116
116
|
if (typeof e == "string") {
|
|
117
117
|
super(e), this.priority = "P1";
|
|
@@ -120,63 +120,63 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
120
120
|
super(e.message), this.priority = "P1", this.stack = e.stack, this.raw = e;
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
var u = class extends
|
|
123
|
+
var u = class extends h {
|
|
124
124
|
constructor() {
|
|
125
125
|
super(...arguments);
|
|
126
126
|
this.kind = "INTERNAL_ERROR";
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
var
|
|
129
|
+
var W = class extends u {
|
|
130
130
|
constructor() {
|
|
131
131
|
super(...arguments);
|
|
132
132
|
this.name = "INTERNAL_JS_MODULE_FETCH_ERROR";
|
|
133
133
|
this.priority = "P0";
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
var
|
|
136
|
+
var Q = class extends u {
|
|
137
137
|
constructor() {
|
|
138
138
|
super(...arguments);
|
|
139
139
|
this.name = "INTERNAL_JS_MODULE_EVAL_ERROR";
|
|
140
140
|
this.priority = "P0";
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function R(n) {
|
|
144
144
|
return function () {
|
|
145
145
|
var r, o;
|
|
146
146
|
((o = (r = globalThis.VConsole) == null ? void 0 : r[n]) != null ? o : globalThis.console[n])(...arguments);
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
var
|
|
150
|
-
log:
|
|
151
|
-
warn:
|
|
152
|
-
info:
|
|
153
|
-
error:
|
|
154
|
-
debug:
|
|
149
|
+
var se = {
|
|
150
|
+
log: R("log"),
|
|
151
|
+
warn: R("warn"),
|
|
152
|
+
info: R("info"),
|
|
153
|
+
error: R("error"),
|
|
154
|
+
debug: R("debug")
|
|
155
155
|
};
|
|
156
156
|
Object.assign(globalThis, {
|
|
157
|
-
logger:
|
|
157
|
+
logger: se
|
|
158
158
|
});
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
globalThis[
|
|
162
|
-
var
|
|
159
|
+
var ae = Symbol.for("Jolibox.canIUseMap");
|
|
160
|
+
var Ce = {};
|
|
161
|
+
globalThis[ae] = Ce;
|
|
162
|
+
var Un = {
|
|
163
163
|
get config() {
|
|
164
|
-
return globalThis[
|
|
164
|
+
return globalThis[ae];
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
function
|
|
167
|
+
function jn(n, e, t) {
|
|
168
168
|
let r = 0;
|
|
169
169
|
if (n !== e) {
|
|
170
170
|
let o = n.split("."),
|
|
171
171
|
i = e.split("."),
|
|
172
|
-
|
|
173
|
-
for (let c = 0; c <
|
|
174
|
-
let
|
|
172
|
+
s = Math.max(o.length, i.length);
|
|
173
|
+
for (let c = 0; c < s; c++) {
|
|
174
|
+
let a = parseInt(o[c], 10) || 0,
|
|
175
175
|
m = parseInt(i[c], 10) || 0;
|
|
176
|
-
if (
|
|
176
|
+
if (a > m) {
|
|
177
177
|
r = 1;
|
|
178
178
|
break;
|
|
179
|
-
} else if (
|
|
179
|
+
} else if (a < m) {
|
|
180
180
|
r = -1;
|
|
181
181
|
break;
|
|
182
182
|
}
|
|
@@ -199,11 +199,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
var Ae = (r => (r[r.System = 1e3] = "System", r[r.ErrorTrace = 1001] = "ErrorTrace", r[r.UserDefined = 1002] = "UserDefined", r))(Ae || {});
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
var
|
|
206
|
-
var
|
|
202
|
+
var we = (i => (i.MiniGame = "mini-game", i.MiniDrama = "mini-drama", i.App = "app", i.WebSDK = "web-sdk", i.AppSDK = "app-sdk", i))(we || {});
|
|
203
|
+
var Oe = (d => (d[d.App = 0] = "App", d[d.H5 = 1] = "H5", d[d.Weapp = 2] = "Weapp", d[d.Alipay = 3] = "Alipay", d[d.Gcash = 4] = "Gcash", d[d.Dana = 5] = "Dana", d[d.Umma = 6] = "Umma", d[d.WebSDK = 1e3] = "WebSDK", d[d.AppSDK = 1001] = "AppSDK", d[d.Other = 9999] = "Other", d))(Oe || {});
|
|
204
|
+
var de = ["name", "params"];
|
|
205
|
+
var Ne = ["name", "type", "location", "target", "extra", "timestamp", "userId"];
|
|
206
|
+
var Le = ["platform", "os", "appVersion", "appId", "model", "brand", "uuid", "jsSdkVersion", "extra"];
|
|
207
207
|
function O(n, e) {
|
|
208
208
|
return e.map(t => {
|
|
209
209
|
if (t === "params" && n[t]) {
|
|
@@ -213,55 +213,24 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
213
213
|
return n[t];
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
let e = n.location ? O(n.location,
|
|
218
|
-
t = n.target ? O(n.target,
|
|
216
|
+
function Pe(n) {
|
|
217
|
+
let e = n.location ? O(n.location, de) : null,
|
|
218
|
+
t = n.target ? O(n.target, de) : null;
|
|
219
219
|
return O(b(f({}, n), {
|
|
220
220
|
location: e,
|
|
221
221
|
target: t
|
|
222
|
-
}),
|
|
222
|
+
}), Ne);
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
let e = n.events.map(r =>
|
|
226
|
-
t = O(n.device,
|
|
224
|
+
function Gn(n) {
|
|
225
|
+
let e = n.events.map(r => Pe(r)),
|
|
226
|
+
t = O(n.device, Le);
|
|
227
227
|
return [n.protocolVersion, e, t, n.project];
|
|
228
228
|
}
|
|
229
|
-
var
|
|
229
|
+
var le = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, n => {
|
|
230
230
|
let e = Math.random() * 16 | 0;
|
|
231
231
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
232
232
|
});
|
|
233
|
-
|
|
234
|
-
isiOS: navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPod") || navigator.userAgent.includes("iPad") || navigator.userAgent.includes("iPhone OS"),
|
|
235
|
-
iosVersion: () => {
|
|
236
|
-
let n = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
|
|
237
|
-
return [parseInt(n[1], 10), parseInt(n[2], 10), parseInt(n[3] || "0", 10)];
|
|
238
|
-
},
|
|
239
|
-
isAndroid: navigator.userAgent.includes("Android"),
|
|
240
|
-
isMac: navigator.userAgent.includes("Mac"),
|
|
241
|
-
isFacebook: navigator.userAgent.includes("FB_IAB"),
|
|
242
|
-
isPC: !navigator.userAgent.includes("iPhone") && !navigator.userAgent.includes("Android")
|
|
243
|
-
};
|
|
244
|
-
var Pe = () => N.isiOS ? "iOS" : N.isAndroid ? "Android" : N.isMac ? "Mac" : N.isFacebook ? "Facebook" : "PC";
|
|
245
|
-
var Se = "device_id";
|
|
246
|
-
var ke = "advertising_id";
|
|
247
|
-
var me = n => (window.__joliboxLocalStorage__.getItem(n) || window.__joliboxLocalStorage__.setItem(n, ce()), window.__joliboxLocalStorage__.getItem(n));
|
|
248
|
-
var Me = () => me(Se);
|
|
249
|
-
var Ue = () => me(ke);
|
|
250
|
-
var De = n => n.charAt(0).toUpperCase() + n.slice(1);
|
|
251
|
-
var Ve = () => {
|
|
252
|
-
var e;
|
|
253
|
-
let n = new URLSearchParams(window.location.search);
|
|
254
|
-
return De((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
|
|
255
|
-
};
|
|
256
|
-
var Wn = n => {
|
|
257
|
-
let e = "JoliboxWebSDK",
|
|
258
|
-
t = Pe(),
|
|
259
|
-
r = navigator.language,
|
|
260
|
-
o = Me(),
|
|
261
|
-
i = Ue();
|
|
262
|
-
return `${e} (${Ve()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
|
|
263
|
-
};
|
|
264
|
-
function Yn() {
|
|
233
|
+
function ce() {
|
|
265
234
|
try {
|
|
266
235
|
if (window.__joliboxLocalStorage__) return window.__joliboxLocalStorage__;
|
|
267
236
|
let n = Object.getOwnPropertyDescriptor(window, "localStorage");
|
|
@@ -281,13 +250,45 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
281
250
|
return console.warn("Failed to get original localStorage, fallback to default implementation", n), localStorage;
|
|
282
251
|
}
|
|
283
252
|
}
|
|
284
|
-
|
|
253
|
+
ce();
|
|
254
|
+
var N = {
|
|
255
|
+
isiOS: navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPod") || navigator.userAgent.includes("iPad") || navigator.userAgent.includes("iPhone OS"),
|
|
256
|
+
iosVersion: () => {
|
|
257
|
+
let n = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
|
|
258
|
+
return [parseInt(n[1], 10), parseInt(n[2], 10), parseInt(n[3] || "0", 10)];
|
|
259
|
+
},
|
|
260
|
+
isAndroid: navigator.userAgent.includes("Android"),
|
|
261
|
+
isMac: navigator.userAgent.includes("Mac"),
|
|
262
|
+
isFacebook: navigator.userAgent.includes("FB_IAB"),
|
|
263
|
+
isPC: !navigator.userAgent.includes("iPhone") && !navigator.userAgent.includes("Android")
|
|
264
|
+
};
|
|
265
|
+
var Se = () => N.isiOS ? "iOS" : N.isAndroid ? "Android" : N.isMac ? "Mac" : N.isFacebook ? "Facebook" : "PC";
|
|
266
|
+
var ke = "device_id";
|
|
267
|
+
var Me = "advertising_id";
|
|
268
|
+
var me = n => (window.__joliboxLocalStorage__.getItem(n) || window.__joliboxLocalStorage__.setItem(n, le()), window.__joliboxLocalStorage__.getItem(n));
|
|
269
|
+
var Ue = () => me(ke);
|
|
270
|
+
var De = () => me(Me);
|
|
271
|
+
var Ve = n => n.charAt(0).toUpperCase() + n.slice(1);
|
|
272
|
+
var Fe = () => {
|
|
273
|
+
var e;
|
|
274
|
+
let n = new URLSearchParams(window.location.search);
|
|
275
|
+
return Ve((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
|
|
276
|
+
};
|
|
277
|
+
var et = n => {
|
|
278
|
+
let e = "JoliboxWebSDK",
|
|
279
|
+
t = Se(),
|
|
280
|
+
r = navigator.language,
|
|
281
|
+
o = Ue(),
|
|
282
|
+
i = De();
|
|
283
|
+
return `${e} (${Fe()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
|
|
284
|
+
};
|
|
285
|
+
var T = class T2 {
|
|
285
286
|
constructor(e) {
|
|
286
|
-
this.element = e, this.next =
|
|
287
|
+
this.element = e, this.next = T2.Undefined, this.prev = T2.Undefined;
|
|
287
288
|
}
|
|
288
289
|
};
|
|
289
|
-
|
|
290
|
-
var l =
|
|
290
|
+
T.Undefined = new T(void 0);
|
|
291
|
+
var l = T;
|
|
291
292
|
var L = class {
|
|
292
293
|
constructor() {
|
|
293
294
|
this._first = l.Undefined;
|
|
@@ -353,11 +354,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
353
354
|
for (; e !== l.Undefined;) yield e.element, e = e.next;
|
|
354
355
|
}
|
|
355
356
|
};
|
|
356
|
-
var
|
|
357
|
-
var
|
|
357
|
+
var je = 0;
|
|
358
|
+
var x = class {
|
|
358
359
|
constructor(e) {
|
|
359
360
|
this.value = e;
|
|
360
|
-
this.id =
|
|
361
|
+
this.id = je++;
|
|
361
362
|
}
|
|
362
363
|
};
|
|
363
364
|
var p = class {
|
|
@@ -367,18 +368,18 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
367
368
|
}
|
|
368
369
|
dispose(e) {
|
|
369
370
|
var t, r;
|
|
370
|
-
this._disposed || (this._disposed = true, this._listeners && (e ? (this._listeners instanceof
|
|
371
|
+
this._disposed || (this._disposed = true, this._listeners && (e ? (this._listeners instanceof x && (this._listeners = [this._listeners]), this._listeners = this._listeners.filter(o => (o == null ? void 0 : o.value) === e)) : (this._listeners = void 0, this._size = 0)), (r = (t = this.options) == null ? void 0 : t.onDidRemoveLastListener) == null || r.call(t));
|
|
371
372
|
}
|
|
372
373
|
get event() {
|
|
373
374
|
var e;
|
|
374
375
|
return (e = this._event) != null || (this._event = (t, r) => {
|
|
375
|
-
var i,
|
|
376
|
+
var i, s, c, a, m, d;
|
|
376
377
|
if (this._disposed) return () => {
|
|
377
378
|
console.info("[Jolibox SDK] Emitter is _disposed");
|
|
378
379
|
};
|
|
379
380
|
r && (t = t.bind(r));
|
|
380
|
-
let o = new
|
|
381
|
-
this._listeners ? this._listeners instanceof
|
|
381
|
+
let o = new x(t);
|
|
382
|
+
this._listeners ? this._listeners instanceof x ? this._listeners = [this._listeners, o] : this._listeners.push(o) : ((s = (i = this.options) == null ? void 0 : i.onWillAddFirstListener) == null || s.call(i, this), this._listeners = o, (a = (c = this.options) == null ? void 0 : c.onDidFirstListener) == null || a.call(c, this)), (d = (m = this.options) == null ? void 0 : m.onDidAddListener) == null || d.call(m, this), this._size++;
|
|
382
383
|
}), this._event;
|
|
383
384
|
}
|
|
384
385
|
_deliver(e, t) {
|
|
@@ -396,7 +397,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
396
397
|
}
|
|
397
398
|
}
|
|
398
399
|
fire(e) {
|
|
399
|
-
this._listeners && (this._listeners instanceof
|
|
400
|
+
this._listeners && (this._listeners instanceof x ? this._deliver(this._listeners, e) : this._listeners.forEach(t => this._deliver(t, e)));
|
|
400
401
|
}
|
|
401
402
|
hasListeners() {
|
|
402
403
|
return this._size > 0;
|
|
@@ -409,8 +410,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
409
410
|
this.cachedEventQueue = /* @__PURE__ */new Map();
|
|
410
411
|
}
|
|
411
412
|
on(e, t) {
|
|
412
|
-
var
|
|
413
|
-
let r = (
|
|
413
|
+
var s;
|
|
414
|
+
let r = (s = this.listeners.get(e)) != null ? s : new p(),
|
|
414
415
|
o = c => t(...c.args);
|
|
415
416
|
this.listerHandlerMap.set(t, o), r.event(o), this.listeners.set(e, r);
|
|
416
417
|
let i = this.cachedEventQueue.get(e);
|
|
@@ -441,17 +442,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
441
442
|
}
|
|
442
443
|
}
|
|
443
444
|
};
|
|
444
|
-
var
|
|
445
|
-
|
|
446
|
-
None: () =>
|
|
447
|
-
filter: () =>
|
|
445
|
+
var E = {};
|
|
446
|
+
he(E, {
|
|
447
|
+
None: () => He,
|
|
448
|
+
filter: () => Ge,
|
|
448
449
|
once: () => ue,
|
|
449
|
-
toPromise: () =>
|
|
450
|
+
toPromise: () => Ke
|
|
450
451
|
});
|
|
451
|
-
var
|
|
452
|
+
var He = () => {
|
|
452
453
|
console.log("[Jolibox SDK] None Event");
|
|
453
454
|
};
|
|
454
|
-
function
|
|
455
|
+
function Ke(n) {
|
|
455
456
|
return new Promise(e => ue(n)(e));
|
|
456
457
|
}
|
|
457
458
|
function ue(n) {
|
|
@@ -463,23 +464,23 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
463
464
|
}, null);
|
|
464
465
|
};
|
|
465
466
|
}
|
|
466
|
-
function
|
|
467
|
+
function Ge(n, e) {
|
|
467
468
|
return (r => {
|
|
468
469
|
let o,
|
|
469
470
|
i = {
|
|
470
471
|
onWillAddFirstListener() {
|
|
471
|
-
o = r(
|
|
472
|
+
o = r(s.fire, s);
|
|
472
473
|
}
|
|
473
474
|
},
|
|
474
|
-
|
|
475
|
-
return
|
|
475
|
+
s = new p(i);
|
|
476
|
+
return s.event;
|
|
476
477
|
})(function (r) {
|
|
477
478
|
let o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
478
479
|
return n(i => e(i) && r.call(o, i), null);
|
|
479
480
|
});
|
|
480
481
|
}
|
|
481
482
|
var U = Symbol.for("Jolibox.hostEmitter");
|
|
482
|
-
var
|
|
483
|
+
var Je = () => {
|
|
483
484
|
let n = new v();
|
|
484
485
|
return globalThis[U] || (globalThis[U] = {
|
|
485
486
|
on: n.on.bind(n),
|
|
@@ -487,12 +488,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
487
488
|
emit: n.emit.bind(n)
|
|
488
489
|
}), globalThis[U];
|
|
489
490
|
};
|
|
490
|
-
var
|
|
491
|
+
var Nt = Je();
|
|
491
492
|
function pe(n, e) {
|
|
492
493
|
let t = Math.min(n.length, e.length);
|
|
493
|
-
for (let r = 0; r < t; r++)
|
|
494
|
+
for (let r = 0; r < t; r++) $e(n[r], e[r]);
|
|
494
495
|
}
|
|
495
|
-
function
|
|
496
|
+
function $e(n, e) {
|
|
496
497
|
if (S(e)) {
|
|
497
498
|
if (typeof n !== e) throw new Error(`argument does not match constraint: typeof ${e}`);
|
|
498
499
|
} else if (M(e)) {
|
|
@@ -514,13 +515,13 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
514
515
|
if (!e) throw new Error("invalid command");
|
|
515
516
|
if (e.metadata && Array.isArray(e.metadata.args)) {
|
|
516
517
|
let o = [];
|
|
517
|
-
for (let
|
|
518
|
+
for (let s of e.metadata.args) o.push(s.constraint);
|
|
518
519
|
let i = e.handler;
|
|
519
520
|
e.handler = function () {
|
|
520
|
-
for (var _len3 = arguments.length,
|
|
521
|
-
|
|
521
|
+
for (var _len3 = arguments.length, s = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
522
|
+
s[_key3] = arguments[_key3];
|
|
522
523
|
}
|
|
523
|
-
return pe(
|
|
524
|
+
return pe(s, o), i(...s);
|
|
524
525
|
};
|
|
525
526
|
}
|
|
526
527
|
let {
|
|
@@ -540,7 +541,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
540
541
|
return e;
|
|
541
542
|
}
|
|
542
543
|
};
|
|
543
|
-
g = I([
|
|
544
|
+
g = I([A], g);
|
|
544
545
|
var _ = class {
|
|
545
546
|
constructor() {
|
|
546
547
|
this._onWillExecuteCommand = new p();
|
|
@@ -551,14 +552,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
551
552
|
this._starActivation = null;
|
|
552
553
|
}
|
|
553
554
|
_activateStar() {
|
|
554
|
-
return this._starActivation || (this._starActivation =
|
|
555
|
+
return this._starActivation || (this._starActivation = H(3e4)), this._starActivation;
|
|
555
556
|
}
|
|
556
557
|
executeCommand(e) {
|
|
557
558
|
for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
558
559
|
t[_key4 - 1] = arguments[_key4];
|
|
559
560
|
}
|
|
560
|
-
return
|
|
561
|
-
return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(),
|
|
561
|
+
return C(this, null, function* () {
|
|
562
|
+
return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(), E.toPromise(E.filter(this.registry.onDidRegisterCommand, o => o === e))])]), this._tryExecuteCommand(e, t));
|
|
562
563
|
});
|
|
563
564
|
}
|
|
564
565
|
executeCommandThowErr(e) {
|
|
@@ -606,34 +607,41 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
606
607
|
}
|
|
607
608
|
}
|
|
608
609
|
};
|
|
609
|
-
_ = I([
|
|
610
|
-
var
|
|
611
|
-
function
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
610
|
+
_ = I([A], _);
|
|
611
|
+
var fe = Symbol.for("Jolibox.commands");
|
|
612
|
+
function ze() {
|
|
613
|
+
return typeof globalThis != "undefined" ? globalThis[fe] : void 0;
|
|
614
|
+
}
|
|
615
|
+
function Be(n) {
|
|
616
|
+
typeof globalThis != "undefined" && (globalThis[fe] = n);
|
|
617
|
+
}
|
|
618
|
+
function ir() {
|
|
619
|
+
let n = ze();
|
|
620
|
+
if (n) return n;
|
|
621
|
+
let e = new g(),
|
|
622
|
+
t = new _(),
|
|
623
|
+
r = {
|
|
624
|
+
registerCommand(o, i, s) {
|
|
625
|
+
e.registerCommand({
|
|
626
|
+
id: o,
|
|
627
|
+
handler: i,
|
|
628
|
+
metadata: s
|
|
621
629
|
});
|
|
622
630
|
},
|
|
623
|
-
executeCommand(
|
|
624
|
-
for (var _len7 = arguments.length,
|
|
625
|
-
|
|
631
|
+
executeCommand(o) {
|
|
632
|
+
for (var _len7 = arguments.length, i = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
|
|
633
|
+
i[_key7 - 1] = arguments[_key7];
|
|
626
634
|
}
|
|
627
|
-
return
|
|
635
|
+
return t.executeCommand(o, ...i);
|
|
628
636
|
},
|
|
629
|
-
excuteCommandSync(
|
|
630
|
-
for (var _len8 = arguments.length,
|
|
631
|
-
|
|
637
|
+
excuteCommandSync(o) {
|
|
638
|
+
for (var _len8 = arguments.length, i = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
|
|
639
|
+
i[_key8 - 1] = arguments[_key8];
|
|
632
640
|
}
|
|
633
|
-
return
|
|
641
|
+
return t.executeCommandThowErr(o, ...i);
|
|
634
642
|
}
|
|
635
643
|
};
|
|
636
|
-
return
|
|
644
|
+
return Be(r), r;
|
|
637
645
|
}
|
|
638
646
|
|
|
639
647
|
// src/utils/env.ts
|
|
@@ -700,7 +708,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
700
708
|
try {
|
|
701
709
|
const reporterHost = API_BASE_URL;
|
|
702
710
|
const url = `${reporterHost}/report`;
|
|
703
|
-
const xua =
|
|
711
|
+
const xua = et("__JOLIBOX_LOCAL_SDK_VERSION__");
|
|
704
712
|
const joliSource = JOLI_SOURCE;
|
|
705
713
|
const headers = {
|
|
706
714
|
"Content-Type": "application/json"
|
|
@@ -736,9 +744,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
736
744
|
protocolVersion: "1.0.0",
|
|
737
745
|
events,
|
|
738
746
|
device,
|
|
739
|
-
project:
|
|
747
|
+
project: we.WebSDK
|
|
740
748
|
};
|
|
741
|
-
const serializedEventPackage =
|
|
749
|
+
const serializedEventPackage = Gn(eventPackage);
|
|
742
750
|
await postToReporter(serializedEventPackage);
|
|
743
751
|
} catch (error) {
|
|
744
752
|
console.error("Failed to track error:", error);
|
|
@@ -746,7 +754,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
746
754
|
}
|
|
747
755
|
|
|
748
756
|
// src/events.ts
|
|
749
|
-
document.addEventListener("DOMContentLoaded", () =>
|
|
757
|
+
document.addEventListener("DOMContentLoaded", () => Nt.emit("onDocumentReady", timeline.startTime));
|
|
750
758
|
var timelineFactory = () => {
|
|
751
759
|
let _beginLoad = 0;
|
|
752
760
|
return {
|
|
@@ -759,7 +767,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
759
767
|
};
|
|
760
768
|
};
|
|
761
769
|
var timeline = timelineFactory();
|
|
762
|
-
var commands =
|
|
770
|
+
var commands = ir();
|
|
763
771
|
var rejectHandler = event => {
|
|
764
772
|
commands.executeCommand("ReportSDK.traceSystem", {
|
|
765
773
|
event: "globalJsError",
|
|
@@ -859,7 +867,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
859
867
|
};
|
|
860
868
|
|
|
861
869
|
// src/utils/report.ts
|
|
862
|
-
var commands2 =
|
|
870
|
+
var commands2 = ir();
|
|
863
871
|
var track = (event, info) => {
|
|
864
872
|
commands2.executeCommand("ReportSDK.traceSystem", {
|
|
865
873
|
event,
|
|
@@ -875,7 +883,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
875
883
|
};
|
|
876
884
|
|
|
877
885
|
// src/loader/h5.ts
|
|
878
|
-
|
|
886
|
+
ce();
|
|
879
887
|
var LOCAL_STORE_KEY = "jolibox-sdk-loadermeta";
|
|
880
888
|
var CURRENT_VERSION_STORE = JSON.parse(window.__joliboxLocalStorage__.getItem(LOCAL_STORE_KEY) ?? "{}");
|
|
881
889
|
var now = Date.now();
|
|
@@ -960,7 +968,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
960
968
|
type: "fetch_from_cdn"
|
|
961
969
|
};
|
|
962
970
|
} catch (e) {
|
|
963
|
-
const internalError = new
|
|
971
|
+
const internalError = new W(`Bootstrap module faile to fetch ${e}`);
|
|
964
972
|
trackError({
|
|
965
973
|
err: `${internalError}`
|
|
966
974
|
});
|
|
@@ -997,7 +1005,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
997
1005
|
URL.revokeObjectURL(blobUrl);
|
|
998
1006
|
return module;
|
|
999
1007
|
} catch (error) {
|
|
1000
|
-
const internalError = new
|
|
1008
|
+
const internalError = new Q(`implement module evaluate error in h5:${error} `);
|
|
1001
1009
|
trackError({
|
|
1002
1010
|
err: `${internalError}`
|
|
1003
1011
|
});
|
|
@@ -1038,7 +1046,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1038
1046
|
loadRemoteImplement();
|
|
1039
1047
|
fetchCurrentRemoteScript();
|
|
1040
1048
|
} catch (e) {
|
|
1041
|
-
const internalError = new
|
|
1049
|
+
const internalError = new Q(`module evaluate error: ${e}`);
|
|
1042
1050
|
trackError({
|
|
1043
1051
|
err: `${internalError}`
|
|
1044
1052
|
});
|
|
@@ -1068,7 +1076,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1068
1076
|
URL.revokeObjectURL(blobUrl);
|
|
1069
1077
|
return module;
|
|
1070
1078
|
} catch (error) {
|
|
1071
|
-
reportError(new
|
|
1079
|
+
reportError(new Q(`implement module evaluate error in native:${error} `));
|
|
1072
1080
|
}
|
|
1073
1081
|
};
|
|
1074
1082
|
evalJS(code);
|
|
@@ -1096,7 +1104,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1096
1104
|
});
|
|
1097
1105
|
} catch (e) {
|
|
1098
1106
|
console.error(`native load script error: ${e}`);
|
|
1099
|
-
reportError(new
|
|
1107
|
+
reportError(new Q(`module load failed ${e}`));
|
|
1100
1108
|
}
|
|
1101
1109
|
};
|
|
1102
1110
|
};
|
|
@@ -1146,7 +1154,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1146
1154
|
loadImplement();
|
|
1147
1155
|
|
|
1148
1156
|
// src/api/get-system-info.ts
|
|
1149
|
-
var commands3 =
|
|
1157
|
+
var commands3 = ir();
|
|
1150
1158
|
function getSystemInfoSync() {
|
|
1151
1159
|
return commands3.excuteCommandSync("API.getSystemInfoSync");
|
|
1152
1160
|
}
|
|
@@ -1156,7 +1164,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1156
1164
|
|
|
1157
1165
|
// src/utils/can-i-use.ts
|
|
1158
1166
|
function getCanIUseConfig(platform, key) {
|
|
1159
|
-
return
|
|
1167
|
+
return Un.config[platform]?.[key];
|
|
1160
1168
|
}
|
|
1161
1169
|
function get(obj, path, defaultValue) {
|
|
1162
1170
|
const pathArray = Array.isArray(path) ? path : path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
@@ -1184,7 +1192,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1184
1192
|
if (!api) return false;
|
|
1185
1193
|
const apiVersion = api["version"];
|
|
1186
1194
|
if (typeof apiVersion !== "string") return false;
|
|
1187
|
-
if (
|
|
1195
|
+
if (jn(__VERSION__, apiVersion, "<")) return false;
|
|
1188
1196
|
if (rest.length === 0) return true;
|
|
1189
1197
|
return checkRest(api, rest) || checkRest(api["properties"], rest);
|
|
1190
1198
|
}
|
|
@@ -1193,12 +1201,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1193
1201
|
const v2 = get(info, paths);
|
|
1194
1202
|
if (!v2) return false;
|
|
1195
1203
|
if (Re(v2)) return true;
|
|
1196
|
-
if (S(v2)) return
|
|
1204
|
+
if (S(v2)) return jn(__VERSION__, v2, ">=");
|
|
1197
1205
|
return false;
|
|
1198
1206
|
}
|
|
1199
1207
|
|
|
1200
1208
|
// src/api/login.ts
|
|
1201
|
-
var commands4 =
|
|
1209
|
+
var commands4 = ir();
|
|
1202
1210
|
async function login() {
|
|
1203
1211
|
if (!canIUse("login")) {
|
|
1204
1212
|
return {
|
|
@@ -1219,7 +1227,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1219
1227
|
}
|
|
1220
1228
|
|
|
1221
1229
|
// src/api/request.ts
|
|
1222
|
-
var commands5 =
|
|
1230
|
+
var commands5 = ir();
|
|
1223
1231
|
async function request(params) {
|
|
1224
1232
|
if (!canIUse("request")) {
|
|
1225
1233
|
return {
|
|
@@ -1258,7 +1266,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
1258
1266
|
// src/sdks/sdk.ts
|
|
1259
1267
|
var BaseSDK = class {
|
|
1260
1268
|
constructor() {
|
|
1261
|
-
this.commands =
|
|
1269
|
+
this.commands = ir();
|
|
1262
1270
|
this._emitter = new v();
|
|
1263
1271
|
}
|
|
1264
1272
|
addEventListener(event, callback) {
|
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.13-beta.
|
|
4
|
+
"version": "1.1.13-beta.9",
|
|
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.13-beta.
|
|
11
|
-
"@jolibox/types": "1.1.13-beta.
|
|
10
|
+
"@jolibox/common": "1.1.13-beta.9",
|
|
11
|
+
"@jolibox/types": "1.1.13-beta.9"
|
|
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.13-beta.
|
|
3
|
+
> @jolibox/sdk@1.1.13-beta.9 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.1.13-beta.
|
|
7
|
+
> @jolibox/sdk@1.1.13-beta.9 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.13-beta.
|
|
11
|
+
> @jolibox/sdk@1.1.13-beta.9 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.13-beta.
|
|
15
|
+
> @jolibox/sdk@1.1.13-beta.9 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|