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