@jolibox/sdk 1.1.29 → 1.1.31
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 +2 -2
- 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 +137 -134
- package/package.json +3 -3
- package/sdk.build.log +4 -4
- package/src/sdks/router.ts +8 -1
|
@@ -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": "c5396055321715cf62586a1a6aef75360723c747",
|
|
8
8
|
"packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
|
|
9
9
|
"packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
|
|
10
10
|
"packages/sdk/src/api/can-i-use.ts": "f3294bb1dd64849bcc95a3490c13ec0cf0509628",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
|
|
24
24
|
"packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
|
|
25
25
|
"packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
|
|
26
|
-
"packages/sdk/src/sdks/router.ts": "
|
|
26
|
+
"packages/sdk/src/sdks/router.ts": "f71c1292340b2c2e373ac6e059f2997e5c0ced84",
|
|
27
27
|
"packages/sdk/src/sdks/runtime.ts": "2194c4f9f630df3cf5b48bdcbdd2cf45a2187a1e",
|
|
28
28
|
"packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
|
|
29
29
|
"packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty,mt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))Se.call(t,r)&&ve(e,r,t[r]);if(_e)for(var r of _e(t))ht.call(t,r)&&ve(e,r,t[r]);return e},U=(e,t)=>mt(e,pt(t));var gt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},Et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!Se.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=ut(t,o))||n.enumerable});return e};var yt=e=>Et(P({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var vr={};gt(vr,{JoliboxSDK:()=>z});module.exports=yt(vr);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 te=Object.defineProperty,_t=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xt=(e,t)=>{for(var r in t||(t={}))bt.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},It=(e,t)=>_t(e,St(t)),wt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?vt(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&&te(t,r,o),o},Tt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 Lt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function At(e){return typeof e=="undefined"}function Dt(e){return At(e)||e===null}function Pt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(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))(Ot||{}),N=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}},Le=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ut={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Ut});var Y=Symbol.for("Jolibox.canIUseMap"),Ct={};globalThis[Y]||(globalThis[Y]=Ct);var De={get config(){return globalThis[Y]}};function ne(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 oe=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),kt=(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))(kt||{}),xe=["name","params"],Kt=["name","type","location","target","extra","timestamp","userId"],Nt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(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 Mt(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(It(xt({},e),{location:t,target:r}),Kt)}function Pe(e){let t=e.events.map(n=>Mt(n)),r=k(e.device,Nt);return[e.protocolVersion,t,r,e.project]}var jt=()=>"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 ie(){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}}ie();var ae=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={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")},Jt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",Ft="device_id",Bt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,jt()),window.__joliboxLocalStorage__.getItem(e)),Vt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Ft),$t=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Bt),Gt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ht=()=>{var e;let t=new URLSearchParams(window.location.search);return Gt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Jt(),n=navigator.language,o=Vt(),s=$t();return`${t} (${Ht()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};q.Undefined=new q(void 0);var m=q,Wt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},zt=0,x=class{constructor(e){this.value=e,this.id=zt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,Ee;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Wt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};wt(Z,{None:()=>Qt,filter:()=>qt,once:()=>Ce,toPromise:()=>Yt});var Qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Ce(e)(t))}function Ce(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),Xt=()=>{let e=new ce;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},v=Xt();function Zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)er(e[n],t[n])}function er(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Pt(t)){try{if(e instanceof t)return}catch(r){}if(!Dt(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 I,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 Zt(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=Ie([Te],K);var ee=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Lt(3e4)),this._starActivation}executeCommand(e,...t){return Tt(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}}};ee=Ie([Te],ee);var ke=Symbol.for("Jolibox.commands");function tr(){return typeof globalThis!="undefined"?globalThis[ke]:void 0}function rr(e){typeof globalThis!="undefined"&&(globalThis[ke]=e)}function h(){let e=tr();if(e)return e;let t=new K,r=new ee,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 rr(n),n}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function nr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function or(){return{platform:1e3,os:"h5",appVersion:"1.1.29",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.29",extra:{}}}var Ke={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"}},sr=()=>{var t;let e=(t=Ke[window.location.host])!=null?t:Ke.default;return j?e.test:e.prod},ir=sr(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ne;(Ne=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var ar=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},cr=ar(),lr=e=>d(void 0,null,function*(){try{let r=`${ir}/report`,n=Ue("1.1.29"),o=cr,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:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:nr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=or(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Pe(o);yield lr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var dr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=dr(),je=h(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var de=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(de(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=de(e),{major:a,minor:l,patch:i,prerelease:c}=de(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Je=h(),J=(e,t)=>{Je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ve="jolibox-sdk-loadermeta",Be,D=JSON.parse((Be=window.__joliboxLocalStorage__.getItem(Ve))!=null?Be:"{}"),me=Date.now(),Fe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function mr(){return d(this,null,function*(){let t=`${j?"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=U(O({},D),{timestamp:me});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(O({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(O({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ve,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var $e=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Fe(me,c)&&L(i)==t&&A(i,r)>=0&&(n=ue(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Ae(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Fe(me,u)&&L(c)==t&&A(c,r)>=0&&(o=pe(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),mr()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ge=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ur="1.1.29",F=ur,Qe=L(F),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),pr=Ye?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,fe="https://jsdelivr.jolibox.com",He=window.document.currentScript;He&&(fe=new URL(He.src).origin);var ue=e=>`${fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=e=>`${fe}/npm/@jolibox/implement@${e}/dist/index.js`,fr=e=>/^\d+\.\d+\.\d+$/.test(e),qe=fr(F)?Qe:F,We=ue(qe),ze=pe(qe);function hr(){Ye?Ge(pr,{bootstrapUrl:We,implementUrl:ze})():$e({bootstrapUrl:We,implementUrl:ze,currentMajorVersion:Qe,currentVersion:F})()}hr();var gr=h();function Xe(){return gr.excuteCommandSync("API.getSystemInfoSync")}function Ze(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function et(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 rt="1.1.29";function E(e){let[t,...r]=e.split(":"),n=Ze(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(rt,o,"<")?!1:r.length===0?!0:tt(n,r)||tt(n.properties,r)}function tt(e,t){if(!e)return!1;let r=et(e,t);return r?we(r)?!0:re(r)?ne(rt,r,">="):!1:!1}var nt=h();function ot(){return d(this,null,function*(){return E("login")?yield nt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function st(){return d(this,null,function*(){return E("checkSession")?yield nt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Er=h();function it(e){return d(this,null,function*(){return E("request")?yield Er.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],at=(e,t)=>{if(!he.includes(e)){_(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},ct=(e,t)=>{if(!he.includes(e)){_(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},lt=(e,t)=>{if(!he.includes(e)){_(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var ge=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)}}},dt=window.JoliboxRuntime||ge;var p=class{constructor(){this.commands=h();this._emitter=new ce}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 yr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(yr,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 V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var G=class extends p{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 H=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var _r=["openHistory"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(_r.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.29";this.runtime=new dt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.getSystemInfoSync=Xe.bind(this);this.canIUse=E.bind(this);this.login=ot.bind(this);this.checkSession=st.bind(this);this.request=it.bind(this);this.on=at.bind(this);this.off=ct.bind(this);this.once=lt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var z=g;window.JoliboxSDK=z;
|
|
1
|
+
"use strict";var P=Object.defineProperty,ut=Object.defineProperties,pt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))Se.call(t,r)&&ve(e,r,t[r]);if(_e)for(var r of _e(t))gt.call(t,r)&&ve(e,r,t[r]);return e},O=(e,t)=>ut(e,ft(t));var Et=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},yt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ht(t))!Se.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=pt(t,o))||n.enumerable});return e};var _t=e=>yt(P({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var br={};Et(br,{JoliboxSDK:()=>z});module.exports=_t(br);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 te=Object.defineProperty,vt=Object.defineProperties,St=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,It=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))xt.call(t,r)&&Re(e,r,t[r]);return e},wt=(e,t)=>vt(e,bt(t)),Tt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?St(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&&te(t,r,o),o},Lt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 At(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Dt(e){return typeof e=="undefined"}function Pt(e){return Dt(e)||e===null}function Ut(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(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))(Ot||{}),N=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}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ct={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Ct});var Y=Symbol.for("Jolibox.canIUseMap"),kt={};globalThis[Y]||(globalThis[Y]=kt);var Pe={get config(){return globalThis[Y]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[xe]||(globalThis[xe]=Kt);function ne(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 oe=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),Nt=(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))(Nt||{}),Ie=["name","params"],Mt=["name","type","location","target","extra","timestamp","userId"],jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(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 Jt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(wt(It({},e),{location:t,target:r}),Mt)}function Ue(e){let t=e.events.map(n=>Jt(n)),r=k(e.device,jt);return[e.protocolVersion,t,r,e.project]}var Ft=()=>"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 ie(){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}}ie();var ae=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={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")},Bt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",Vt="device_id",$t="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ft()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Vt),Ht=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe($t),Wt=e=>e.charAt(0).toUpperCase()+e.slice(1),zt=()=>{var e;let t=new URLSearchParams(window.location.search);return Wt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,o=Gt(),s=Ht();return`${t} (${zt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};q.Undefined=new q(void 0);var m=q,Qt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Yt=0,x=class{constructor(e){this.value=e,this.id=Yt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,Ee;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Qt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};Tt(Z,{None:()=>qt,filter:()=>Zt,once:()=>ke,toPromise:()=>Xt});var qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Xt(e){return new Promise(t=>ke(e)(t))}function ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),er=()=>{let e=new ce;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},v=er();function tr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)rr(e[n],t[n])}function rr(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ut(t)){try{if(e instanceof t)return}catch(r){}if(!Pt(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 I,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 tr(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=we([Le],K);var ee=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=At(3e4)),this._starActivation}executeCommand(e,...t){return Lt(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}}};ee=we([Le],ee);var Ke=Symbol.for("Jolibox.commands");function nr(){return typeof globalThis!="undefined"?globalThis[Ke]:void 0}function or(e){typeof globalThis!="undefined"&&(globalThis[Ke]=e)}function h(){let e=nr();if(e)return e;let t=new K,r=new ee,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 or(n),n}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function sr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function ir(){return{platform:1e3,os:"h5",appVersion:"1.1.31",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.31",extra:{}}}var Ne={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"}},ar=()=>{var t;let e=(t=Ne[window.location.host])!=null?t:Ne.default;return j?e.test:e.prod},cr=ar(),je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Me;(Me=AbortSignal.timeout)!=null||(AbortSignal.timeout=je);var lr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},dr=lr(),mr=e=>d(void 0,null,function*(){try{let r=`${cr}/report`,n=Ce("1.1.31"),o=dr,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:je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:sr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=ir(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield mr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ur=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ur(),Je=h(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var de=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(de(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=de(e),{major:a,minor:l,patch:i,prerelease:c}=de(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Fe=h(),J=(e,t)=>{Fe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Fe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var $e="jolibox-sdk-loadermeta",Ve,D=JSON.parse((Ve=window.__joliboxLocalStorage__.getItem($e))!=null?Ve:"{}"),me=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function pr(){return d(this,null,function*(){let t=`${j?"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=O(U({},D),{timestamp:me});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem($e,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Be(me,c)&&L(i)==t&&A(i,r)>=0&&(n=ue(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new De(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Be(me,u)&&L(c)==t&&A(c,r)>=0&&(o=pe(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),pr()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var He=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var fr="1.1.31",F=fr,Ye=L(F),qe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),hr=qe?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,fe="https://jsdelivr.jolibox.com",We=window.document.currentScript;We&&(fe=new URL(We.src).origin);var ue=e=>`${fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=e=>`${fe}/npm/@jolibox/implement@${e}/dist/index.js`,gr=e=>/^\d+\.\d+\.\d+$/.test(e),Xe=gr(F)?Ye:F,ze=ue(Xe),Qe=pe(Xe);function Er(){qe?He(hr,{bootstrapUrl:ze,implementUrl:Qe})():Ge({bootstrapUrl:ze,implementUrl:Qe,currentMajorVersion:Ye,currentVersion:F})()}Er();var yr=h();function Ze(){return yr.excuteCommandSync("API.getSystemInfoSync")}function et(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function tt(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 nt="1.1.31";function E(e){let[t,...r]=e.split(":"),n=et(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(nt,o,"<")?!1:r.length===0?!0:rt(n,r)||rt(n.properties,r)}function rt(e,t){if(!e)return!1;let r=tt(e,t);return r?Te(r)?!0:re(r)?ne(nt,r,">="):!1:!1}var ot=h();function st(){return d(this,null,function*(){return E("login")?yield ot.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function it(){return d(this,null,function*(){return E("checkSession")?yield ot.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var _r=h();function at(e){return d(this,null,function*(){return E("request")?yield _r.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],ct=(e,t)=>{if(!he.includes(e)){_(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},lt=(e,t)=>{if(!he.includes(e)){_(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},dt=(e,t)=>{if(!he.includes(e)){_(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var ge=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)}}},mt=window.JoliboxRuntime||ge;var p=class{constructor(){this.commands=h();this._emitter=new ce}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 vr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(vr,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 V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var G=class extends p{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 H=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var Sr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Sr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.31";this.runtime=new mt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.getSystemInfoSync=Ze.bind(this);this.canIUse=E.bind(this);this.login=st.bind(this);this.checkSession=it.bind(this);this.request=at.bind(this);this.on=ct.bind(this);this.off=lt.bind(this);this.once=dt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var z=g;window.JoliboxSDK=z;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var lt=Object.defineProperty,dt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))pt.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,mt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))yt.call(t,r)&&Se(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},Re=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(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},bt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function xt(e){return typeof e=="undefined"}function It(e){return xt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Lt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Le={get config(){return globalThis[z]}};function te(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Dt||{}),be=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ut(e){let t=e.location?C(e.location,be):null,r=e.target?C(e.target,be):null;return C(vt(_t({},e),{location:t,target:r}),Pt)}function Ae(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),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",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,Bt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Vt=0,x=class{constructor(e){this.value=e,this.id=Vt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};St(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Qt(e[n],t[n])}function Qt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=Re([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(3e4)),this._starActivation}executeCommand(e,...t){return bt(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}}};X=Re([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,r=new X,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.29",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.29",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>d(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.29"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Ae(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return d(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Te(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ve=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ar="1.1.29",J=ar,We=L(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=de(Qe),He=me(Qe);function dr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}dr();var mr=h();function Ye(){return mr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Le.config[e])==null?void 0:r[t]}function Xe(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 et="1.1.29";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?xe(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return d(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return d(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return d(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},it=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}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 pr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(pr,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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var $=class extends p{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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.29";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var he=g;window.JoliboxSDK=he;export{he as JoliboxSDK};
|
|
1
|
+
var dt=Object.defineProperty,mt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))pt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))ft.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>mt(e,ut(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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,ht=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&Se(e,r,t[r]);return e},St=(e,t)=>ht(e,Et(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{for(var o=n>1?void 0:n?gt(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},Rt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function It(e){return typeof e=="undefined"}function wt(e){return It(e)||e===null}function Tt(e){return typeof e=="function"}function we(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Lt=(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))(Lt||{}),K=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}},Te=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var At={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:At});var z=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[z]||(globalThis[z]=Dt);var Ae={get config(){return globalThis[z]}};var be=Symbol.for("Jolibox.canIUseMap.native"),Pt={};globalThis[be]||(globalThis[be]=Pt);function te(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ut=(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))(Ut||{}),Re=["name","params"],Ot=["name","type","location","target","extra","timestamp","userId"],Ct=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?C(e.location,Re):null,r=e.target?C(e.target,Re):null;return C(St(vt({},e),{location:t,target:r}),Ot)}function De(e){let t=e.events.map(n=>kt(n)),r=C(e.device,Ct);return[e.protocolVersion,t,r,e.project]}var Kt=()=>"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 oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={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")},Nt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Mt="device_id",jt="advertising_id",Pe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Kt()),window.__joliboxLocalStorage__.getItem(e)),Jt=()=>new URLSearchParams(window.location.search).get("deviceId")||Pe(Mt),Ft=()=>new URLSearchParams(window.location.search).get("advertisingId")||Pe(jt),Bt=e=>e.charAt(0).toUpperCase()+e.slice(1),Vt=()=>{var e;let t=new URLSearchParams(window.location.search);return Bt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Nt(),n=navigator.language,o=Jt(),s=Ft();return`${t} (${Vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,$t=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Gt=0,x=class{constructor(e){this.value=e,this.id=Gt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new $t,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};bt(q,{None:()=>Ht,filter:()=>zt,once:()=>Oe,toPromise:()=>Wt});var Ht=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Wt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Qt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Qt();function Yt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qt(e[n],t[n])}function qt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Tt(t)){try{if(e instanceof t)return}catch(r){}if(!wt(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 I,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 Yt(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=xe([we],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xt(3e4)),this._starActivation}executeCommand(e,...t){return Rt(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}}};X=xe([we],X);var Ce=Symbol.for("Jolibox.commands");function Xt(){return typeof globalThis!="undefined"?globalThis[Ce]:void 0}function Zt(e){typeof globalThis!="undefined"&&(globalThis[Ce]=e)}function h(){let e=Xt();if(e)return e;let t=new k,r=new X,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 Zt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function er(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function tr(){return{platform:1e3,os:"h5",appVersion:"1.1.31",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.31",extra:{}}}var ke={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"}},rr=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return M?e.test:e.prod},nr=rr(),Ne=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ke;(Ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ne);var or=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},sr=or(),ir=e=>d(void 0,null,function*(){try{let r=`${nr}/report`,n=Ue("1.1.31"),o=sr,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:Ne(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:er(),target:null,extra:e,timestamp:Date.now(),userId:null},r=tr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=De(o);yield ir(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ar=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ar(),Me=h(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var je=h(),j=(e,t)=>{je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Be="jolibox-sdk-loadermeta",Fe,D=JSON.parse((Fe=window.__joliboxLocalStorage__.getItem(Be))!=null?Fe:"{}"),le=Date.now(),Je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function cr(){return d(this,null,function*(){let t=`${M?"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=U(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Be,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ve=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Le(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),cr()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var $e=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var lr="1.1.31",J=lr,ze=L(J),Qe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),dr=Qe?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,ue="https://jsdelivr.jolibox.com",Ge=window.document.currentScript;Ge&&(ue=new URL(Ge.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,mr=e=>/^\d+\.\d+\.\d+$/.test(e),Ye=mr(J)?ze:J,He=de(Ye),We=me(Ye);function ur(){Qe?$e(dr,{bootstrapUrl:He,implementUrl:We})():Ve({bootstrapUrl:He,implementUrl:We,currentMajorVersion:ze,currentVersion:J})()}ur();var pr=h();function qe(){return pr.excuteCommandSync("API.getSystemInfoSync")}function Xe(e,t){var r;return(r=Ae.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 tt="1.1.31";function E(e){let[t,...r]=e.split(":"),n=Xe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(tt,o,"<")?!1:r.length===0?!0:et(n,r)||et(n.properties,r)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?Ie(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=h();function nt(){return d(this,null,function*(){return E("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return d(this,null,function*(){return E("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var fr=h();function st(e){return d(this,null,function*(){return E("request")?yield fr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],it=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},ct=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},lt=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}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 hr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(hr,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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var $=class extends p{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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var gr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(gr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.31";this.runtime=new lt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=qe.bind(this);this.canIUse=E.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var he=g;window.JoliboxSDK=he;export{he as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var lt=Object.defineProperty,dt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))pt.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,mt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))yt.call(t,r)&&Se(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},Re=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(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},bt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function xt(e){return typeof e=="undefined"}function It(e){return xt(e)||e===null}function wt(e){return typeof e=="function"}function Ie(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),K=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}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Te=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Lt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Le={get config(){return globalThis[z]}};function te(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Dt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Dt||{}),be=["name","params"],Pt=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ut(e){let t=e.location?C(e.location,be):null,r=e.target?C(e.target,be):null;return C(vt(_t({},e),{location:t,target:r}),Pt)}function Ae(e){let t=e.events.map(n=>Ut(n)),r=C(e.device,Ot);return[e.protocolVersion,t,r,e.project]}var Ct=()=>"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 oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),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",Kt="device_id",Nt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ct()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Kt),jt=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(Nt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Pe=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,Bt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Vt=0,x=class{constructor(e){this.value=e,this.id=Vt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Bt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};St(q,{None:()=>$t,filter:()=>Ht,once:()=>Oe,toPromise:()=>Gt});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ht(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Wt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Wt();function zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Qt(e[n],t[n])}function Qt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 I,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 zt(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=Re([Ie],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(3e4)),this._starActivation}executeCommand(e,...t){return bt(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}}};X=Re([Ie],X);var Ue=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Yt();if(e)return e;let t=new k,r=new X,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 qt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.29",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.29",extra:{}}}var Ce={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"}},er=()=>{var t;let e=(t=Ce[window.location.host])!=null?t:Ce.default;return M?e.test:e.prod},tr=er(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>d(void 0,null,function*(){try{let r=`${tr}/report`,n=Pe("1.1.29"),o=nr,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:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Ae(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=sr(),Ne=h(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Fe="jolibox-sdk-loadermeta",Je,D=JSON.parse((Je=window.__joliboxLocalStorage__.getItem(Fe))!=null?Je:"{}"),le=Date.now(),je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){return d(this,null,function*(){let t=`${M?"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=O(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Fe,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Be=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Te(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ve=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ar="1.1.29",J=ar,We=L(J),ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=ze?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,ue="https://jsdelivr.jolibox.com",$e=window.document.currentScript;$e&&(ue=new URL($e.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=lr(J)?We:J,Ge=de(Qe),He=me(Qe);function dr(){ze?Ve(cr,{bootstrapUrl:Ge,implementUrl:He})():Be({bootstrapUrl:Ge,implementUrl:He,currentMajorVersion:We,currentVersion:J})()}dr();var mr=h();function Ye(){return mr.excuteCommandSync("API.getSystemInfoSync")}function qe(e,t){var r;return(r=Le.config[e])==null?void 0:r[t]}function Xe(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 et="1.1.29";function E(e){let[t,...r]=e.split(":"),n=qe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(et,o,"<")?!1:r.length===0?!0:Ze(n,r)||Ze(n.properties,r)}function Ze(e,t){if(!e)return!1;let r=Xe(e,t);return r?xe(r)?!0:ee(r)?te(et,r,">="):!1:!1}var tt=h();function rt(){return d(this,null,function*(){return E("login")?yield tt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function nt(){return d(this,null,function*(){return E("checkSession")?yield tt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function ot(e){return d(this,null,function*(){return E("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],st=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},it=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},ct=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}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 pr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(pr,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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var $=class extends p{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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var fr=["openHistory"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(fr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.29";this.runtime=new ct;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=rt.bind(this);this.checkSession=nt.bind(this);this.request=ot.bind(this);this.on=st.bind(this);this.off=it.bind(this);this.once=at.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var he=g;window.JoliboxSDK=he;})();
|
|
1
|
+
"use strict";(()=>{var dt=Object.defineProperty,mt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))pt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))ft.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>mt(e,ut(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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,ht=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&Se(e,r,t[r]);return e},St=(e,t)=>ht(e,Et(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{for(var o=n>1?void 0:n?gt(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},Rt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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 xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function It(e){return typeof e=="undefined"}function wt(e){return It(e)||e===null}function Tt(e){return typeof e=="function"}function we(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Lt=(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))(Lt||{}),K=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}},Te=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var At={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:At});var z=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[z]||(globalThis[z]=Dt);var Ae={get config(){return globalThis[z]}};var be=Symbol.for("Jolibox.canIUseMap.native"),Pt={};globalThis[be]||(globalThis[be]=Pt);function te(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 l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ut=(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))(Ut||{}),Re=["name","params"],Ot=["name","type","location","target","extra","timestamp","userId"],Ct=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?C(e.location,Re):null,r=e.target?C(e.target,Re):null;return C(St(vt({},e),{location:t,target:r}),Ot)}function De(e){let t=e.events.map(n=>kt(n)),r=C(e.device,Ct);return[e.protocolVersion,t,r,e.project]}var Kt=()=>"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 oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={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")},Nt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Mt="device_id",jt="advertising_id",Pe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Kt()),window.__joliboxLocalStorage__.getItem(e)),Jt=()=>new URLSearchParams(window.location.search).get("deviceId")||Pe(Mt),Ft=()=>new URLSearchParams(window.location.search).get("advertisingId")||Pe(jt),Bt=e=>e.charAt(0).toUpperCase()+e.slice(1),Vt=()=>{var e;let t=new URLSearchParams(window.location.search);return Bt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Nt(),n=navigator.language,o=Jt(),s=Ft();return`${t} (${Vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};Q.Undefined=new Q(void 0);var m=Q,$t=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Gt=0,x=class{constructor(e){this.value=e,this.id=Gt++}},I=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 x&&(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,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new $t,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},q={};bt(q,{None:()=>Ht,filter:()=>zt,once:()=>Oe,toPromise:()=>Wt});var Ht=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Wt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),Qt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=Qt();function Yt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qt(e[n],t[n])}function qt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Tt(t)){try{if(e instanceof t)return}catch(r){}if(!wt(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 I,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 Yt(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=xe([we],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xt(3e4)),this._starActivation}executeCommand(e,...t){return Rt(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}}};X=xe([we],X);var Ce=Symbol.for("Jolibox.commands");function Xt(){return typeof globalThis!="undefined"?globalThis[Ce]:void 0}function Zt(e){typeof globalThis!="undefined"&&(globalThis[Ce]=e)}function h(){let e=Xt();if(e)return e;let t=new k,r=new X,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 Zt(n),n}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function er(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function tr(){return{platform:1e3,os:"h5",appVersion:"1.1.31",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.31",extra:{}}}var ke={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"}},rr=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return M?e.test:e.prod},nr=rr(),Ne=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ke;(Ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ne);var or=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},sr=or(),ir=e=>d(void 0,null,function*(){try{let r=`${nr}/report`,n=Ue("1.1.31"),o=sr,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:Ne(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:er(),target:null,extra:e,timestamp:Date.now(),userId:null},r=tr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=De(o);yield ir(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ar=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ar(),Me=h(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;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]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var je=h(),j=(e,t)=>{je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Be="jolibox-sdk-loadermeta",Fe,D=JSON.parse((Fe=window.__joliboxLocalStorage__.getItem(Be))!=null?Fe:"{}"),le=Date.now(),Je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function cr(){return d(this,null,function*(){let t=`${M?"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=U(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Be,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ve=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=de(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Le(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Je(le,u)&&L(c)==t&&A(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),cr()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var $e=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var lr="1.1.31",J=lr,ze=L(J),Qe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),dr=Qe?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,ue="https://jsdelivr.jolibox.com",Ge=window.document.currentScript;Ge&&(ue=new URL(Ge.src).origin);var de=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,mr=e=>/^\d+\.\d+\.\d+$/.test(e),Ye=mr(J)?ze:J,He=de(Ye),We=me(Ye);function ur(){Qe?$e(dr,{bootstrapUrl:He,implementUrl:We})():Ve({bootstrapUrl:He,implementUrl:We,currentMajorVersion:ze,currentVersion:J})()}ur();var pr=h();function qe(){return pr.excuteCommandSync("API.getSystemInfoSync")}function Xe(e,t){var r;return(r=Ae.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 tt="1.1.31";function E(e){let[t,...r]=e.split(":"),n=Xe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(tt,o,"<")?!1:r.length===0?!0:et(n,r)||et(n.properties,r)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?Ie(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=h();function nt(){return d(this,null,function*(){return E("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return d(this,null,function*(){return E("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var fr=h();function st(e){return d(this,null,function*(){return E("request")?yield fr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],it=(e,t)=>{if(!pe.includes(e)){_(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},at=(e,t)=>{if(!pe.includes(e)){_(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},ct=(e,t)=>{if(!pe.includes(e)){_(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var fe=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)}}},lt=window.JoliboxRuntime||fe;var p=class{constructor(){this.commands=h();this._emitter=new ie}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 hr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(hr,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 B=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{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)}}initAd(r){return d(this,null,function*(){})}};var $=class extends p{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 G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var gr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],H=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(gr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.31";this.runtime=new lt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=qe.bind(this);this.canIUse=E.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var he=g;window.JoliboxSDK=he;})();
|
package/dist/index.js
CHANGED
|
@@ -4,35 +4,35 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
4
4
|
(_JoliboxSDK2 => {
|
|
5
5
|
// ../common/dist/index.es.js
|
|
6
6
|
var M = Object.defineProperty;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var Re = Object.defineProperties;
|
|
8
|
+
var ve = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var be = Object.getOwnPropertyDescriptors;
|
|
10
10
|
var J = Object.getOwnPropertySymbols;
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
11
|
+
var Ie = Object.prototype.hasOwnProperty;
|
|
12
|
+
var Ae = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var z = (n, e, t) => e in n ? M(n, e, {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
configurable: true,
|
|
16
16
|
writable: true,
|
|
17
17
|
value: t
|
|
18
18
|
}) : n[e] = t;
|
|
19
19
|
var T = (n, e) => {
|
|
20
|
-
for (var t in e || (e = {}))
|
|
21
|
-
if (J) for (var t of J(e))
|
|
20
|
+
for (var t in e || (e = {})) Ie.call(e, t) && z(n, t, e[t]);
|
|
21
|
+
if (J) for (var t of J(e)) Ae.call(e, t) && z(n, t, e[t]);
|
|
22
22
|
return n;
|
|
23
23
|
};
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var C = (n, e) => Re(n, be(e));
|
|
25
|
+
var Ce = (n, e) => {
|
|
26
26
|
for (var t in e) M(n, t, {
|
|
27
27
|
get: e[t],
|
|
28
28
|
enumerable: true
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
var
|
|
32
|
-
for (var o = r > 1 ? void 0 : r ?
|
|
31
|
+
var N = (n, e, t, r) => {
|
|
32
|
+
for (var o = r > 1 ? void 0 : r ? ve(e, t) : e, i = n.length - 1, a; i >= 0; i--) (a = n[i]) && (o = (r ? a(e, t, o) : a(o)) || o);
|
|
33
33
|
return r && o && M(e, t, o), o;
|
|
34
34
|
};
|
|
35
|
-
var
|
|
35
|
+
var w = (n, e, t) => new Promise((r, o) => {
|
|
36
36
|
var i = s => {
|
|
37
37
|
try {
|
|
38
38
|
l(t.next(s));
|
|
@@ -76,7 +76,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
76
76
|
if (this._eventListeners[t.type]) for (let r of this._eventListeners[t.type]) r.call(this, t);
|
|
77
77
|
}, window.AbortController = n, window.AbortSignal = e;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function B(n) {
|
|
80
80
|
return new Promise(e => {
|
|
81
81
|
setTimeout(() => {
|
|
82
82
|
e();
|
|
@@ -86,16 +86,16 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
86
86
|
function U(n) {
|
|
87
87
|
return typeof n == "string";
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function Ne(n) {
|
|
90
90
|
return typeof n == "object" && n !== null && !Array.isArray(n) && !(n instanceof RegExp) && !(n instanceof Date);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function we(n) {
|
|
93
93
|
return typeof n == "undefined";
|
|
94
94
|
}
|
|
95
95
|
function D(n) {
|
|
96
|
-
return
|
|
96
|
+
return we(n) || n === null;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function V(n) {
|
|
99
99
|
return typeof n == "function";
|
|
100
100
|
}
|
|
101
101
|
function O(n) {
|
|
@@ -109,7 +109,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
109
109
|
};
|
|
110
110
|
return r.prototype = e.prototype, r;
|
|
111
111
|
}
|
|
112
|
-
var
|
|
112
|
+
var Oe = (s => (s[s.DEVELOPER_FILE_NOT_FOUND = 0] = "DEVELOPER_FILE_NOT_FOUND", s[s.INTERNAL_IOS_CAN_NOT_FOUND_PKG = 1] = "INTERNAL_IOS_CAN_NOT_FOUND_PKG", s[s.USER_IOS_LOAD_TIMEOUT = 2] = "USER_IOS_LOAD_TIMEOUT", s[s.INTERNAL_IOS_PKG_LOAD_ERROR = 3] = "INTERNAL_IOS_PKG_LOAD_ERROR", s[s.INTERNAL_IOS_PKG_PARSE_FAIL = 4] = "INTERNAL_IOS_PKG_PARSE_FAIL", s[s.USER_IOS_GET_EMPTY_DATA = 5] = "USER_IOS_GET_EMPTY_DATA", s[s.USER_ANDROID_GET_PKG_FAIL = 6] = "USER_ANDROID_GET_PKG_FAIL", s[s.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE = 7] = "DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE", s))(Oe || {});
|
|
113
113
|
var v = class extends Error {
|
|
114
114
|
constructor(e) {
|
|
115
115
|
if (typeof e == "string") {
|
|
@@ -125,21 +125,21 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
125
125
|
this.kind = "INTERNAL_ERROR";
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
var
|
|
128
|
+
var ne = class extends u {
|
|
129
129
|
constructor() {
|
|
130
130
|
super(...arguments);
|
|
131
131
|
this.name = "INTERNAL_JS_MODULE_FETCH_ERROR";
|
|
132
132
|
this.priority = "P0";
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
var
|
|
135
|
+
var te = class extends u {
|
|
136
136
|
constructor() {
|
|
137
137
|
super(...arguments);
|
|
138
138
|
this.name = "INTERNAL_JS_MODULE_EVAL_ERROR";
|
|
139
139
|
this.priority = "P0";
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
var
|
|
142
|
+
var me = class extends v {
|
|
143
143
|
constructor(t, r, o, i, a) {
|
|
144
144
|
super(t);
|
|
145
145
|
this.message = t;
|
|
@@ -164,7 +164,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
164
164
|
((o = (r = globalThis.VConsole) == null ? void 0 : r[n]) != null ? o : globalThis.console[n])(...arguments);
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
var
|
|
167
|
+
var fe = {
|
|
168
168
|
log: b("log"),
|
|
169
169
|
warn: b("warn"),
|
|
170
170
|
info: b("info"),
|
|
@@ -172,17 +172,20 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
172
172
|
debug: b("debug")
|
|
173
173
|
};
|
|
174
174
|
Object.assign(globalThis, {
|
|
175
|
-
logger:
|
|
175
|
+
logger: fe
|
|
176
176
|
});
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
globalThis[
|
|
180
|
-
var
|
|
177
|
+
var F = Symbol.for("Jolibox.canIUseMap");
|
|
178
|
+
var Le = {};
|
|
179
|
+
globalThis[F] || (globalThis[F] = Le);
|
|
180
|
+
var Jn = {
|
|
181
181
|
get config() {
|
|
182
|
-
return globalThis[
|
|
182
|
+
return globalThis[F];
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
|
|
185
|
+
var j = Symbol.for("Jolibox.canIUseMap.native");
|
|
186
|
+
var Se = {};
|
|
187
|
+
globalThis[j] || (globalThis[j] = Se);
|
|
188
|
+
function Qn(n, e, t) {
|
|
186
189
|
let r = 0;
|
|
187
190
|
if (n !== e) {
|
|
188
191
|
let o = n.split("."),
|
|
@@ -216,12 +219,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
216
219
|
return false;
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
|
-
var
|
|
220
|
-
var
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
222
|
+
var ke = (r => (r[r.System = 1e3] = "System", r[r.ErrorTrace = 1001] = "ErrorTrace", r[r.UserDefined = 1002] = "UserDefined", r))(ke || {});
|
|
223
|
+
var Me = (i => (i.MiniGame = "mini-game", i.MiniDrama = "mini-drama", i.App = "app", i.WebSDK = "web-sdk", i.AppSDK = "app-sdk", i))(Me || {});
|
|
224
|
+
var Ue = (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))(Ue || {});
|
|
225
|
+
var ge = ["name", "params"];
|
|
226
|
+
var De = ["name", "type", "location", "target", "extra", "timestamp", "userId"];
|
|
227
|
+
var Ve = ["platform", "os", "appVersion", "appId", "model", "brand", "uuid", "jsSdkVersion", "extra"];
|
|
225
228
|
function L(n, e) {
|
|
226
229
|
return e.map(t => {
|
|
227
230
|
if (t === "params" && n[t]) {
|
|
@@ -231,24 +234,24 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
231
234
|
return n[t];
|
|
232
235
|
});
|
|
233
236
|
}
|
|
234
|
-
function
|
|
235
|
-
let e = n.location ? L(n.location,
|
|
236
|
-
t = n.target ? L(n.target,
|
|
237
|
-
return L(
|
|
237
|
+
function Fe(n) {
|
|
238
|
+
let e = n.location ? L(n.location, ge) : null,
|
|
239
|
+
t = n.target ? L(n.target, ge) : null;
|
|
240
|
+
return L(C(T({}, n), {
|
|
238
241
|
location: e,
|
|
239
242
|
target: t
|
|
240
|
-
}),
|
|
243
|
+
}), De);
|
|
241
244
|
}
|
|
242
|
-
function
|
|
243
|
-
let e = n.events.map(r =>
|
|
244
|
-
t = L(n.device,
|
|
245
|
+
function Xn(n) {
|
|
246
|
+
let e = n.events.map(r => Fe(r)),
|
|
247
|
+
t = L(n.device, Ve);
|
|
245
248
|
return [n.protocolVersion, e, t, n.project];
|
|
246
249
|
}
|
|
247
|
-
var
|
|
250
|
+
var ye = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, n => {
|
|
248
251
|
let e = Math.random() * 16 | 0;
|
|
249
252
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
250
253
|
});
|
|
251
|
-
function
|
|
254
|
+
function Ee() {
|
|
252
255
|
try {
|
|
253
256
|
if (window.__joliboxLocalStorage__) return window.__joliboxLocalStorage__;
|
|
254
257
|
let n = Object.getOwnPropertyDescriptor(window, "localStorage");
|
|
@@ -268,8 +271,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
268
271
|
return console.warn("Failed to get original localStorage, fallback to default implementation", n), localStorage;
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
|
-
|
|
272
|
-
var
|
|
274
|
+
Ee();
|
|
275
|
+
var je = () => !!(navigator.userAgent || "").includes("JoliboxPlatformSDK");
|
|
273
276
|
var S = {
|
|
274
277
|
isiOS: navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPod") || navigator.userAgent.includes("iPad") || navigator.userAgent.includes("iPhone OS"),
|
|
275
278
|
iosVersion: () => {
|
|
@@ -281,40 +284,40 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
281
284
|
isFacebook: navigator.userAgent.includes("FB_IAB"),
|
|
282
285
|
isPC: !navigator.userAgent.includes("iPhone") && !navigator.userAgent.includes("Android")
|
|
283
286
|
};
|
|
284
|
-
var
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
var
|
|
287
|
+
var He = () => S.isiOS ? "iOS" : S.isAndroid ? "Android" : S.isMac ? "Mac" : S.isFacebook ? "Facebook" : "PC";
|
|
288
|
+
var Ke = "device_id";
|
|
289
|
+
var Ge = "advertising_id";
|
|
290
|
+
var Te = n => (window.__joliboxLocalStorage__.getItem(n) || window.__joliboxLocalStorage__.setItem(n, ye()), window.__joliboxLocalStorage__.getItem(n));
|
|
291
|
+
var Je = () => {
|
|
289
292
|
let e = new URLSearchParams(window.location.search).get("deviceId");
|
|
290
|
-
return e ||
|
|
293
|
+
return e || Te(Ke);
|
|
291
294
|
};
|
|
292
|
-
var
|
|
295
|
+
var ze = () => {
|
|
293
296
|
let e = new URLSearchParams(window.location.search).get("advertisingId");
|
|
294
|
-
return e ||
|
|
297
|
+
return e || Te(Ge);
|
|
295
298
|
};
|
|
296
|
-
var
|
|
297
|
-
var
|
|
299
|
+
var $e = n => n.charAt(0).toUpperCase() + n.slice(1);
|
|
300
|
+
var Be = () => {
|
|
298
301
|
var e;
|
|
299
302
|
let n = new URLSearchParams(window.location.search);
|
|
300
|
-
return
|
|
303
|
+
return $e((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
|
|
301
304
|
};
|
|
302
|
-
var
|
|
303
|
-
if (
|
|
305
|
+
var lt = n => {
|
|
306
|
+
if (je()) return window.navigator.userAgent;
|
|
304
307
|
let e = "JoliboxWebSDK",
|
|
305
|
-
t =
|
|
308
|
+
t = He(),
|
|
306
309
|
r = navigator.language,
|
|
307
|
-
o =
|
|
308
|
-
i =
|
|
309
|
-
return `${e} (${
|
|
310
|
+
o = Je(),
|
|
311
|
+
i = ze();
|
|
312
|
+
return `${e} (${Be()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
|
|
310
313
|
};
|
|
311
|
-
var
|
|
314
|
+
var x = class x2 {
|
|
312
315
|
constructor(e) {
|
|
313
|
-
this.element = e, this.next =
|
|
316
|
+
this.element = e, this.next = x2.Undefined, this.prev = x2.Undefined;
|
|
314
317
|
}
|
|
315
318
|
};
|
|
316
|
-
|
|
317
|
-
var c =
|
|
319
|
+
x.Undefined = new x(void 0);
|
|
320
|
+
var c = x;
|
|
318
321
|
var k = class {
|
|
319
322
|
constructor() {
|
|
320
323
|
this._first = c.Undefined;
|
|
@@ -380,11 +383,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
380
383
|
for (; e !== c.Undefined;) yield e.element, e = e.next;
|
|
381
384
|
}
|
|
382
385
|
};
|
|
383
|
-
var
|
|
386
|
+
var We = 0;
|
|
384
387
|
var y = class {
|
|
385
388
|
constructor(e) {
|
|
386
389
|
this.value = e;
|
|
387
|
-
this.id =
|
|
390
|
+
this.id = We++;
|
|
388
391
|
}
|
|
389
392
|
};
|
|
390
393
|
var p = class {
|
|
@@ -406,11 +409,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
406
409
|
r && (t = t.bind(r));
|
|
407
410
|
let o = new y(t);
|
|
408
411
|
return this._listeners ? this._listeners instanceof y ? this._listeners = [this._listeners, o] : this._listeners.push(o) : ((a = (i = this.options) == null ? void 0 : i.onWillAddFirstListener) == null || a.call(i, this), this._listeners = o, (s = (l = this.options) == null ? void 0 : l.onDidFirstListener) == null || s.call(l, this)), (d = (m = this.options) == null ? void 0 : m.onDidAddListener) == null || d.call(m, this), this._size++, () => {
|
|
409
|
-
var E, R, A,
|
|
412
|
+
var E, R, A, K;
|
|
410
413
|
if (!this._disposed) {
|
|
411
414
|
if (this._listeners instanceof y) this._listeners.id === o.id && (this._listeners = void 0, this._size = 0, (R = (E = this.options) == null ? void 0 : E.onDidRemoveLastListener) == null || R.call(E));else if (this._listeners) {
|
|
412
|
-
let
|
|
413
|
-
|
|
415
|
+
let G = this._listeners.indexOf(o);
|
|
416
|
+
G >= 0 && (this._listeners.splice(G, 1), this._size--, this._size === 0 && ((K = (A = this.options) == null ? void 0 : A.onDidRemoveLastListener) == null || K.call(A)));
|
|
414
417
|
}
|
|
415
418
|
}
|
|
416
419
|
};
|
|
@@ -484,20 +487,20 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
484
487
|
this.on(e, r, false);
|
|
485
488
|
}
|
|
486
489
|
};
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
None: () =>
|
|
490
|
-
filter: () =>
|
|
491
|
-
once: () =>
|
|
492
|
-
toPromise: () =>
|
|
490
|
+
var _ = {};
|
|
491
|
+
Ce(_, {
|
|
492
|
+
None: () => Qe,
|
|
493
|
+
filter: () => qe,
|
|
494
|
+
once: () => xe,
|
|
495
|
+
toPromise: () => Ye
|
|
493
496
|
});
|
|
494
|
-
var
|
|
497
|
+
var Qe = () => (console.log("[Jolibox SDK] None Event"), () => {
|
|
495
498
|
console.log("[Jolibox SDK] None Event dispose");
|
|
496
499
|
});
|
|
497
|
-
function
|
|
498
|
-
return new Promise(e =>
|
|
500
|
+
function Ye(n) {
|
|
501
|
+
return new Promise(e => xe(n)(e));
|
|
499
502
|
}
|
|
500
|
-
function
|
|
503
|
+
function xe(n) {
|
|
501
504
|
return function (e) {
|
|
502
505
|
let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
503
506
|
let r = false;
|
|
@@ -506,7 +509,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
506
509
|
}, null);
|
|
507
510
|
};
|
|
508
511
|
}
|
|
509
|
-
function
|
|
512
|
+
function qe(n, e) {
|
|
510
513
|
return (r => {
|
|
511
514
|
let o,
|
|
512
515
|
i = {
|
|
@@ -521,25 +524,25 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
521
524
|
return n(i => e(i) && r.call(o, i), null);
|
|
522
525
|
});
|
|
523
526
|
}
|
|
524
|
-
var
|
|
525
|
-
var
|
|
527
|
+
var H = Symbol.for("Jolibox.hostEmitter");
|
|
528
|
+
var Xe = () => {
|
|
526
529
|
let n = new I();
|
|
527
|
-
return globalThis[
|
|
530
|
+
return globalThis[H] || (globalThis[H] = {
|
|
528
531
|
on: n.on.bind(n),
|
|
529
532
|
off: n.off.bind(n),
|
|
530
533
|
emit: n.emit.bind(n),
|
|
531
534
|
once: n.once.bind(n)
|
|
532
|
-
}), globalThis[
|
|
535
|
+
}), globalThis[H];
|
|
533
536
|
};
|
|
534
|
-
var
|
|
537
|
+
var Vt = Xe();
|
|
535
538
|
function _e(n, e) {
|
|
536
539
|
let t = Math.min(n.length, e.length);
|
|
537
|
-
for (let r = 0; r < t; r++)
|
|
540
|
+
for (let r = 0; r < t; r++) Ze(n[r], e[r]);
|
|
538
541
|
}
|
|
539
|
-
function
|
|
542
|
+
function Ze(n, e) {
|
|
540
543
|
if (U(e)) {
|
|
541
544
|
if (typeof n !== e) throw new Error(`argument does not match constraint: typeof ${e}`);
|
|
542
|
-
} else if (
|
|
545
|
+
} else if (V(e)) {
|
|
543
546
|
try {
|
|
544
547
|
if (n instanceof e) return;
|
|
545
548
|
} catch (t) {}
|
|
@@ -584,7 +587,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
584
587
|
return e;
|
|
585
588
|
}
|
|
586
589
|
};
|
|
587
|
-
g =
|
|
590
|
+
g = N([O], g);
|
|
588
591
|
var h = class {
|
|
589
592
|
constructor() {
|
|
590
593
|
this._onWillExecuteCommand = new p();
|
|
@@ -595,14 +598,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
595
598
|
this._starActivation = null;
|
|
596
599
|
}
|
|
597
600
|
_activateStar() {
|
|
598
|
-
return this._starActivation || (this._starActivation =
|
|
601
|
+
return this._starActivation || (this._starActivation = B(3e4)), this._starActivation;
|
|
599
602
|
}
|
|
600
603
|
executeCommand(e) {
|
|
601
604
|
for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
602
605
|
t[_key4 - 1] = arguments[_key4];
|
|
603
606
|
}
|
|
604
|
-
return
|
|
605
|
-
return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(),
|
|
607
|
+
return w(this, null, function* () {
|
|
608
|
+
return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(), _.toPromise(_.filter(this.registry.onDidRegisterCommand, o => o === e))])]), this._tryExecuteCommand(e, t));
|
|
606
609
|
});
|
|
607
610
|
}
|
|
608
611
|
executeCommandThowErr(e) {
|
|
@@ -650,16 +653,16 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
650
653
|
}
|
|
651
654
|
}
|
|
652
655
|
};
|
|
653
|
-
h =
|
|
654
|
-
var
|
|
655
|
-
function
|
|
656
|
-
return typeof globalThis != "undefined" ? globalThis[
|
|
656
|
+
h = N([O], h);
|
|
657
|
+
var he = Symbol.for("Jolibox.commands");
|
|
658
|
+
function en() {
|
|
659
|
+
return typeof globalThis != "undefined" ? globalThis[he] : void 0;
|
|
657
660
|
}
|
|
658
|
-
function
|
|
659
|
-
typeof globalThis != "undefined" && (globalThis[
|
|
661
|
+
function nn(n) {
|
|
662
|
+
typeof globalThis != "undefined" && (globalThis[he] = n);
|
|
660
663
|
}
|
|
661
|
-
function
|
|
662
|
-
let n =
|
|
664
|
+
function pr() {
|
|
665
|
+
let n = en();
|
|
663
666
|
if (n) return n;
|
|
664
667
|
let e = new g(),
|
|
665
668
|
t = new h(),
|
|
@@ -684,7 +687,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
684
687
|
return t.executeCommandThowErr(o, ...i);
|
|
685
688
|
}
|
|
686
689
|
};
|
|
687
|
-
return
|
|
690
|
+
return nn(r), r;
|
|
688
691
|
}
|
|
689
692
|
|
|
690
693
|
// src/utils/env.ts
|
|
@@ -751,7 +754,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
751
754
|
try {
|
|
752
755
|
const reporterHost = API_BASE_URL;
|
|
753
756
|
const url = `${reporterHost}/report`;
|
|
754
|
-
const xua =
|
|
757
|
+
const xua = lt("__JOLIBOX_LOCAL_SDK_VERSION__");
|
|
755
758
|
const joliSource = JOLI_SOURCE;
|
|
756
759
|
const headers = {
|
|
757
760
|
"Content-Type": "application/json"
|
|
@@ -774,7 +777,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
774
777
|
try {
|
|
775
778
|
const errEvent = {
|
|
776
779
|
name: "globalJsError",
|
|
777
|
-
type:
|
|
780
|
+
type: ke.ErrorTrace,
|
|
778
781
|
location: getLocation(),
|
|
779
782
|
target: null,
|
|
780
783
|
extra: errorData,
|
|
@@ -787,9 +790,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
787
790
|
protocolVersion: "1.0.0",
|
|
788
791
|
events,
|
|
789
792
|
device,
|
|
790
|
-
project:
|
|
793
|
+
project: Me.WebSDK
|
|
791
794
|
};
|
|
792
|
-
const serializedEventPackage =
|
|
795
|
+
const serializedEventPackage = Xn(eventPackage);
|
|
793
796
|
await postToReporter(serializedEventPackage);
|
|
794
797
|
} catch (error) {
|
|
795
798
|
console.error("Failed to track error:", error);
|
|
@@ -797,7 +800,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
797
800
|
}
|
|
798
801
|
|
|
799
802
|
// src/events.ts
|
|
800
|
-
document.addEventListener("DOMContentLoaded", () =>
|
|
803
|
+
document.addEventListener("DOMContentLoaded", () => Vt.emit("onDocumentReady", timeline.startTime));
|
|
801
804
|
var timelineFactory = () => {
|
|
802
805
|
let _beginLoad = 0;
|
|
803
806
|
return {
|
|
@@ -810,7 +813,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
810
813
|
};
|
|
811
814
|
};
|
|
812
815
|
var timeline = timelineFactory();
|
|
813
|
-
var commands =
|
|
816
|
+
var commands = pr();
|
|
814
817
|
var rejectHandler = event => {
|
|
815
818
|
let errorInfo;
|
|
816
819
|
if (event instanceof ErrorEvent) {
|
|
@@ -927,7 +930,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
927
930
|
};
|
|
928
931
|
|
|
929
932
|
// src/utils/report.ts
|
|
930
|
-
var commands2 =
|
|
933
|
+
var commands2 = pr();
|
|
931
934
|
var track = (event, info) => {
|
|
932
935
|
commands2.executeCommand("ReportSDK.traceSystem", {
|
|
933
936
|
event,
|
|
@@ -943,7 +946,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
943
946
|
};
|
|
944
947
|
|
|
945
948
|
// src/loader/h5.ts
|
|
946
|
-
|
|
949
|
+
Ee();
|
|
947
950
|
var LOCAL_STORE_KEY = "jolibox-sdk-loadermeta";
|
|
948
951
|
var CURRENT_VERSION_STORE = JSON.parse(window.__joliboxLocalStorage__.getItem(LOCAL_STORE_KEY) ?? "{}");
|
|
949
952
|
var now = Date.now();
|
|
@@ -1019,7 +1022,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1019
1022
|
type: "fetch_from_cdn"
|
|
1020
1023
|
};
|
|
1021
1024
|
} catch (e) {
|
|
1022
|
-
const internalError = new
|
|
1025
|
+
const internalError = new ne(`Bootstrap module faile to fetch ${e}`);
|
|
1023
1026
|
trackError({
|
|
1024
1027
|
err: `${internalError}`
|
|
1025
1028
|
});
|
|
@@ -1073,7 +1076,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1073
1076
|
loadRemoteImplement();
|
|
1074
1077
|
fetchCurrentRemoteScript();
|
|
1075
1078
|
} catch (e) {
|
|
1076
|
-
const internalError = new
|
|
1079
|
+
const internalError = new te(`module evaluate error: ${e}`);
|
|
1077
1080
|
trackError({
|
|
1078
1081
|
err: `${internalError}`
|
|
1079
1082
|
});
|
|
@@ -1103,7 +1106,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1103
1106
|
URL.revokeObjectURL(blobUrl);
|
|
1104
1107
|
return module;
|
|
1105
1108
|
} catch (error) {
|
|
1106
|
-
reportError(new
|
|
1109
|
+
reportError(new te(`implement module evaluate error in native:${error} `));
|
|
1107
1110
|
}
|
|
1108
1111
|
};
|
|
1109
1112
|
evalJS(code);
|
|
@@ -1131,7 +1134,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1131
1134
|
});
|
|
1132
1135
|
} catch (e) {
|
|
1133
1136
|
console.error(`native load script error: ${e}`);
|
|
1134
|
-
reportError(new
|
|
1137
|
+
reportError(new te(`module load failed ${e}`));
|
|
1135
1138
|
}
|
|
1136
1139
|
};
|
|
1137
1140
|
};
|
|
@@ -1187,14 +1190,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1187
1190
|
loadImplement();
|
|
1188
1191
|
|
|
1189
1192
|
// src/api/get-system-info.ts
|
|
1190
|
-
var commands3 =
|
|
1193
|
+
var commands3 = pr();
|
|
1191
1194
|
function getSystemInfoSync() {
|
|
1192
1195
|
return commands3.excuteCommandSync("API.getSystemInfoSync");
|
|
1193
1196
|
}
|
|
1194
1197
|
|
|
1195
1198
|
// src/utils/can-i-use.ts
|
|
1196
1199
|
function getCanIUseConfig(platform, key) {
|
|
1197
|
-
return
|
|
1200
|
+
return Jn.config[platform]?.[key];
|
|
1198
1201
|
}
|
|
1199
1202
|
function get(obj, path, defaultValue) {
|
|
1200
1203
|
const pathArray = Array.isArray(path) ? path : path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
@@ -1213,11 +1216,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1213
1216
|
var __VERSION__ = "__JOLIBOX_LOCAL_SDK_VERSION__";
|
|
1214
1217
|
function canIUse(schema) {
|
|
1215
1218
|
const [name, ...rest] = schema.split(":");
|
|
1216
|
-
const api = getCanIUseConfig(
|
|
1219
|
+
const api = getCanIUseConfig(je() ? "native" : "h5", name);
|
|
1217
1220
|
if (!api) return false;
|
|
1218
1221
|
const apiVersion = api["version"];
|
|
1219
1222
|
if (typeof apiVersion !== "string") return false;
|
|
1220
|
-
if (
|
|
1223
|
+
if (Qn(__VERSION__, apiVersion, "<")) return false;
|
|
1221
1224
|
if (rest.length === 0) return true;
|
|
1222
1225
|
return checkRest(api, rest) || checkRest(api["properties"], rest);
|
|
1223
1226
|
}
|
|
@@ -1225,13 +1228,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1225
1228
|
if (!info) return false;
|
|
1226
1229
|
const v2 = get(info, paths);
|
|
1227
1230
|
if (!v2) return false;
|
|
1228
|
-
if (
|
|
1229
|
-
if (U(v2)) return
|
|
1231
|
+
if (Ne(v2)) return true;
|
|
1232
|
+
if (U(v2)) return Qn(__VERSION__, v2, ">=");
|
|
1230
1233
|
return false;
|
|
1231
1234
|
}
|
|
1232
1235
|
|
|
1233
1236
|
// src/api/login.ts
|
|
1234
|
-
var commands4 =
|
|
1237
|
+
var commands4 = pr();
|
|
1235
1238
|
async function login() {
|
|
1236
1239
|
if (!canIUse("login")) {
|
|
1237
1240
|
return {
|
|
@@ -1252,7 +1255,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1252
1255
|
}
|
|
1253
1256
|
|
|
1254
1257
|
// src/api/request.ts
|
|
1255
|
-
var commands5 =
|
|
1258
|
+
var commands5 = pr();
|
|
1256
1259
|
async function request(params) {
|
|
1257
1260
|
if (!canIUse("request")) {
|
|
1258
1261
|
return {
|
|
@@ -1267,24 +1270,24 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1267
1270
|
var supportedEvents = ["onI18nChanged", "onBackPress"];
|
|
1268
1271
|
var onCustomEvent = (event, callback) => {
|
|
1269
1272
|
if (!supportedEvents.includes(event)) {
|
|
1270
|
-
reportError(new
|
|
1273
|
+
reportError(new me(`[onCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1271
1274
|
return;
|
|
1272
1275
|
}
|
|
1273
|
-
|
|
1276
|
+
Vt.on(event, callback);
|
|
1274
1277
|
};
|
|
1275
1278
|
var offCustomEvent = (event, callback) => {
|
|
1276
1279
|
if (!supportedEvents.includes(event)) {
|
|
1277
|
-
reportError(new
|
|
1280
|
+
reportError(new me(`[offCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1278
1281
|
return;
|
|
1279
1282
|
}
|
|
1280
|
-
|
|
1283
|
+
Vt.off(event, callback);
|
|
1281
1284
|
};
|
|
1282
1285
|
var onceCustomEvent = (event, callback) => {
|
|
1283
1286
|
if (!supportedEvents.includes(event)) {
|
|
1284
|
-
reportError(new
|
|
1287
|
+
reportError(new me(`[onceCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1285
1288
|
return;
|
|
1286
1289
|
}
|
|
1287
|
-
|
|
1290
|
+
Vt.once(event, callback);
|
|
1288
1291
|
};
|
|
1289
1292
|
|
|
1290
1293
|
// src/sdks/runtime.ts
|
|
@@ -1319,7 +1322,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1319
1322
|
* @private
|
|
1320
1323
|
* Instance for executing commands. Intended for internal SDK use.
|
|
1321
1324
|
*/
|
|
1322
|
-
this.commands =
|
|
1325
|
+
this.commands = pr();
|
|
1323
1326
|
/**
|
|
1324
1327
|
* @private
|
|
1325
1328
|
* Event emitter instance for handling internal events. Intended for internal SDK use.
|
|
@@ -1623,7 +1626,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1623
1626
|
};
|
|
1624
1627
|
|
|
1625
1628
|
// src/sdks/router.ts
|
|
1626
|
-
var NavigateToNativePageTypeTypes = ["openHistory"];
|
|
1629
|
+
var NavigateToNativePageTypeTypes = ["openHistory", "openDiscover", "openGame", "openDrama", "openFeed", "openTopup"];
|
|
1627
1630
|
var RouterSDK = class extends BaseSDK {
|
|
1628
1631
|
/**
|
|
1629
1632
|
* @public
|
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.
|
|
4
|
+
"version": "1.1.31",
|
|
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.
|
|
11
|
-
"@jolibox/types": "1.1.
|
|
10
|
+
"@jolibox/common": "1.1.31",
|
|
11
|
+
"@jolibox/types": "1.1.31"
|
|
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.
|
|
3
|
+
> @jolibox/sdk@1.1.31 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.1.
|
|
7
|
+
> @jolibox/sdk@1.1.31 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.
|
|
11
|
+
> @jolibox/sdk@1.1.31 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.
|
|
15
|
+
> @jolibox/sdk@1.1.31 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|
package/src/sdks/router.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { Router, StandardResponse, ResponseType, NavigateToNativePageType } from '@jolibox/types';
|
|
3
3
|
|
|
4
|
-
const NavigateToNativePageTypeTypes = [
|
|
4
|
+
const NavigateToNativePageTypeTypes = [
|
|
5
|
+
'openHistory',
|
|
6
|
+
'openDiscover',
|
|
7
|
+
'openGame',
|
|
8
|
+
'openDrama',
|
|
9
|
+
'openFeed',
|
|
10
|
+
'openTopup'
|
|
11
|
+
];
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
14
|
* @private
|