@jolibox/implement 1.1.4-beta.10 → 1.1.4-beta.12
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 +14 -15
- package/dist/common/http/uuid.d.ts +2 -2
- package/dist/common/http/xua.d.ts +0 -15
- package/dist/common/report/base-tracker.d.ts +1 -1
- package/dist/common/report/types.d.ts +1 -54
- package/dist/h5/report/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.native.js +3 -3
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/common/context/index.ts +3 -2
- package/src/common/http/uuid.ts +2 -10
- package/src/common/http/xua.ts +2 -69
- package/src/common/report/base-tracker.ts +1 -45
- package/src/common/report/types.ts +1 -63
- package/src/h5/http/index.ts +5 -1
- package/src/h5/http/utils/__tests__/xua.test.ts +1 -1
- package/src/h5/http/utils/session.ts +1 -1
- package/src/h5/report/errors/index.ts +1 -1
- package/src/h5/report/event-tracker.ts +1 -1
- package/src/h5/report/index.ts +3 -2
- package/src/native/bootstrap/index.ts +0 -1
- package/src/native/report/index.ts +2 -2
- package/dist/h5/http/utils/__tests__/uuid.test.d.ts +0 -1
- package/src/h5/http/utils/__tests__/uuid.test.ts +0 -16
package/dist/index.native.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var ln=Object.create;var Mt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var d=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!fn.call(e,o)&&o!==r&&Mt(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e};var vn=(e,t,r)=>(r=e!=null?ln(dn(e)):{},hn(t||!e||!e.__esModule?Mt(r,"default",{value:e,enumerable:!0}):r,e));function yn(e){return!!e?.__nativeBuffers__}function le(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!yn(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=bn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Lt(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:kn(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var bn,kn,Ze=d(()=>{"use strict";bn=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};kn=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function _n(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vt(e){return typeof e=="object"&&Array.isArray(e)}function Rn(e){return typeof e>"u"}function Sn(e){return Rn(e)||e===null}function $t(e){return typeof e=="function"}function Kt(e){return N(e)&&$t(e.then)}function Ht(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function Bt(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],l=s[i],u=r(a,l,i,o,s);u!==void 0?o[i]=u:Ft(l)&&Ft(a)?o[i]=n({...a},l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function Ft(e){return e&&typeof e=="object"&&e.constructor===Object}function qt(e,t){if(Array.isArray(e))return e.concat(t)}function de(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),m=function(...p){o=p,s=this;let f=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!f&&u()},t),f)return u()};return m.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,u()},m}function wn(e,t){return(...r)=>t(e,...r)}function ke(e){return t=>wn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new st(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Pn(e){return new Promise(t=>Zt(e)(t))}function Zt(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Dn(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Mn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ln(e[n],t[n])}function Ln(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if($t(t)){try{if(e instanceof t)return}catch{}if(!Sn(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")}}function S(){if(globalThis[tt])return globalThis[tt];let e=new ye,t=new nt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[tt]=r,r}var jt,Tn,En,Jt,W,xn,ot,ee,In,st,Gt,zt,Wt,Qt,Yt,fe,be,it,R,Xt,An,at,b,Cn,Nn,he,pe,Q,rt,On,et,Un,K,ye,nt,tt,h=d(()=>{"use strict";jt=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,En=(e,t)=>{for(var r in t)jt(e,r,{get:t[r],enumerable:!0})},Jt=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tn(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&jt(t,r,o),o};W=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};xn=(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))(xn||{}),ot=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},ee=class extends ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},In=class extends ot{constructor(){super(...arguments),this.kind="USER_ERROR"}},st=class extends In{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Gt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},zt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Wt=class extends ee{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Qt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Yt=class extends ee{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends ot{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},be=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},it=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};R={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:R});Xt=Symbol.for("Jolibox.canIUseMap"),An={};globalThis[Xt]=An;at={get config(){return globalThis[Xt]}},b=class ve{static{this.Undefined=new ve(void 0)}constructor(t){this.element=t,this.next=ve.Undefined,this.prev=ve.Undefined}},Cn=class{constructor(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===b.Undefined}clear(){let e=this._first;for(;e!==b.Undefined;){let t=e.next;e.prev=b.Undefined,e.next=b.Undefined,e=t}this._first=b.Undefined,this._last=b.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new b(e);if(this._first===b.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==b.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==b.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==b.Undefined&&e.next!==b.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===b.Undefined&&e.next===b.Undefined?(this._first=b.Undefined,this._last=b.Undefined):e.next===b.Undefined?(this._last=this._last.prev,this._last.next=b.Undefined):e.prev===b.Undefined&&(this._first=this._first.next,this._first.prev=b.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==b.Undefined;)yield e.element,e=e.next}},Nn=0,he=class{constructor(e){this.value=e,this.id=Nn++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof he&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let r=new he(e);this._listeners?this._listeners instanceof he?this._listeners=[this._listeners,r]:this._listeners.push(r):(this.options?.onWillAddFirstListener?.(this),this._listeners=r,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let r=this.options?.onListenerError||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(n){r(n)}}fire(e){this._listeners&&(this._listeners instanceof he?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Q=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new pe,n=s=>t(...s.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire({event:e,...o.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 Cn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rt={};En(rt,{None:()=>On,filter:()=>Dn,once:()=>Zt,toPromise:()=>Pn});On=()=>{console.log("[Jolibox SDK] None Event")};et=Symbol.for("Jolibox.hostEmitter"),Un=()=>{let e=new Q;return globalThis[et]||(globalThis[et]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[et]},K=Un();ye=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Mn(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};ye=Jt([Ht],ye);nt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new ye,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=_n(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),rt.toPromise(rt.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}}};nt=Jt([Ht],nt);tt=Symbol.for("Jolibox.commands")});function I(e,t={}){ct.emit("ERROR_REPORT",{error:e,options:t})}var ct,te,U=d(()=>{"use strict";h();h();ct=new Q,te=new Q;I.debounce=de(I,50,{leading:!0})});function Te(e,t){return`[${e}]:${t}`}var re,ut,Y=d(()=>{"use strict";U();h();U();re=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),ut=e=>new st(e)});var er,tr,rr,nr=d(()=>{"use strict";er=[],tr=[],rr=["env","createRequestTask","login"]});function sr(e,t){or||(lt=new ne({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),mt=new ne({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),pt=new ne({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{lt.flush(),mt.flush(),pt.flush()}),or=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:l,errMsg:u=`${s}:fail no errMsg`,errNo:m=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:f,invokeCallback:v}=p,_=u.match(/\S:(\S+)\s?/)?.[1]??"fail";lt.report({status:_,method:n(s,i),errNo:`${m}`,errMsg:u,isForeground:l,duration:Date.now()-a}),a&&f&&v&&(mt.report({status:_,method:s,isForeground:l,duration:Number((f-a).toFixed(3))}),pt.report({status:_,method:s,isForeground:l,duration:Number((Date.now()-v).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Fn,ne,or,lt,mt,pt,dt=d(()=>{"use strict";h();Fn=e=>e==="pv"?e:"default",ne=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=Fn(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let l=i[a];n[l]||(n[l]={}),r(n[l],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let l=s.shift();if(!l&&N(a))throw new be(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let u=[];if(N(a))u.push(...Object.keys(a));else if(Z(a)){if(s.length>0)throw new be(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new be(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(m=>{o[m]||(o[m]={});let p=N(a)?a[m]:a;r(o[m],[...s],i,p)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},or=!1});function ar(e,t){let r=0,n=!0,o=new Map,s=sr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ft.forEach(async({method:u,args:m,resolve:p})=>{let f=await a(u,m);p(f)}),ft.length=0});let i=(u,m)=>{R.info("----resolveId",u,m);let p=o.get(Number(u));if(!p)return;let f=le(m);p(f),o.delete(Number(u))},a=(u,m)=>{let p=Date.now(),f=`${n}`;r+=1;let v=new W;if(o.set(r,v.resolve),!n&&tr.includes(u))return new Promise(C=>{ft.push({method:u,args:m,resolve:C})});let A={...{method:u,startTime:p,args:m,isForeground:f},invokeType:"js-bridge"},O=!jn&&er.includes(u),G=Lt(m,O),z=O?G:JSON.stringify(G),k;if(u.endsWith("Sync")||rr.includes(u)?k=e.call?.(u,G,r):typeof z=="string"?(console.log("-----params",u,r),k=e.invoke(u,z,r)):k=e.call?.(u,z,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=le(k)}catch(C){R.error(C)}return o.delete(r),k.errorCode&&(k.errorCode=Te(u,k.errorCode)),s({...A,...k}),k}return u.endsWith("Sync")&&o.delete(r),v.promise.then(C=>(C.errorCode&&(C.errorCode=Te(u,C.errorCode)),s({...A,...C}),C))};return{invokeNative:a,applyNative:(u,m)=>{let p=a(u,m);return Kt(p)?p.then(f=>ir(u,f)):ir(u,p)},invokeHandler:i}}function ir(e,t){if(!N(t)){R.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new Wt(r,n,o,s);return i}var ft,jn,cr=d(()=>{"use strict";Ze();h();Y();nr();dt();ft=[],jn=!1});function ur(e){let t=new Q,r=new ne({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,o,s){let i=le(o),a;if(i.__extra){a=i.params;let{type:l,startTime:u}=i.__extra;r.report({type:l,event:n,duration:Date.now()-u})}else a=i;t.emit(n,a,s)}}}var lr=d(()=>{"use strict";h();Ze();dt()});function gt(e){let{subscribeHandler:t,onNative:r,offNative:n}=ur(e),{invokeNative:o,invokeHandler:s,applyNative:i}=ar(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var mr=d(()=>{"use strict";cr();lr()});var pr=d(()=>{"use strict"});var dr=d(()=>{"use strict";mr();pr()});var X,M,fr,gr=d(()=>{"use strict";h();U();M={trigger(){},exit(){return!1},onReady(e){M.trigger=e},doExit(e){M.exit=e}},fr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)I(new zt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{M.trigger(),e.onDocumentReady.postMessage({path:o})};X={onDocumentReady:t,doExit:o=>{let s=M.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})},invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:fr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{M.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};X={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=M.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:fr};globalThis.joliboxJSCore={...n}}});function ht(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var vt=d(()=>{"use strict"});function yt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ie.publish=function(t,r){let n=ht(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,hr=d(()=>{"use strict";vt()});var Ee=d(()=>{"use strict";gr();hr();vt()});var yr,Jn,br,vr,P,w,J,ui,Vn,L=d(()=>{"use strict";dr();Ee();Y();h();Ee();yr=X;if(!yr)throw new Qt("No joliboxJScore is found, native bridge not found.");yt();Jn={...yr},br=gt(Jn),{invokeHandler:vr}=br,{applyNative:P,invokeNative:w,onNative:J,offNative:ui,subscribeHandler:Vn}=br;globalThis.joliboxJSBridge={callHandler:vr,invokeHandler:vr,subscribeHandler:Vn}});var bt,kr,Tr=d(()=>{"use strict";h();U();bt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch{return{}}},kr=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[o,s,i]=n;return{headerJson:bt(o),payloadJson:bt(s),signature:bt(i)}}else throw"joli_source is missing"}catch(t){return I(new Gt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Er,_r=d(()=>{"use strict";Er=()=>"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 _e,$n,Kn,Re,Hn,Bn,Rr,kt,qn,Gn,zn,Sr,Tt=d(()=>{"use strict";_r();_e={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")},$n=()=>_e.isiOS?"iOS":_e.isAndroid?"Android":_e.isMac?"Mac":_e.isFacebook?"Facebook":"PC",Kn="1.1.4-beta.10",Re=()=>Kn,Hn="device_id",Bn="advertising_id",Rr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Er()),localStorage.getItem(e)),kt=()=>Rr(Hn),qn=()=>Rr(Bn),Gn=e=>e.charAt(0).toUpperCase()+e.slice(1),zn=()=>{let e=new URLSearchParams(window.location.search);return Gn(e.get("utm_source")??"")||"JoliboxSDK"},Sr=()=>{let e="JoliboxWebSDK",t=$n(),r=navigator.language,n=kt(),o=qn(),s=Re();return`${e} (${zn()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${n} adid/${o} version/${s||""}`}});var Wn,Qn,F,Yn,y,H=d(()=>{"use strict";h();Tr();Tt();Wn={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:kt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Re()},schema:"",platform:"h5"},Qn=globalThis.joliboxJSCore?.env,F=Object.assign({},Qn?.()??Wn),Yn=()=>{let{payloadJson:e,headerJson:t}=kr(F.schema),r=`${F.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(F.schema.length?F.schema:window.location.search),o=n.get("appId")??n.get("gameId")??"",s=e.sessionId??n.get("sessionId")??r,i=!!(e.testAdsMode??n.get("testAdsMode")==="true"),a=e.joliboxEnv??n.get("joliboxEnv")??"production",l=a==="staging";return{get testMode(){return l},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return o??e.id},get mpVersion(){return t.ver??Re()},get platform(){return F.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??s??r},onEnvConfigChanged:u=>{Bt(F,u,qt)}}},y=Yn()});var Et,Ir,Xn,Zn,xr,eo,wr=d(()=>{"use strict";h();U();H();h();Et=!1,Ir=(e,t)=>e==null?!1:t in e,Xn=e=>Ir(e,"kind"),Zn=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},xr=(e,t={},r)=>{let n=e.priority??"P1",s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:Zn(e.name)},env:t.environment,isFromUser:r};r?te.emit("GLOBAL_USER_ERROR",e,s):te.emit("GLOBAL_ERROR",e,s)},eo=e=>Ir(e,"kind")&&e.kind==="USER_ERROR";ct.on("ERROR_REPORT",({error:e,options:t})=>{if(Et)return;Et=!0;let r=Xn(e)&&e.raw?e.raw:e;try{let n=eo(e);xr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new it(`${o}, origin error: ${r.message}`);R.error(s),xr(new it(s.message),{environment:t.environment},!1)}finally{Et=!1}})});var Ar=d(()=>{"use strict";wr();Y();h();L();te.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});te.on("GLOBAL_USER_ERROR",(e,t)=>{R.log("UserError",e,t)})});var _t=d(()=>{"use strict"});function Cr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?I(new Yt(JSON.stringify(i),"P0")):e("systemLog",i,s)};return r.debounce=de(r,500,{leading:!0}),r}function Nr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=de(t,500,{leading:!0}),t}var Or=d(()=>{"use strict";h();h();U()});function Pr(e,t){let r=Cr(e,t),n=Nr(r);return{track:r,trackPerformance:n}}var Dr=d(()=>{"use strict";Or()});var Ur=d(()=>{"use strict";H();h()});var Mr=d(()=>{"use strict";Dr();_t();Ur()});var Se,Lr=d(()=>{"use strict";Se=class{constructor(t,r){this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration:t??0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=performance.now(),n,o=!1,s=0,i=a=>{if(!o)return;let l=a-r;l>=this.interval&&(this.visible&&(s+=l,t(s)),r=a),n=requestAnimationFrame(i)};return{start(){o||(o=!0,r=performance.now(),n=requestAnimationFrame(i))},stop(){o=!1,n&&cancelAnimationFrame(n)}}}}});var Rt=d(()=>{"use strict"});function jr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,m={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:i};(i==="public"&&Fr<ro||i==="inner")&&(m.joli_request_number=Fr++,setTimeout(()=>{V("joliboxNetRequestResult",m)},500))}var Fr,ro,Jr=d(()=>{"use strict";Rt();oe();Fr=0,ro=10});function xe(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return J("onRequestTaskStateChange",l=>{if(typeof l.requestTaskId!="string")return;let u=n.get(l.requestTaskId);if(u)if(l.state==="success"){let{requestTaskId:m,state:p,...f}=l;u.resolve(f),n.delete(m)}else if(l.state==="fail"){let{requestTaskId:m,state:p,...f}=l;u.reject(f),n.delete(m)}else R.warn("onRequestTaskStateChange unknown event",l)}),K.on("onLoginComplete",({isLogin:l,token:u})=>{l&&u&&(i["X-JOLI-TOKEN"]=u)}),async(l,u={})=>{let m=Date.now(),p=no(l,{...u,baseUrl:o}),{method:f="GET",responseType:v="text",dataType:_="json",timeout:A,enableCache:O=!1,appendHostCookie:G=!0}=u,z=Object.assign({"content-type":"application/json"},i,u.header),k={url:p,method:f,header:z,enableCache:O,responseType:v,appendHostCookie:G};if(f=="POST"||f=="PUT"){let j=so(u.data,z["content-type"]);k.data=j}A&&Object.assign(k,{timeout:A});let{data:{requestTaskId:C}}=w(e,k);if(typeof C!="string")throw re({code:-1,msg:"requestTaskId is not a string"});let ue=(j,$)=>{jr("request",p,{state:j,startTime:m,endTime:Date.now(),params:k,response:$,requestId:C,requestFrom:s=="public"?"public":"inner"})},{resolve:Xe,reject:on,promise:sn}=new W;n.set(C,{resolve:Xe,reject:on});try{let j=await sn;ue("success",j);let{data:$}=j;return _==="json"&&typeof $=="string"&&($=oo($)),{url:p,timeout:A,method:f,response:{...j,data:$}}}catch(j){let $=j;if(N($)){let{errMsg:ge,prefetchDetail:an,isPrefetch:cn,errNo:un}=$;Z(ge)&&(ue("fail",{errMsg:ge,isPrefetch:cn,prefetchDetail:an}),I(re({code:-1,msg:ge},{errNo:un,errMsg:ge})))}throw j}}}function oo(e){try{return JSON.parse(e.trim())}catch{return e}}function so(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var no,St=d(()=>{"use strict";h();Jr();Rt();L();U();Y();no=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var se,xt=d(()=>{"use strict";Tt();St();H();se=xe("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":Sr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ie,Vr=d(()=>{"use strict";H();Lr();xt();L();Ie=class extends Se{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,o=[];o.push(se("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}async reportToNative(t){let{event:r,params:n}=t;await P("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var io,V,ao,$r,we,D,oe=d(()=>{"use strict";Ar();h();_t();Mr();H();Vr();L();io=(e,t,r)=>{let n=t,s={...N(n.extra)?n.extra:Z(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};w("trackAsync",{event:e,data:s,webviewId:r})},{track:V,trackPerformance:ao}=Pr(io,{type:"app-sdk",platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),$r=S();$r.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{ao(e,t)});$r.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{V(e,t)});we=new Q,D=new Ie(V,we)});function Hr(e){let t=at.config[e];return t||(t={},at.config[e]=t),(r,n)=>{if(t[r]){R.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Br=d(()=>{"use strict";h()});function It(e){qr=e}function Ce(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ce(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ce(e[r]),t),{})}function B(e){return typeof e=="number"}function wt(e){let t=At(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function At(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qr,T,Ne,Oe,Pe,De,ae,Ue,Me,Le,Fe,je,Je,Ve,$e,Ke,He,Be,qe,Ct=d(()=>{"use strict";qr=!1;T=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qr)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${wt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ce(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ce(this._default)}optional(){return this._optional=!0,this}};Ne=class extends T{validate(t){return this._optional&&t===void 0?!0:B(t)?B(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):B(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):B(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Oe=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Pe=class extends T{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(B(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(B(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},De=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends T{validate(t){return!0}},Ue=class extends T{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends T{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends T{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Fe=class extends T{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${wt(t)}`)}return!0}},je=class extends T{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(B(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(B(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(B(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},Je=class extends T{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(At(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let l=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(l===void 0&&s._optional)){if(l===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(l)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},Ve=class extends T{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(At(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},$e=class extends T{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:wt(this.value),actual:r}):!0}},Ke=class extends T{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
2
|
-
or `);this.errors.push(s)}return n}},He=class extends
|
|
3
|
-
`);throw e.errors.length=0,It(!1),new TypeError(n)}}var c,Ot=d(()=>{"use strict";Ct();Ct();c={object(e){return new Ve(e)},array(e){return new je(e)},tuple(...e){return new He(...e)},literal(e){return new $e(e)},or(...e){return new Ke(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Oe},string(){return new Pe},number(){return new Ne},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Be},enum(...e){return new Fe(...e)},typedarray(e){return new qe(e)}}});var Ge,Gr,zr=d(()=>{"use strict";h();U();Ot();Y();Ge=1,Gr=e=>{function t(n,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let l="SUCCESS",u=`${n}:ok`,m=0;try{if(o.paramsSchema)try{Nt(o.paramsSchema,s,"params")}catch(_){throw ut(`${n}:fail ${_.message}`)}let p=o.implement(...s),f=p,v=`${n}:ok`;if(p&&"code"in p){let{code:_,data:A,message:O}=p;l=_,f=A,v=O}return{code:l,message:v,data:f}}catch(p){let f=p;m=f.code??f.errNo??2e3,l="FAILURE";let v=f.message??f.errMsg??`${p}`;return u=`${n}:${l} ${v.replace(/^\S+:(fail|cancel)\s?/,"")}`,I(new fe(u,m)),{code:l,message:u}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:l})}}}function r(n,o){return async(...s)=>{let i=Vt(s)?s:[s],a=Date.now(),l={method:n,trace_id:Ge};Ge+=1;let u=`${n}:ok`,m="SUCCESS",p={code:m,message:u};try{if(o.paramsSchema)try{Nt(o.paramsSchema,i,"params")}catch(_){throw ut(_.message)}let v=await o.implement(...i);if(v&&"code"in v){let{code:_,data:A,message:O}=v;m=_,u=O,v=A}return Object.assign(p,{code:m,message:u,data:v}),p}catch(f){let v=f,_=v.code??v.errNo??2e3;m="FAILURE";let A=v.message??v.errMsg??`${f}`,O=`${n}:${m} ${A.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:m,message:O}),I(new fe(O,_)),p}finally{let f=Date.now()-a;e("apiInvoked",{...l,duration:f,status:m})}}}return{createAPI:r,createSyncAPI:t}}});var E,x,g,q=d(()=>{"use strict";Br();oe();zr();Ot();({createAPI:E,createSyncAPI:x}=Gr(V)),g=Hr("native")});var Yr=gn(Qr=>{"use strict";h();q();U();L();oe();var ho="exitGame",vo="onReady",yo="onJoliboxShow",bo="onJoliboxHide",ze=S(),We=ke(I),ko=E(ho,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(Qr),await P("exitAppAsync")}}),To=x(yo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Eo=x(bo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),_o=x(vo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",ko);ze.registerCommand("LifecycleSDK.onReady",_o);ze.registerCommand("LifecycleSDK.onJoliboxShow",To);ze.registerCommand("LifecycleSDK.onJoliboxHide",Eo);g("lifeCycle.exit",{version:"1.0.0"});g("lifeCycle.onReady",{version:"1.0.0"});g("lifeCycle.onJoliboxShow",{version:"1.0.0"});g("lifeCycle.onJoliboxHide",{version:"1.0.0"})});L();Ee();H();h();oe();M.onReady(()=>{});M.doExit(()=>(V("onBeforeExit",{timestamp:Date.now()}),D.close(Date.now()-Ae),!1));function co(){K.on("onDocumentReady",()=>{X?.onDocumentReady(window.location.href),V("onDocumentReady",{start_timestamp:Ae,timestamp:Date.now()})})}function uo(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),V("joliboxServiceReady",{start_timestamp:Ae,timestamp:Date.now()}),D.start(t)}),J("onBeforeExit",({uuid:e})=>{X?.doExit(e)})}var Ae;function Kr(){Ae=Date.now(),uo(),co()}h();q();L();var Wr=S(),mo="env",po="getSystemInfoSync",fo=x(po,{implement:()=>{let e=w("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),go=x(mo,{implement:()=>w("envSync")?.data??void 0});Wr.registerCommand("API.getSystemInfoSync",fo);Wr.registerCommand("API.env",go);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"});var Kc=vn(Yr());Y();St();q();h();function Xr(e){let t={};if(!N(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Zr(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function en(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function tn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!N(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}h();U();var Ro=15,So=xe("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Pt=0,Dt=[],rn=ke(I),xo=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Io=e=>{let t=new W,r=()=>{};return E("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(o){let s=async()=>{let i=rn(o.fail);try{if(Pt+=1,t.state!=="pending")return;let{data:a,dataType:l,responseType:u,enableCache:m,appendHostCookie:p}=o,f=Xr(o.header),v=Zr(o.method),_=en(o.timeout),A=tn(o.url,v,a),O=rn(o.success),G=Object.assign({},o,{method:v,header:f,data:v==="GET"||v==="HEAD"?void 0:a,enableCache:m,query:o.query??{},dataType:l,responseType:u,appendHostCookie:p});_&&(G.timeout=_);let z=So(A,G);{let{response:k}=await z,{code:C,data:ue,message:Xe}=k;t.resolve({code:C??"SUCCESS",data:ue,message:Xe??"request:ok"}),O({code:"SUCCESS",message:"request:ok",data:ue})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Pt-=1,Dt.shift()?.()}};return Pt>=Ro?(r=()=>{xo(Dt,i=>i===s)},Dt.push(s)):s(),t.promise}})(e),{abort(){t.reject(re({code:-1,msg:"request:fail abort"})),r()}}},wo=S();wo.registerCommand("HttpSDK.request",Io);g("request",{version:"1.0.0"});q();L();h();xt();H();var Qe=S(),Ao=E("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await se(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await P("getLocalStorageAsync",{key:e}),a=Uo(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});Qe.registerCommand("StorageSDK.getItem",Ao);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Co=E("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=await se(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Do(t),l=Mo(t,a);return await P("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});Qe.registerCommand("StorageSDK.setItem",Co);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var No=E("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await se(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return await P("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Qe.registerCommand("StorageSDK.removeItem",No);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Oo=E("clearStorage",{async implement(){let e=y.mpId,{response:t}=await se(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});P("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Qe.registerCommand("StorageSDK.clear",Oo);g("storage.clear",{version:"1.0.0"});var _c=E("getStorageInfo",{async implement(){let{data:e}=await P("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Rc=x("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),Po=["string","number","boolean","object",""];function Do(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Po.includes(t)?t:""}function Uo(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch{return""}}function Mo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}h();L();q();var Lo=x("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});g("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});var Fo=x("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var jo=x("hideKeyboard",{implement(){w("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});var Ut=S();Ut.registerCommand("KeyboardSDK.showKeyboard",Lo);Ut.registerCommand("KeyboardSDK.updateKeyboard",Fo);Ut.registerCommand("KeyboardSDK.hideKeyboard",jo);h();q();oe();var ce=S(),Jo=E("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(D.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(D.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Vo=E("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await D.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),$o=E("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),Ko=E("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Ho=E("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserScore",params:{score:e}})}),Bo=E("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(D.reporter({event:"USE_GAME_ITEM"})),r.push(D.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",Jo);ce.registerCommand("TaskTrackerSDK.taskFinished",Vo);ce.registerCommand("TaskTrackerSDK.levelUpgrade",$o);ce.registerCommand("TaskTrackerSDK.historyUserLevel",Ko);ce.registerCommand("TaskTrackerSDK.historyUserScore",Ho);ce.registerCommand("TaskTrackerSDK.taskEvent",Bo);g("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});g("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});g("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});g("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}});H();L();q();h();Y();g("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});g("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});var qo=E("login",{async implement(){let{data:{isLogin:e}}=await P("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:l})=>{l==r&&o({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw re({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new W,s=await n;return y.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),Go=E("checkSession",{async implement(){let{data:{isLogin:e}}=await P("checkLoginAsync");return{isLogin:e}}}),nn=S();nn.registerCommand("API.login",qo);nn.registerCommand("API.checkSession",Go);h();q();var Ye=S(),zo=x("adInit",{implement:e=>{R.log("[JoliboxAdsSDK] adInit",e)}}),Wo=x("adConfig",{implement:e=>{R.log("[JoliboxAdsSDK] adConfig",e)}}),Qo=x("adBreak",{implement:e=>{R.log("[JoliboxAdsSDK] adBreak",e)}}),Yo=x("adUnit",{implement:e=>{R.log("[JoliboxAdsSDK] adUnit",e)}});Ye.registerCommand("AdsSDK.init",zo);Ye.registerCommand("AdsSDK.adConfig",Wo);Ye.registerCommand("AdsSDK.adBreak",Qo);Ye.registerCommand("AdsSDK.adUnit",Yo);g("AdsSDK.init",{version:"1.0.0"});g("AdsSDK.adConfig",{version:"1.0.0"});g("AdsSDK.adBreak",{version:"1.0.0"});g("AdsSDK.adUnit",{version:"1.0.0"});oe();Kr();
|
|
1
|
+
var ln=Object.create;var Lt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!fn.call(e,o)&&o!==r&&Lt(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e};var vn=(e,t,r)=>(r=e!=null?ln(dn(e)):{},hn(t||!e||!e.__esModule?Lt(r,"default",{value:e,enumerable:!0}):r,e));function yn(e){return!!e?.__nativeBuffers__}function le(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!yn(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=bn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Ft(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:kn(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var bn,kn,Ze=f(()=>{"use strict";bn=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};kn=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function _n(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vt(e){return typeof e=="object"&&Array.isArray(e)}function Sn(e){return typeof e>"u"}function Rn(e){return Sn(e)||e===null}function Kt(e){return typeof e=="function"}function Ht(e){return C(e)&&Kt(e.then)}function Bt(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function qt(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],l=s[i],u=r(a,l,i,o,s);u!==void 0?o[i]=u:jt(l)&&jt(a)?o[i]=n({...a},l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function jt(e){return e&&typeof e=="object"&&e.constructor===Object}function Gt(e,t){if(Array.isArray(e))return e.concat(t)}function de(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),m=function(...p){o=p,s=this;let d=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!d&&u()},t),d)return u()};return m.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,u()},m}function wn(e,t){return(...r)=>t(e,...r)}function Ee(e){return t=>wn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new st(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Vn(e){return new Promise(t=>rr(e)(t))}function rr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Kn(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Bn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qn(e[n],t[n])}function qn(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Kt(t)){try{if(e instanceof t)return}catch{}if(!Rn(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")}}function R(){if(globalThis[tt])return globalThis[tt];let e=new be,t=new nt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[tt]=r,r}var Jt,En,Tn,$t,W,xn,ot,ee,In,st,zt,Wt,Yt,Qt,Xt,fe,ke,it,S,Zt,An,at,Pn,ct,Cn,Nn,he,On,Dn,Un,er,ut,Mn,Ln,Fn,tr,b,jn,Jn,ve,pe,Y,rt,$n,et,Hn,K,be,nt,tt,h=f(()=>{"use strict";Jt=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Tn=(e,t)=>{for(var r in t)Jt(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,n)=>{for(var o=n>1?void 0:n?En(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Jt(t,r,o),o};W=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};xn=(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))(xn||{}),ot=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},ee=class extends ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},In=class extends ot{constructor(){super(...arguments),this.kind="USER_ERROR"}},st=class extends In{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},zt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Wt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Yt=class extends ee{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Qt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Xt=class extends ee{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends ot{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ke=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},it=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};S={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:S});Zt=Symbol.for("Jolibox.canIUseMap"),An={};globalThis[Zt]=An;at={get config(){return globalThis[Zt]}},Pn=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Pn||{}),ct=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ct||{}),Cn=(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))(Cn||{}),Nn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),he={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")},On=()=>he.isiOS?"iOS":he.isAndroid?"Android":he.isMac?"Mac":he.isFacebook?"Facebook":"PC",Dn="device_id",Un="advertising_id",er=e=>(localStorage.getItem(e)||localStorage.setItem(e,Nn()),localStorage.getItem(e)),ut=()=>er(Dn),Mn=()=>er(Un),Ln=e=>e.charAt(0).toUpperCase()+e.slice(1),Fn=()=>{let e=new URLSearchParams(window.location.search);return Ln(e.get("utm_source")??"")||"JoliboxSDK"},tr=e=>{let t="JoliboxWebSDK",r=On(),n=navigator.language,o=ut(),s=Mn();return`${t} (${Fn()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},b=class ye{static{this.Undefined=new ye(void 0)}constructor(t){this.element=t,this.next=ye.Undefined,this.prev=ye.Undefined}},jn=class{constructor(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===b.Undefined}clear(){let e=this._first;for(;e!==b.Undefined;){let t=e.next;e.prev=b.Undefined,e.next=b.Undefined,e=t}this._first=b.Undefined,this._last=b.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new b(e);if(this._first===b.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==b.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==b.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==b.Undefined&&e.next!==b.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===b.Undefined&&e.next===b.Undefined?(this._first=b.Undefined,this._last=b.Undefined):e.next===b.Undefined?(this._last=this._last.prev,this._last.next=b.Undefined):e.prev===b.Undefined&&(this._first=this._first.next,this._first.prev=b.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==b.Undefined;)yield e.element,e=e.next}},Jn=0,ve=class{constructor(e){this.value=e,this.id=Jn++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ve&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let r=new ve(e);this._listeners?this._listeners instanceof ve?this._listeners=[this._listeners,r]:this._listeners.push(r):(this.options?.onWillAddFirstListener?.(this),this._listeners=r,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let r=this.options?.onListenerError||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(n){r(n)}}fire(e){this._listeners&&(this._listeners instanceof ve?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Y=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new pe,n=s=>t(...s.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire({event:e,...o.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 jn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rt={};Tn(rt,{None:()=>$n,filter:()=>Kn,once:()=>rr,toPromise:()=>Vn});$n=()=>{console.log("[Jolibox SDK] None Event")};et=Symbol.for("Jolibox.hostEmitter"),Hn=()=>{let e=new Y;return globalThis[et]||(globalThis[et]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[et]},K=Hn();be=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Bn(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};be=$t([Bt],be);nt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new be,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=_n(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),rt.toPromise(rt.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}}};nt=$t([Bt],nt);tt=Symbol.for("Jolibox.commands")});function I(e,t={}){lt.emit("ERROR_REPORT",{error:e,options:t})}var lt,te,U=f(()=>{"use strict";h();h();lt=new Y,te=new Y;I.debounce=de(I,50,{leading:!0})});function Te(e,t){return`[${e}]:${t}`}var re,mt,Q=f(()=>{"use strict";U();h();U();re=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),mt=e=>new st(e)});var nr,or,sr,ir=f(()=>{"use strict";nr=[],or=[],sr=["env","createRequestTask","login"]});function cr(e,t){ar||(pt=new ne({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),dt=new ne({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),ft=new ne({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{pt.flush(),dt.flush(),ft.flush()}),ar=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:l,errMsg:u=`${s}:fail no errMsg`,errNo:m=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:d,invokeCallback:v}=p,_=u.match(/\S:(\S+)\s?/)?.[1]??"fail";pt.report({status:_,method:n(s,i),errNo:`${m}`,errMsg:u,isForeground:l,duration:Date.now()-a}),a&&d&&v&&(dt.report({status:_,method:s,isForeground:l,duration:Number((d-a).toFixed(3))}),ft.report({status:_,method:s,isForeground:l,duration:Number((Date.now()-v).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Gn,ne,ar,pt,dt,ft,gt=f(()=>{"use strict";h();Gn=e=>e==="pv"?e:"default",ne=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=Gn(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let l=i[a];n[l]||(n[l]={}),r(n[l],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let l=s.shift();if(!l&&C(a))throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let u=[];if(C(a))u.push(...Object.keys(a));else if(Z(a)){if(s.length>0)throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new ke(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(m=>{o[m]||(o[m]={});let p=C(a)?a[m]:a;r(o[m],[...s],i,p)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},ar=!1});function lr(e,t){let r=0,n=!0,o=new Map,s=cr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ht.forEach(async({method:u,args:m,resolve:p})=>{let d=await a(u,m);p(d)}),ht.length=0});let i=(u,m)=>{S.info("----resolveId",u,m);let p=o.get(Number(u));if(!p)return;let d=le(m);p(d),o.delete(Number(u))},a=(u,m)=>{let p=Date.now(),d=`${n}`;r+=1;let v=new W;if(o.set(r,v.resolve),!n&&or.includes(u))return new Promise(P=>{ht.push({method:u,args:m,resolve:P})});let A={...{method:u,startTime:p,args:m,isForeground:d},invokeType:"js-bridge"},N=!zn&&nr.includes(u),G=Ft(m,N),z=N?G:JSON.stringify(G),k;if(u.endsWith("Sync")||sr.includes(u)?k=e.call?.(u,G,r):typeof z=="string"?(console.log("-----params",u,r),k=e.invoke(u,z,r)):k=e.call?.(u,z,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=le(k)}catch(P){S.error(P)}return o.delete(r),k.errorCode&&(k.errorCode=Te(u,k.errorCode)),s({...A,...k}),k}return u.endsWith("Sync")&&o.delete(r),v.promise.then(P=>(P.errorCode&&(P.errorCode=Te(u,P.errorCode)),s({...A,...P}),P))};return{invokeNative:a,applyNative:(u,m)=>{let p=a(u,m);return Ht(p)?p.then(d=>ur(u,d)):ur(u,p)},invokeHandler:i}}function ur(e,t){if(!C(t)){S.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new Yt(r,n,o,s);return i}var ht,zn,mr=f(()=>{"use strict";Ze();h();Q();ir();gt();ht=[],zn=!1});function pr(e){let t=new Y,r=new ne({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,o,s){let i=le(o),a;if(i.__extra){a=i.params;let{type:l,startTime:u}=i.__extra;r.report({type:l,event:n,duration:Date.now()-u})}else a=i;t.emit(n,a,s)}}}var dr=f(()=>{"use strict";h();Ze();gt()});function vt(e){let{subscribeHandler:t,onNative:r,offNative:n}=pr(e),{invokeNative:o,invokeHandler:s,applyNative:i}=lr(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var fr=f(()=>{"use strict";mr();dr()});var gr=f(()=>{"use strict"});var hr=f(()=>{"use strict";fr();gr()});var X,M,vr,yr=f(()=>{"use strict";h();U();M={trigger(){},exit(){return!1},onReady(e){M.trigger=e},doExit(e){M.exit=e}},vr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)I(new Wt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{M.trigger(),e.onDocumentReady.postMessage({path:o})};X={onDocumentReady:t,doExit:o=>{let s=M.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})},invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:vr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{M.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};X={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=M.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:vr};globalThis.joliboxJSCore={...n}}});function yt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var bt=f(()=>{"use strict"});function kt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ie.publish=function(t,r){let n=yt(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,br=f(()=>{"use strict";bt()});var _e=f(()=>{"use strict";yr();br();bt()});var Er,Wn,Tr,kr,O,w,J,pi,Yn,L=f(()=>{"use strict";hr();_e();Q();h();_e();Er=X;if(!Er)throw new Qt("No joliboxJScore is found, native bridge not found.");kt();Wn={...Er},Tr=vt(Wn),{invokeHandler:kr}=Tr,{applyNative:O,invokeNative:w,onNative:J,offNative:pi,subscribeHandler:Yn}=Tr;globalThis.joliboxJSBridge={callHandler:kr,invokeHandler:kr,subscribeHandler:Yn}});var Et,_r,Sr=f(()=>{"use strict";h();U();Et=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch{return{}}},_r=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[o,s,i]=n;return{headerJson:Et(o),payloadJson:Et(s),signature:Et(i)}}else throw"joli_source is missing"}catch(t){return I(new zt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Qn,Se,Rr,Tt=f(()=>{"use strict";h();Qn="1.1.4-beta.12",Se=()=>Qn,Rr=()=>{let e=Se();return`${tr(e)}`}});var Xn,Zn,F,eo,y,H=f(()=>{"use strict";h();Sr();Tt();h();Xn={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ut(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Se()},schema:"",platform:"h5"},Zn=globalThis.joliboxJSCore?.env,F=Object.assign({},Zn?.()??Xn),eo=()=>{let{payloadJson:e,headerJson:t}=_r(F.schema),r=`${F.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(F.schema.length?F.schema:window.location.search),o=n.get("mpId")??n.get("appId")??n.get("gameId")??"",s=e.sessionId??n.get("sessionId")??r,i=!!(e.testAdsMode??n.get("testAdsMode")==="true"),a=e.joliboxEnv??n.get("joliboxEnv")??"production",l=a==="staging";return{get testMode(){return l},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return o??e.id},get mpVersion(){return t.ver??Se()},get platform(){return F.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??s??r},onEnvConfigChanged:u=>{qt(F,u,Gt)}}},y=eo()});var _t,Ir,to,ro,xr,no,wr=f(()=>{"use strict";h();U();H();h();_t=!1,Ir=(e,t)=>e==null?!1:t in e,to=e=>Ir(e,"kind"),ro=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},xr=(e,t={},r)=>{let n=e.priority??"P1",s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:ro(e.name)},env:t.environment,isFromUser:r};r?te.emit("GLOBAL_USER_ERROR",e,s):te.emit("GLOBAL_ERROR",e,s)},no=e=>Ir(e,"kind")&&e.kind==="USER_ERROR";lt.on("ERROR_REPORT",({error:e,options:t})=>{if(_t)return;_t=!0;let r=to(e)&&e.raw?e.raw:e;try{let n=no(e);xr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new it(`${o}, origin error: ${r.message}`);S.error(s),xr(new it(s.message),{environment:t.environment},!1)}finally{_t=!1}})});var Ar=f(()=>{"use strict";wr();Q();h();L();te.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});te.on("GLOBAL_USER_ERROR",(e,t)=>{S.log("UserError",e,t)})});var St=f(()=>{"use strict"});function Pr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?I(new Xt(JSON.stringify(i),"P0")):e("systemLog",i,s)};return r.debounce=de(r,500,{leading:!0}),r}function Cr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=de(t,500,{leading:!0}),t}var Nr=f(()=>{"use strict";h();h();U()});function Or(e,t){let r=Pr(e,t),n=Cr(r);return{track:r,trackPerformance:n}}var Dr=f(()=>{"use strict";Nr()});var Ur=f(()=>{"use strict";H();h();h()});var Mr=f(()=>{"use strict";Dr();St();Ur()});var Re,Lr=f(()=>{"use strict";Re=class{constructor(t,r){this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration:t??0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=performance.now(),n,o=!1,s=0,i=a=>{if(!o)return;let l=a-r;l>=this.interval&&(this.visible&&(s+=l,t(s)),r=a),n=requestAnimationFrame(i)};return{start(){o||(o=!0,r=performance.now(),n=requestAnimationFrame(i))},stop(){o=!1,n&&cancelAnimationFrame(n)}}}}});var Rt=f(()=>{"use strict"});function jr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,m={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:i};(i==="public"&&Fr<so||i==="inner")&&(m.joli_request_number=Fr++,setTimeout(()=>{$("joliboxNetRequestResult",m)},500))}var Fr,so,Jr=f(()=>{"use strict";Rt();oe();Fr=0,so=10});function xe(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return J("onRequestTaskStateChange",l=>{if(typeof l.requestTaskId!="string")return;let u=n.get(l.requestTaskId);if(u)if(l.state==="success"){let{requestTaskId:m,state:p,...d}=l;u.resolve(d),n.delete(m)}else if(l.state==="fail"){let{requestTaskId:m,state:p,...d}=l;u.reject(d),n.delete(m)}else S.warn("onRequestTaskStateChange unknown event",l)}),K.on("onLoginComplete",({isLogin:l,token:u})=>{l&&u&&(i["X-JOLI-TOKEN"]=u)}),async(l,u={})=>{let m=Date.now(),p=io(l,{...u,baseUrl:o}),{method:d="GET",responseType:v="text",dataType:_="json",timeout:A,enableCache:N=!1,appendHostCookie:G=!0}=u,z=Object.assign({"content-type":"application/json"},i,u.header),k={url:p,method:d,header:z,enableCache:N,responseType:v,appendHostCookie:G};if(d=="POST"||d=="PUT"){let j=co(u.data,z["content-type"]);k.data=j}A&&Object.assign(k,{timeout:A});let{data:{requestTaskId:P}}=w(e,k);if(typeof P!="string")throw re({code:-1,msg:"requestTaskId is not a string"});let ue=(j,V)=>{jr("request",p,{state:j,startTime:m,endTime:Date.now(),params:k,response:V,requestId:P,requestFrom:s=="public"?"public":"inner"})},{resolve:Xe,reject:on,promise:sn}=new W;n.set(P,{resolve:Xe,reject:on});try{let j=await sn;ue("success",j);let{data:V}=j;return _==="json"&&typeof V=="string"&&(V=ao(V)),{url:p,timeout:A,method:d,response:{...j,data:V}}}catch(j){let V=j;if(C(V)){let{errMsg:ge,prefetchDetail:an,isPrefetch:cn,errNo:un}=V;Z(ge)&&(ue("fail",{errMsg:ge,isPrefetch:cn,prefetchDetail:an}),I(re({code:-1,msg:ge},{errNo:un,errMsg:ge})))}throw j}}}function ao(e){try{return JSON.parse(e.trim())}catch{return e}}function co(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var io,xt=f(()=>{"use strict";h();Jr();Rt();L();U();Q();io=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var se,It=f(()=>{"use strict";Tt();xt();H();se=xe("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":Rr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ie,$r=f(()=>{"use strict";H();Lr();It();L();Ie=class extends Re{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,o=[];o.push(se("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}async reportToNative(t){let{event:r,params:n}=t;await O("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var uo,$,lo,Vr,we,D,oe=f(()=>{"use strict";Ar();h();St();Mr();H();$r();L();uo=(e,t,r)=>{let n=t,s={...C(n.extra)?n.extra:Z(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};w("trackAsync",{event:e,data:s,webviewId:r})},{track:$,trackPerformance:lo}=Or(uo,{type:ct.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),Vr=R();Vr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{lo(e,t)});Vr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{$(e,t)});we=new Y,D=new Ie($,we)});function Hr(e){let t=at.config[e];return t||(t={},at.config[e]=t),(r,n)=>{if(t[r]){S.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Br=f(()=>{"use strict";h()});function wt(e){qr=e}function Pe(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Pe(t)):Object.keys(e).reduce((t,r)=>(t[r]=Pe(e[r]),t),{})}function B(e){return typeof e=="number"}function At(e){let t=Pt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Pt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qr,E,Ce,Ne,Oe,De,ae,Ue,Me,Le,Fe,je,Je,$e,Ve,Ke,He,Be,qe,Ct=f(()=>{"use strict";qr=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qr)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${At(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Pe(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Pe(this._default)}optional(){return this._optional=!0,this}};Ce=class extends E{validate(t){return this._optional&&t===void 0?!0:B(t)?B(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):B(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):B(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ne=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Oe=class extends E{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(B(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(B(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},De=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends E{validate(t){return!0}},Ue=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Fe=class extends E{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${At(t)}`)}return!0}},je=class extends E{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(B(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(B(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(B(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},Je=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let l=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(l===void 0&&s._optional)){if(l===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(l)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},$e=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},Ve=class extends E{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:At(this.value),actual:r}):!0}},Ke=class extends E{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
2
|
+
or `);this.errors.push(s)}return n}},He=class extends E{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},Be=class extends E{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},qe=class extends E{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Nt(e,t,r="param"){if(e.errors=[],e.path=r,wt(!0),!e.validate(t)){let n=e.errors.join(`
|
|
3
|
+
`);throw e.errors.length=0,wt(!1),new TypeError(n)}}var c,Ot=f(()=>{"use strict";Ct();Ct();c={object(e){return new $e(e)},array(e){return new je(e)},tuple(...e){return new He(...e)},literal(e){return new Ve(e)},or(...e){return new Ke(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Ne},string(){return new Oe},number(){return new Ce},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Be},enum(...e){return new Fe(...e)},typedarray(e){return new qe(e)}}});var Ge,Gr,zr=f(()=>{"use strict";h();U();Ot();Q();Ge=1,Gr=e=>{function t(n,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let l="SUCCESS",u=`${n}:ok`,m=0;try{if(o.paramsSchema)try{Nt(o.paramsSchema,s,"params")}catch(_){throw mt(`${n}:fail ${_.message}`)}let p=o.implement(...s),d=p,v=`${n}:ok`;if(p&&"code"in p){let{code:_,data:A,message:N}=p;l=_,d=A,v=N}return{code:l,message:v,data:d}}catch(p){let d=p;m=d.code??d.errNo??2e3,l="FAILURE";let v=d.message??d.errMsg??`${p}`;return u=`${n}:${l} ${v.replace(/^\S+:(fail|cancel)\s?/,"")}`,I(new fe(u,m)),{code:l,message:u}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:l})}}}function r(n,o){return async(...s)=>{let i=Vt(s)?s:[s],a=Date.now(),l={method:n,trace_id:Ge};Ge+=1;let u=`${n}:ok`,m="SUCCESS",p={code:m,message:u};try{if(o.paramsSchema)try{Nt(o.paramsSchema,i,"params")}catch(_){throw mt(_.message)}let v=await o.implement(...i);if(v&&"code"in v){let{code:_,data:A,message:N}=v;m=_,u=N,v=A}return Object.assign(p,{code:m,message:u,data:v}),p}catch(d){let v=d,_=v.code??v.errNo??2e3;m="FAILURE";let A=v.message??v.errMsg??`${d}`,N=`${n}:${m} ${A.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:m,message:N}),I(new fe(N,_)),p}finally{let d=Date.now()-a;e("apiInvoked",{...l,duration:d,status:m})}}}return{createAPI:r,createSyncAPI:t}}});var T,x,g,q=f(()=>{"use strict";Br();oe();zr();Ot();({createAPI:T,createSyncAPI:x}=Gr($)),g=Hr("native")});var Qr=gn(Yr=>{"use strict";h();q();U();L();oe();var bo="exitGame",ko="onReady",Eo="onJoliboxShow",To="onJoliboxHide",ze=R(),We=Ee(I),_o=T(bo,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(Yr),await O("exitAppAsync")}}),So=x(Eo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Ro=x(To,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),xo=x(ko,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",_o);ze.registerCommand("LifecycleSDK.onReady",xo);ze.registerCommand("LifecycleSDK.onJoliboxShow",So);ze.registerCommand("LifecycleSDK.onJoliboxHide",Ro);g("lifeCycle.exit",{version:"1.0.0"});g("lifeCycle.onReady",{version:"1.0.0"});g("lifeCycle.onJoliboxShow",{version:"1.0.0"});g("lifeCycle.onJoliboxHide",{version:"1.0.0"})});L();_e();H();h();oe();M.onReady(()=>{});M.doExit(()=>($("onBeforeExit",{timestamp:Date.now()}),D.close(Date.now()-Ae),!1));function mo(){K.on("onDocumentReady",()=>{X?.onDocumentReady(window.location.href),$("onDocumentReady",{start_timestamp:Ae,timestamp:Date.now()})})}function po(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),$("joliboxServiceReady",{start_timestamp:Ae,timestamp:Date.now()}),D.start(t)}),J("onBeforeExit",({uuid:e})=>{X?.doExit(e)})}var Ae;function Kr(){Ae=Date.now(),po(),mo()}h();q();L();var Wr=R(),go="env",ho="getSystemInfoSync",vo=x(ho,{implement:()=>{let e=w("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),yo=x(go,{implement:()=>w("envSync")?.data??void 0});Wr.registerCommand("API.getSystemInfoSync",vo);Wr.registerCommand("API.env",yo);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"});var Qc=vn(Qr());Q();xt();q();h();function Xr(e){let t={};if(!C(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Zr(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function en(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function tn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!C(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}h();U();var Io=15,wo=xe("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Dt=0,Ut=[],rn=Ee(I),Ao=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Po=e=>{let t=new W,r=()=>{};return T("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(o){let s=async()=>{let i=rn(o.fail);try{if(Dt+=1,t.state!=="pending")return;let{data:a,dataType:l,responseType:u,enableCache:m,appendHostCookie:p}=o,d=Xr(o.header),v=Zr(o.method),_=en(o.timeout),A=tn(o.url,v,a),N=rn(o.success),G=Object.assign({},o,{method:v,header:d,data:v==="GET"||v==="HEAD"?void 0:a,enableCache:m,query:o.query??{},dataType:l,responseType:u,appendHostCookie:p});_&&(G.timeout=_);let z=wo(A,G);{let{response:k}=await z,{code:P,data:ue,message:Xe}=k;t.resolve({code:P??"SUCCESS",data:ue,message:Xe??"request:ok"}),N({code:"SUCCESS",message:"request:ok",data:ue})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Dt-=1,Ut.shift()?.()}};return Dt>=Io?(r=()=>{Ao(Ut,i=>i===s)},Ut.push(s)):s(),t.promise}})(e),{abort(){t.reject(re({code:-1,msg:"request:fail abort"})),r()}}},Co=R();Co.registerCommand("HttpSDK.request",Po);g("request",{version:"1.0.0"});q();L();h();It();H();var Ye=R(),No=T("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await se(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await O("getLocalStorageAsync",{key:e}),a=Fo(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});Ye.registerCommand("StorageSDK.getItem",No);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Oo=T("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=await se(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Lo(t),l=jo(t,a);return await O("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});Ye.registerCommand("StorageSDK.setItem",Oo);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Do=T("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await se(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return await O("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Ye.registerCommand("StorageSDK.removeItem",Do);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Uo=T("clearStorage",{async implement(){let e=y.mpId,{response:t}=await se(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});O("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Ye.registerCommand("StorageSDK.clear",Uo);g("storage.clear",{version:"1.0.0"});var Cc=T("getStorageInfo",{async implement(){let{data:e}=await O("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Nc=x("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),Mo=["string","number","boolean","object",""];function Lo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Mo.includes(t)?t:""}function Fo(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch{return""}}function jo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}h();L();q();var Jo=x("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});g("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});var $o=x("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var Vo=x("hideKeyboard",{implement(){w("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});var Mt=R();Mt.registerCommand("KeyboardSDK.showKeyboard",Jo);Mt.registerCommand("KeyboardSDK.updateKeyboard",$o);Mt.registerCommand("KeyboardSDK.hideKeyboard",Vo);h();q();oe();var ce=R(),Ko=T("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(D.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(D.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Ho=T("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await D.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),Bo=T("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),qo=T("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Go=T("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserScore",params:{score:e}})}),zo=T("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(D.reporter({event:"USE_GAME_ITEM"})),r.push(D.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",Ko);ce.registerCommand("TaskTrackerSDK.taskFinished",Ho);ce.registerCommand("TaskTrackerSDK.levelUpgrade",Bo);ce.registerCommand("TaskTrackerSDK.historyUserLevel",qo);ce.registerCommand("TaskTrackerSDK.historyUserScore",Go);ce.registerCommand("TaskTrackerSDK.taskEvent",zo);g("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});g("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});g("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});g("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}});H();L();q();h();Q();g("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});g("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});var Wo=T("login",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:l})=>{l==r&&o({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw re({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new W,s=await n;return y.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),Yo=T("checkSession",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");return{isLogin:e}}}),nn=R();nn.registerCommand("API.login",Wo);nn.registerCommand("API.checkSession",Yo);h();q();var Qe=R(),Qo=x("adInit",{implement:e=>{S.log("[JoliboxAdsSDK] adInit",e)}}),Xo=x("adConfig",{implement:e=>{S.log("[JoliboxAdsSDK] adConfig",e)}}),Zo=x("adBreak",{implement:e=>{S.log("[JoliboxAdsSDK] adBreak",e)}}),es=x("adUnit",{implement:e=>{S.log("[JoliboxAdsSDK] adUnit",e)}});Qe.registerCommand("AdsSDK.init",Qo);Qe.registerCommand("AdsSDK.adConfig",Xo);Qe.registerCommand("AdsSDK.adBreak",Zo);Qe.registerCommand("AdsSDK.adUnit",es);g("AdsSDK.init",{version:"1.0.0"});g("AdsSDK.adConfig",{version:"1.0.0"});g("AdsSDK.adBreak",{version:"1.0.0"});g("AdsSDK.adUnit",{version:"1.0.0"});oe();Kr();
|
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.1.4-beta.
|
|
3
|
+
> @jolibox/implement@1.1.4-beta.12 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.4-beta.
|
|
7
|
+
> @jolibox/implement@1.1.4-beta.12 build:esm
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.1.4-beta.
|
|
4
|
+
"version": "1.1.4-beta.12",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.1.4-beta.
|
|
10
|
-
"@jolibox/types": "1.1.4-beta.
|
|
9
|
+
"@jolibox/common": "1.1.4-beta.12",
|
|
10
|
+
"@jolibox/types": "1.1.4-beta.12",
|
|
11
11
|
"localforage": "1.10.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
@@ -2,7 +2,8 @@ import { mergeArray, mergeWith } from '@jolibox/common';
|
|
|
2
2
|
import { DeviceInfo, HostInfo, HostUserInfo, SdkInfo } from './types';
|
|
3
3
|
import { Env } from '@jolibox/types';
|
|
4
4
|
import { parseUrlQuery } from './url-parse';
|
|
5
|
-
import { getAppVersion
|
|
5
|
+
import { getAppVersion } from '../http/xua';
|
|
6
|
+
import { getDeviceId } from '@jolibox/common';
|
|
6
7
|
|
|
7
8
|
declare const globalThis: {
|
|
8
9
|
joliboxJSCore?: {
|
|
@@ -36,7 +37,7 @@ const wrapContext = () => {
|
|
|
36
37
|
const { payloadJson, headerJson } = parseUrlQuery(env.schema);
|
|
37
38
|
const defaultSessionId = `${env.deviceInfo.did}-${new Date().getTime()}`;
|
|
38
39
|
const urlParams = new URLSearchParams(env.schema.length ? env.schema : window.location.search);
|
|
39
|
-
const defaultGameID = urlParams.get('appId') ?? urlParams.get('gameId') ?? '';
|
|
40
|
+
const defaultGameID = urlParams.get('mpId') ?? urlParams.get('appId') ?? urlParams.get('gameId') ?? '';
|
|
40
41
|
const sessionId = payloadJson.sessionId ?? urlParams.get('sessionId') ?? defaultSessionId;
|
|
41
42
|
const testAdsMode = !!(payloadJson.testAdsMode ?? urlParams.get('testAdsMode') === 'true');
|
|
42
43
|
const joliboxEnv = payloadJson.joliboxEnv ?? urlParams.get('joliboxEnv') ?? 'production';
|
package/src/common/http/uuid.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
3
|
-
const r = (Math.random() * 16) | 0;
|
|
4
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
5
|
-
return v.toString(16);
|
|
6
|
-
});
|
|
7
|
-
};
|
|
1
|
+
import { uuidv4, isValidUUIDV4 } from '@jolibox/common';
|
|
8
2
|
|
|
9
|
-
export
|
|
10
|
-
return /^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(uuid);
|
|
11
|
-
};
|
|
3
|
+
export { uuidv4, isValidUUIDV4 };
|
package/src/common/http/xua.ts
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const platform = {
|
|
4
|
-
isiOS:
|
|
5
|
-
navigator.userAgent.includes('iPhone') ||
|
|
6
|
-
navigator.userAgent.includes('iPod') ||
|
|
7
|
-
navigator.userAgent.includes('iPad') ||
|
|
8
|
-
navigator.userAgent.includes('iPhone OS'),
|
|
9
|
-
iosVersion: () => {
|
|
10
|
-
const v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/) as string[];
|
|
11
|
-
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || '0', 10)];
|
|
12
|
-
},
|
|
13
|
-
isAndroid: navigator.userAgent.includes('Android'),
|
|
14
|
-
isMac: navigator.userAgent.includes('Mac'),
|
|
15
|
-
isFacebook: navigator.userAgent.includes('FB_IAB'),
|
|
16
|
-
isPC: !navigator.userAgent.includes('iPhone') && !navigator.userAgent.includes('Android')
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const getPlatform = () => {
|
|
20
|
-
if (platform.isiOS) {
|
|
21
|
-
return 'iOS';
|
|
22
|
-
} else if (platform.isAndroid) {
|
|
23
|
-
return 'Android';
|
|
24
|
-
} else if (platform.isMac) {
|
|
25
|
-
return 'Mac';
|
|
26
|
-
} else if (platform.isFacebook) {
|
|
27
|
-
return 'Facebook';
|
|
28
|
-
} else {
|
|
29
|
-
return 'PC';
|
|
30
|
-
}
|
|
31
|
-
};
|
|
1
|
+
import { xUserAgent as xua } from '@jolibox/common';
|
|
32
2
|
|
|
33
3
|
const jssdkVersion = '__JOLIBOX_LOCAL_SDK_VERSION__';
|
|
34
4
|
|
|
@@ -36,44 +6,7 @@ export const getAppVersion = () => {
|
|
|
36
6
|
return jssdkVersion;
|
|
37
7
|
};
|
|
38
8
|
|
|
39
|
-
export const DEVICE_ID = 'device_id';
|
|
40
|
-
export const ADVERTISING_ID = 'advertising_id';
|
|
41
|
-
|
|
42
|
-
export const getStorage = (cookieKey: string) => {
|
|
43
|
-
if (!localStorage.getItem(cookieKey)) {
|
|
44
|
-
localStorage.setItem(cookieKey, uuidv4());
|
|
45
|
-
}
|
|
46
|
-
return localStorage.getItem(cookieKey)!;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const getDeviceId = () => {
|
|
50
|
-
return getStorage(DEVICE_ID);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const getAdvertisingId = () => {
|
|
54
|
-
return getStorage(ADVERTISING_ID);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const firstCharUpperCase = (chars: string) => chars.charAt(0).toUpperCase() + chars.slice(1);
|
|
58
|
-
|
|
59
|
-
export const getUtmSource = () => {
|
|
60
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
61
|
-
return firstCharUpperCase(urlParams.get('utm_source') ?? '') || 'JoliboxSDK';
|
|
62
|
-
};
|
|
63
|
-
|
|
64
9
|
export const xUserAgent = () => {
|
|
65
|
-
const applicationName = 'JoliboxWebSDK';
|
|
66
|
-
const thePlatform = getPlatform();
|
|
67
|
-
const locale = navigator.language;
|
|
68
|
-
const deviceId = getDeviceId();
|
|
69
|
-
const adid = getAdvertisingId();
|
|
70
10
|
const appVersion = getAppVersion();
|
|
71
|
-
|
|
72
|
-
// const deviceModel = parserResult.device.model;
|
|
73
|
-
const deviceModel = 'UnknownModel';
|
|
74
|
-
// const systemVersion = parserResult.os.version;
|
|
75
|
-
const systemVersion = 'UnknownSystemVersion';
|
|
76
|
-
return `${applicationName} (${getUtmSource()}${thePlatform}; ${deviceModel}; ${systemVersion}; ${locale}) uuid/${deviceId} adid/${adid} version/${
|
|
77
|
-
appVersion || ''
|
|
78
|
-
}`;
|
|
11
|
+
return `${xua(appVersion)}`;
|
|
79
12
|
};
|
|
@@ -1,50 +1,6 @@
|
|
|
1
1
|
import { context } from '@/common/context';
|
|
2
2
|
import { logger } from '@jolibox/common';
|
|
3
|
-
import { IDevice, IPage, IEventPackage, IEvent, EProject } from '
|
|
4
|
-
|
|
5
|
-
const keysOfPage: (keyof IPage)[] = ['name', 'params'];
|
|
6
|
-
const keysOfEvent: (keyof IEvent)[] = ['name', 'type', 'location', 'target', 'extra', 'timestamp', 'userId'];
|
|
7
|
-
const keysOfDevice: (keyof IDevice)[] = [
|
|
8
|
-
'platform',
|
|
9
|
-
'os',
|
|
10
|
-
'appVersion',
|
|
11
|
-
'appId',
|
|
12
|
-
'model',
|
|
13
|
-
'brand',
|
|
14
|
-
'uuid',
|
|
15
|
-
'jsSdkVersion',
|
|
16
|
-
'extra'
|
|
17
|
-
];
|
|
18
|
-
function serializeObject<T>(obj: T, order: (keyof T)[]): any[] {
|
|
19
|
-
return order.map((key) => {
|
|
20
|
-
if (key === 'params' && obj[key]) {
|
|
21
|
-
const params = obj[key] as Record<string, any>;
|
|
22
|
-
return Object.keys(params).reduce((acc, k) => {
|
|
23
|
-
acc[k] = String(params[k]);
|
|
24
|
-
return acc;
|
|
25
|
-
}, {} as Record<string, any>);
|
|
26
|
-
}
|
|
27
|
-
return obj[key];
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function serializeEvent(event: IEvent): any[] {
|
|
32
|
-
const location = event.location ? serializeObject(event.location, keysOfPage) : null;
|
|
33
|
-
const target = event.target ? serializeObject(event.target, keysOfPage) : null;
|
|
34
|
-
|
|
35
|
-
// 定义IEvent的序列化顺序
|
|
36
|
-
return serializeObject({ ...event, location, target }, keysOfEvent);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function serializeEventPackage(eventPackage: IEventPackage): any[] {
|
|
40
|
-
// 序列化事件数组
|
|
41
|
-
const events = eventPackage.events.map((event) => serializeEvent(event));
|
|
42
|
-
|
|
43
|
-
// 定义IDevice的序列化顺序
|
|
44
|
-
const device = serializeObject(eventPackage.device, keysOfDevice);
|
|
45
|
-
|
|
46
|
-
return [eventPackage.protocolVersion, events, device, eventPackage.project];
|
|
47
|
-
}
|
|
3
|
+
import { IDevice, IPage, IEventPackage, IEvent, EProject, serializeEventPackage } from '@jolibox/common';
|
|
48
4
|
|
|
49
5
|
export abstract class EventTracker {
|
|
50
6
|
deviceInfo: IDevice | null = null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PerformanceType, TrackEvent } from '@jolibox/types';
|
|
2
|
+
import { EProject } from '@jolibox/common';
|
|
2
3
|
|
|
3
4
|
export interface Track {
|
|
4
5
|
(tag: TrackEvent, info: Record<string, unknown> | null): void;
|
|
@@ -25,66 +26,3 @@ export interface CommonReportConfig {
|
|
|
25
26
|
mp_version: string;
|
|
26
27
|
trace_id?: number;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
export enum EventType {
|
|
30
|
-
System = 1000, // used for web sdk
|
|
31
|
-
ErrorTrace = 1001, // used for web sdk
|
|
32
|
-
UserDefined = 1002 // used for web sdk
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface IPage {
|
|
36
|
-
name: string;
|
|
37
|
-
params: Record<string, string | boolean | number | null> | null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IEvent {
|
|
41
|
-
name: string;
|
|
42
|
-
type: EventType; // use a higher ts version to get static analysis
|
|
43
|
-
location: IPage | null;
|
|
44
|
-
target: IPage | null;
|
|
45
|
-
extra: Record<string, string | boolean | number | null> | null;
|
|
46
|
-
timestamp: number; // in unix timestamp
|
|
47
|
-
userId: string | null; // 没登陆时为空
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export enum EProject {
|
|
51
|
-
MiniGame = 'mini-game',
|
|
52
|
-
MiniDrama = 'mini-drama',
|
|
53
|
-
App = 'app',
|
|
54
|
-
WebSDK = 'web-sdk',
|
|
55
|
-
AppSDK = 'app-sdk'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export enum EPlatform {
|
|
59
|
-
App = 0,
|
|
60
|
-
H5 = 1,
|
|
61
|
-
Weapp = 2,
|
|
62
|
-
Alipay = 3,
|
|
63
|
-
Gcash = 4,
|
|
64
|
-
Dana = 5,
|
|
65
|
-
Umma = 6,
|
|
66
|
-
|
|
67
|
-
WebSDK = 1000,
|
|
68
|
-
AppSDK = 1001,
|
|
69
|
-
|
|
70
|
-
Other = 9999
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface IDevice {
|
|
74
|
-
platform: EPlatform;
|
|
75
|
-
os: string; // for app: Android、iOS
|
|
76
|
-
appVersion: string;
|
|
77
|
-
appId: string; // for external SDK, "1 - game h5", "2 - drama h5", "3 - game h5 ant", "4 - drama h5 ant"
|
|
78
|
-
model: string;
|
|
79
|
-
brand: string;
|
|
80
|
-
uuid: string; // 前端生成的唯一标识,用来串整个埋点
|
|
81
|
-
jsSdkVersion: string | null;
|
|
82
|
-
extra: Record<string, string | boolean | number | null> | null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface IEventPackage {
|
|
86
|
-
protocolVersion: string;
|
|
87
|
-
events: IEvent[];
|
|
88
|
-
device: IDevice;
|
|
89
|
-
project: EProject;
|
|
90
|
-
}
|
package/src/h5/http/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ export class JoliboxHttpClient implements IHttpClient {
|
|
|
65
65
|
const response = await fetch(url, {
|
|
66
66
|
method: 'GET',
|
|
67
67
|
headers,
|
|
68
|
+
credentials: 'include',
|
|
68
69
|
signal: timeoutFn(timeout ?? 30000)
|
|
69
70
|
});
|
|
70
71
|
return (await response.json()) as T;
|
|
@@ -100,8 +101,10 @@ export class JoliboxHttpClient implements IHttpClient {
|
|
|
100
101
|
method: 'POST',
|
|
101
102
|
headers,
|
|
102
103
|
body: JSON.stringify(data),
|
|
103
|
-
signal: timeoutFn(timeout ?? 30000)
|
|
104
|
+
signal: timeoutFn(timeout ?? 30000),
|
|
105
|
+
credentials: 'include'
|
|
104
106
|
});
|
|
107
|
+
|
|
105
108
|
const responseContentType = response.headers.get('content-type');
|
|
106
109
|
|
|
107
110
|
// return blob
|
|
@@ -167,6 +170,7 @@ export class JoliboxHttpClient implements IHttpClient {
|
|
|
167
170
|
const response = await fetch(url, {
|
|
168
171
|
method: 'PUT',
|
|
169
172
|
headers,
|
|
173
|
+
credentials: 'include',
|
|
170
174
|
body: JSON.stringify(data ?? {}) // 将数据转换为 JSON 字符串
|
|
171
175
|
});
|
|
172
176
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { expect, test } from 'jest';
|
|
2
2
|
import { xUserAgent, getAppVersion } from '../../../../common/http/xua';
|
|
3
|
-
import { isValidUUIDV4 } from '
|
|
3
|
+
import { isValidUUIDV4 } from '@jolibox/common';
|
|
4
4
|
|
|
5
5
|
describe('xua', () => {
|
|
6
6
|
it('test xua', () => {
|
|
@@ -5,7 +5,7 @@ import '@/common/report/errors/report/listeners';
|
|
|
5
5
|
import { BaseError, logger } from '@jolibox/common';
|
|
6
6
|
import { errorReportEmitter } from '@/common/report/errors';
|
|
7
7
|
import { ErrorData } from '@/common/report/errors/report';
|
|
8
|
-
import { IEvent, EventType, EProject } from '
|
|
8
|
+
import { IEvent, EventType, EProject } from '@jolibox/common';
|
|
9
9
|
import { tracker } from '../event-tracker';
|
|
10
10
|
import { context } from '@/common/context';
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { context } from '@/common/context';
|
|
2
2
|
import { logger } from '@jolibox/common';
|
|
3
|
-
import {
|
|
3
|
+
import { EventTracker } from '@/common/report';
|
|
4
4
|
import JoliboxHttpClient from '@/h5/http';
|
|
5
5
|
|
|
6
6
|
export class H5EventTracker extends EventTracker {
|
package/src/h5/report/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './errors';
|
|
2
|
-
import { createCommands, EventEmitter,
|
|
3
|
-
import {
|
|
2
|
+
import { createCommands, EventEmitter, isObject, isString } from '@jolibox/common';
|
|
3
|
+
import { EProject, EventType, IEvent } from '@jolibox/common';
|
|
4
|
+
import { CommonReportConfig, createTracks } from '@/common/report';
|
|
4
5
|
import { tracker } from './event-tracker';
|
|
5
6
|
import { H5TaskTracker } from './task-tracker';
|
|
6
7
|
import { context } from '@/common/context';
|