@jolibox/sdk 1.1.4-beta.4 → 1.1.4-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "7eacca35e51bf3e2face4112b3cfa76777e7c0d5",
7
- "packages/sdk/package.json": "ea4aea324367f207cca21df0b8e282bac0dc1df6",
7
+ "packages/sdk/package.json": "3e9db4458eb11df395a147b7e3f281dcf82d98d0",
8
8
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "27fbe5050ac2e95d6643ff5fec335ba4d22ceb93",
9
9
  "packages/sdk/src/api/can-i-use.ts": "c6f9e896d05a63eabd754ab01d90711186eb8959",
10
10
  "packages/sdk/src/api/get-system-info.ts": "c73be9f62c7055093effadaf6c48c54d6f383542",
@@ -12,8 +12,8 @@
12
12
  "packages/sdk/src/api/login.ts": "747c923c87175b467c17e303a14210bf0ab7a1cb",
13
13
  "packages/sdk/src/events.ts": "e7c5994804cc627eb5ad225c161c48a37a7b3bdb",
14
14
  "packages/sdk/src/index.ts": "a772c24e370f183dba0c5346004f41dac6cb6807",
15
- "packages/sdk/src/loader/h5.ts": "9797fb5ca8e710803f61c47125e4eb1f6fad8a84",
16
- "packages/sdk/src/loader/index.ts": "d727939b55e661bcccf0eaf05ecdb32194bd55f8",
15
+ "packages/sdk/src/loader/h5.ts": "9ca7acc4996893f683b9adc8cffb2456928e5875",
16
+ "packages/sdk/src/loader/index.ts": "8a009a193488ad0cd7e7469adad5bd3b1b2d525f",
17
17
  "packages/sdk/src/loader/native.ts": "b250d460509f67b4544e5ca4d5f35f8dd20373c4",
18
18
  "packages/sdk/src/loader/version.ts": "8b584cf9c97198b6b6d1f728cc49f56260d7c02e",
19
19
  "packages/sdk/src/sdks/ads.ts": "d12ffe12be857f216a59a742f54395e31888adb5",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var N=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Oe=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},Ke=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ce(t))!ke.call(e,s)&&s!==r&&N(e,s,{get:()=>t[s],enumerable:!(n=Ae(t,s))||n.enumerable});return e};var Pe=e=>Ke(N({},"__esModule",{value:!0}),e);var ct={};Oe(ct,{JoliboxSDK:()=>M});module.exports=Pe(ct);var X=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ne=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,n)=>{for(var s=n>1?void 0:n?Me(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&X(t,r,s),s};function je(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function V(e){return typeof e=="string"}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Je(e){return typeof e>"u"}function Fe(e){return Je(e)||e===null}function Be(e){return typeof e=="function"}function ee(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Ve=(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))(Ve||{}),$e=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},te=class extends $e{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var re=class extends te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var He={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:He});var ne=Symbol.for("Jolibox.canIUseMap"),Ge={};globalThis[ne]=Ge;var se={get config(){return globalThis[ne]}};function $(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},ze=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},We=0,w=class{constructor(e){this.value=e,this.id=We++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},H=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ze,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},F={};Ne(F,{None:()=>Qe,filter:()=>Xe,once:()=>oe,toPromise:()=>Ye});var Qe=()=>{console.log("[Jolibox SDK] None Event")};function Ye(e){return new Promise(t=>oe(e)(t))}function oe(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Xe(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var j=Symbol.for("Jolibox.hostEmitter"),qe=()=>{let e=new H;return globalThis[j]||(globalThis[j]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[j]},ie=qe();function Ze(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)et(e[n],t[n])}function et(e,t){if(V(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Be(t)){try{if(e instanceof t)return}catch{}if(!Fe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ze(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=q([ee],D);var B=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=je(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),F.toPromise(F.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}}};B=q([ee],B);var J=Symbol.for("Jolibox.commands");function p(){if(globalThis[J])return globalThis[J];let e=new D,t=new B,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[J]=r,r}document.addEventListener("DOMContentLoaded",()=>ie.emit("onDocumentReady",v.startTime));var tt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=tt(),ae=p(),G=e=>{ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=G;window.addEventListener("unhandledrejection",G.bind(void 0));window.addEventListener("error",G.bind(void 0));window.onerror=(e,t,r,n,s)=>{ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var z=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(z(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=z(e),{major:o,minor:i,patch:l}=z(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ce=p(),L=(e,t)=>{ce.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ce.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var de="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(de)??"{}"),W=Date.now(),me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,le=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function rt(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:W};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(Q(n))).text();le(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(Y(r))).text();le(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(de,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var ue=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!me(W,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new re(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),Le=await import(h);return URL.revokeObjectURL(h),Le}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!me(W,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),rt()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var pe=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var nt="1.1.4-beta.4",A=nt,ge=x(A),Ee=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,st=typeof Ee<"u",Q=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,Y=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implementation@${e}/dist/index.js`,ot=e=>/^\d+\.\d+\.\d+$/.test(e),_e=ot(A)?ge:A,fe=Q(_e),he=Y(_e);function it(){st?pe(Ee,{bootstrapUrl:fe,implementUrl:he})():ue({bootstrapUrl:fe,implementUrl:he,currentMajorVersion:ge,currentVersion:A})()}it();var ye=p();function Re(){return ye.excuteCommandSync("API.getSystemInfoSync")}function Se(){return ye.excuteCommandSync("API.env")}function be(e,t){return se.config[e]?.[t]}function ve(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var Te="1.0.0";function y(e){let r=Se().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=be(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||$(Te,i,"<")?!1:s.length===0?!0:xe(o,s)||xe(o.properties,s)}function xe(e,t){if(!e)return!1;let r=ve(e,t);return r?Z(r)?!0:V(r)?$(Te,r,">="):!1:!1}var Ie=p();async function we(){return y("login")?await Ie.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function Ue(){return y("checkSession")?await Ie.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var De=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new H}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var at="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(at,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var M=class{constructor(){this.jssdkVersion="1.1.4-beta.4";this.runtime=new De;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=Re.bind(this);this.canIUse=y.bind(this);this.login=we.bind(this);this.checkSession=Ue.bind(this)}};window.JoliboxSDK=M;
1
+ "use strict";var N=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Oe=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},Ke=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ce(t))!ke.call(e,s)&&s!==r&&N(e,s,{get:()=>t[s],enumerable:!(n=Ae(t,s))||n.enumerable});return e};var Pe=e=>Ke(N({},"__esModule",{value:!0}),e);var ct={};Oe(ct,{JoliboxSDK:()=>M});module.exports=Pe(ct);var X=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ne=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,n)=>{for(var s=n>1?void 0:n?Me(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&X(t,r,s),s};function je(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function V(e){return typeof e=="string"}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Je(e){return typeof e>"u"}function Fe(e){return Je(e)||e===null}function Be(e){return typeof e=="function"}function ee(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Ve=(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))(Ve||{}),$e=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},te=class extends $e{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var re=class extends te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var He={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:He});var ne=Symbol.for("Jolibox.canIUseMap"),Ge={};globalThis[ne]=Ge;var se={get config(){return globalThis[ne]}};function $(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},ze=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},We=0,w=class{constructor(e){this.value=e,this.id=We++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},H=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ze,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},F={};Ne(F,{None:()=>Qe,filter:()=>Xe,once:()=>oe,toPromise:()=>Ye});var Qe=()=>{console.log("[Jolibox SDK] None Event")};function Ye(e){return new Promise(t=>oe(e)(t))}function oe(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Xe(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var j=Symbol.for("Jolibox.hostEmitter"),qe=()=>{let e=new H;return globalThis[j]||(globalThis[j]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[j]},ie=qe();function Ze(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)et(e[n],t[n])}function et(e,t){if(V(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Be(t)){try{if(e instanceof t)return}catch{}if(!Fe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ze(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=q([ee],D);var B=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=je(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),F.toPromise(F.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}}};B=q([ee],B);var J=Symbol.for("Jolibox.commands");function p(){if(globalThis[J])return globalThis[J];let e=new D,t=new B,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[J]=r,r}document.addEventListener("DOMContentLoaded",()=>ie.emit("onDocumentReady",v.startTime));var tt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=tt(),ae=p(),G=e=>{ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=G;window.addEventListener("unhandledrejection",G.bind(void 0));window.addEventListener("error",G.bind(void 0));window.onerror=(e,t,r,n,s)=>{ae.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var z=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(z(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=z(e),{major:o,minor:i,patch:l}=z(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ce=p(),L=(e,t)=>{ce.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ce.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var de="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(de)??"{}"),W=Date.now(),me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,le=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function rt(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:W};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(Q(n))).text();le(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(Y(r))).text();le(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(de,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var ue=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!me(W,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new re(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),Le=await import(h);return URL.revokeObjectURL(h),Le}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!me(W,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),rt()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var pe=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var nt="1.1.4-beta.6",A=nt,ge=x(A),Ee=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,st=typeof Ee<"u",Q=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,Y=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,ot=e=>/^\d+\.\d+\.\d+$/.test(e),_e=ot(A)?ge:A,fe=Q(_e),he=Y(_e);function it(){st?pe(Ee,{bootstrapUrl:fe,implementUrl:he})():ue({bootstrapUrl:fe,implementUrl:he,currentMajorVersion:ge,currentVersion:A})()}it();var ye=p();function Re(){return ye.excuteCommandSync("API.getSystemInfoSync")}function Se(){return ye.excuteCommandSync("API.env")}function be(e,t){return se.config[e]?.[t]}function ve(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var Te="1.0.0";function y(e){let r=Se().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=be(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||$(Te,i,"<")?!1:s.length===0?!0:xe(o,s)||xe(o.properties,s)}function xe(e,t){if(!e)return!1;let r=ve(e,t);return r?Z(r)?!0:V(r)?$(Te,r,">="):!1:!1}var Ie=p();async function we(){return y("login")?await Ie.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function Ue(){return y("checkSession")?await Ie.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var De=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new H}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var at="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(at,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var M=class{constructor(){this.jssdkVersion="1.1.4-beta.6";this.runtime=new De;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=Re.bind(this);this.canIUse=y.bind(this);this.login=we.bind(this);this.checkSession=Ue.bind(this)}};window.JoliboxSDK=M;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var Y=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{for(var s=n>1?void 0:n?Le(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&Y(t,r,s),s};function Ce(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function F(e){return typeof e=="string"}function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ke(e){return typeof e>"u"}function Oe(e){return ke(e)||e===null}function Ke(e){return typeof e=="function"}function Z(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Pe=(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))(Pe||{}),Me=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 Me{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var te=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var Ne={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Ne});var re=Symbol.for("Jolibox.canIUseMap"),je={};globalThis[re]=je;var ne={get config(){return globalThis[re]}};function B(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},Je=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},Fe=0,w=class{constructor(e){this.value=e,this.id=Fe++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},V=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Je,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},j={};Ae(j,{None:()=>Be,filter:()=>$e,once:()=>se,toPromise:()=>Ve});var Be=()=>{console.log("[Jolibox SDK] None Event")};function Ve(e){return new Promise(t=>se(e)(t))}function se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function $e(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var M=Symbol.for("Jolibox.hostEmitter"),He=()=>{let e=new V;return globalThis[M]||(globalThis[M]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[M]},oe=He();function Ge(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ze(e[n],t[n])}function ze(e,t){if(F(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ke(t)){try{if(e instanceof t)return}catch{}if(!Oe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ge(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=X([Z],D);var J=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ce(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),j.toPromise(j.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}}};J=X([Z],J);var N=Symbol.for("Jolibox.commands");function p(){if(globalThis[N])return globalThis[N];let e=new D,t=new J,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[N]=r,r}document.addEventListener("DOMContentLoaded",()=>oe.emit("onDocumentReady",v.startTime));var We=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=We(),ie=p(),$=e=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=$;window.addEventListener("unhandledrejection",$.bind(void 0));window.addEventListener("error",$.bind(void 0));window.onerror=(e,t,r,n,s)=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var H=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(H(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=H(e),{major:o,minor:i,patch:l}=H(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ae=p(),L=(e,t)=>{ae.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ae.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var le="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(le)??"{}"),G=Date.now(),ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,me=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function Qe(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:G};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(z(n))).text();me(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(W(r))).text();me(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(le,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var de=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!ce(G,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new te(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),De=await import(h);return URL.revokeObjectURL(h),De}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!ce(G,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),Qe()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var ue=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var Ye="1.1.4-beta.4",A=Ye,he=x(A),ge=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,Xe=typeof ge<"u",z=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,W=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implementation@${e}/dist/index.js`,qe=e=>/^\d+\.\d+\.\d+$/.test(e),Ee=qe(A)?he:A,pe=z(Ee),fe=W(Ee);function Ze(){Xe?ue(ge,{bootstrapUrl:pe,implementUrl:fe})():de({bootstrapUrl:pe,implementUrl:fe,currentMajorVersion:he,currentVersion:A})()}Ze();var _e=p();function ye(){return _e.excuteCommandSync("API.getSystemInfoSync")}function Re(){return _e.excuteCommandSync("API.env")}function Se(e,t){return ne.config[e]?.[t]}function be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var xe="1.0.0";function y(e){let r=Re().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Se(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||B(xe,i,"<")?!1:s.length===0?!0:ve(o,s)||ve(o.properties,s)}function ve(e,t){if(!e)return!1;let r=be(e,t);return r?q(r)?!0:F(r)?B(xe,r,">="):!1:!1}var Te=p();async function Ie(){return y("login")?await Te.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function we(){return y("checkSession")?await Te.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var Ue=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new V}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var et="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(et,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var Q=class{constructor(){this.jssdkVersion="1.1.4-beta.4";this.runtime=new Ue;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=ye.bind(this);this.canIUse=y.bind(this);this.login=Ie.bind(this);this.checkSession=we.bind(this)}};window.JoliboxSDK=Q;export{Q as JoliboxSDK};
1
+ var Y=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{for(var s=n>1?void 0:n?Le(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&Y(t,r,s),s};function Ce(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function F(e){return typeof e=="string"}function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ke(e){return typeof e>"u"}function Oe(e){return ke(e)||e===null}function Ke(e){return typeof e=="function"}function Z(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Pe=(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))(Pe||{}),Me=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 Me{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var te=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var Ne={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Ne});var re=Symbol.for("Jolibox.canIUseMap"),je={};globalThis[re]=je;var ne={get config(){return globalThis[re]}};function B(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},Je=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},Fe=0,w=class{constructor(e){this.value=e,this.id=Fe++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},V=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Je,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},j={};Ae(j,{None:()=>Be,filter:()=>$e,once:()=>se,toPromise:()=>Ve});var Be=()=>{console.log("[Jolibox SDK] None Event")};function Ve(e){return new Promise(t=>se(e)(t))}function se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function $e(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var M=Symbol.for("Jolibox.hostEmitter"),He=()=>{let e=new V;return globalThis[M]||(globalThis[M]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[M]},oe=He();function Ge(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ze(e[n],t[n])}function ze(e,t){if(F(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ke(t)){try{if(e instanceof t)return}catch{}if(!Oe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ge(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=X([Z],D);var J=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ce(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),j.toPromise(j.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}}};J=X([Z],J);var N=Symbol.for("Jolibox.commands");function p(){if(globalThis[N])return globalThis[N];let e=new D,t=new J,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[N]=r,r}document.addEventListener("DOMContentLoaded",()=>oe.emit("onDocumentReady",v.startTime));var We=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=We(),ie=p(),$=e=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=$;window.addEventListener("unhandledrejection",$.bind(void 0));window.addEventListener("error",$.bind(void 0));window.onerror=(e,t,r,n,s)=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var H=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(H(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=H(e),{major:o,minor:i,patch:l}=H(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ae=p(),L=(e,t)=>{ae.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ae.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var le="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(le)??"{}"),G=Date.now(),ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,me=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function Qe(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:G};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(z(n))).text();me(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(W(r))).text();me(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(le,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var de=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!ce(G,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new te(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),De=await import(h);return URL.revokeObjectURL(h),De}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!ce(G,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),Qe()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var ue=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var Ye="1.1.4-beta.6",A=Ye,he=x(A),ge=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,Xe=typeof ge<"u",z=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,W=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,qe=e=>/^\d+\.\d+\.\d+$/.test(e),Ee=qe(A)?he:A,pe=z(Ee),fe=W(Ee);function Ze(){Xe?ue(ge,{bootstrapUrl:pe,implementUrl:fe})():de({bootstrapUrl:pe,implementUrl:fe,currentMajorVersion:he,currentVersion:A})()}Ze();var _e=p();function ye(){return _e.excuteCommandSync("API.getSystemInfoSync")}function Re(){return _e.excuteCommandSync("API.env")}function Se(e,t){return ne.config[e]?.[t]}function be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var xe="1.0.0";function y(e){let r=Re().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Se(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||B(xe,i,"<")?!1:s.length===0?!0:ve(o,s)||ve(o.properties,s)}function ve(e,t){if(!e)return!1;let r=be(e,t);return r?q(r)?!0:F(r)?B(xe,r,">="):!1:!1}var Te=p();async function Ie(){return y("login")?await Te.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function we(){return y("checkSession")?await Te.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var Ue=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new V}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var et="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(et,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var Q=class{constructor(){this.jssdkVersion="1.1.4-beta.6";this.runtime=new Ue;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=ye.bind(this);this.canIUse=y.bind(this);this.login=Ie.bind(this);this.checkSession=we.bind(this)}};window.JoliboxSDK=Q;export{Q as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var Y=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{for(var s=n>1?void 0:n?Le(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&Y(t,r,s),s};function Ce(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function F(e){return typeof e=="string"}function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ke(e){return typeof e>"u"}function Oe(e){return ke(e)||e===null}function Ke(e){return typeof e=="function"}function Z(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Pe=(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))(Pe||{}),Me=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 Me{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var te=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var Ne={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Ne});var re=Symbol.for("Jolibox.canIUseMap"),je={};globalThis[re]=je;var ne={get config(){return globalThis[re]}};function B(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},Je=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},Fe=0,w=class{constructor(e){this.value=e,this.id=Fe++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},V=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Je,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},j={};Ae(j,{None:()=>Be,filter:()=>$e,once:()=>se,toPromise:()=>Ve});var Be=()=>{console.log("[Jolibox SDK] None Event")};function Ve(e){return new Promise(t=>se(e)(t))}function se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function $e(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var M=Symbol.for("Jolibox.hostEmitter"),He=()=>{let e=new V;return globalThis[M]||(globalThis[M]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[M]},oe=He();function Ge(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ze(e[n],t[n])}function ze(e,t){if(F(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ke(t)){try{if(e instanceof t)return}catch{}if(!Oe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ge(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=X([Z],D);var J=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ce(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),j.toPromise(j.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}}};J=X([Z],J);var N=Symbol.for("Jolibox.commands");function p(){if(globalThis[N])return globalThis[N];let e=new D,t=new J,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[N]=r,r}document.addEventListener("DOMContentLoaded",()=>oe.emit("onDocumentReady",v.startTime));var We=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=We(),ie=p(),$=e=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=$;window.addEventListener("unhandledrejection",$.bind(void 0));window.addEventListener("error",$.bind(void 0));window.onerror=(e,t,r,n,s)=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var H=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(H(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=H(e),{major:o,minor:i,patch:l}=H(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ae=p(),L=(e,t)=>{ae.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ae.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var le="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(le)??"{}"),G=Date.now(),ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,me=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function Qe(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:G};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(z(n))).text();me(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(W(r))).text();me(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(le,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var de=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!ce(G,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new te(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),De=await import(h);return URL.revokeObjectURL(h),De}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!ce(G,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),Qe()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var ue=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var Ye="1.1.4-beta.4",A=Ye,he=x(A),ge=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,Xe=typeof ge<"u",z=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,W=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implementation@${e}/dist/index.js`,qe=e=>/^\d+\.\d+\.\d+$/.test(e),Ee=qe(A)?he:A,pe=z(Ee),fe=W(Ee);function Ze(){Xe?ue(ge,{bootstrapUrl:pe,implementUrl:fe})():de({bootstrapUrl:pe,implementUrl:fe,currentMajorVersion:he,currentVersion:A})()}Ze();var _e=p();function ye(){return _e.excuteCommandSync("API.getSystemInfoSync")}function Re(){return _e.excuteCommandSync("API.env")}function Se(e,t){return ne.config[e]?.[t]}function be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var xe="1.0.0";function y(e){let r=Re().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Se(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||B(xe,i,"<")?!1:s.length===0?!0:ve(o,s)||ve(o.properties,s)}function ve(e,t){if(!e)return!1;let r=be(e,t);return r?q(r)?!0:F(r)?B(xe,r,">="):!1:!1}var Te=p();async function Ie(){return y("login")?await Te.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function we(){return y("checkSession")?await Te.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var Ue=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new V}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var et="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(et,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var Q=class{constructor(){this.jssdkVersion="1.1.4-beta.4";this.runtime=new Ue;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=ye.bind(this);this.canIUse=y.bind(this);this.login=Ie.bind(this);this.checkSession=we.bind(this)}};window.JoliboxSDK=Q;})();
1
+ "use strict";(()=>{var Y=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{for(var s=n>1?void 0:n?Le(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&Y(t,r,s),s};function Ce(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function F(e){return typeof e=="string"}function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ke(e){return typeof e>"u"}function Oe(e){return ke(e)||e===null}function Ke(e){return typeof e=="function"}function Z(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Pe=(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))(Pe||{}),Me=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 Me{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var te=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var Ne={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Ne});var re=Symbol.for("Jolibox.canIUseMap"),je={};globalThis[re]=je;var ne={get config(){return globalThis[re]}};function B(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let g=parseInt(s[l],10)||0,c=parseInt(o[l],10)||0;if(g>c){n=1;break}else if(g<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var a=class U{static{this.Undefined=new U(void 0)}constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}},Je=class{constructor(){this._first=a.Undefined,this._last=a.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===a.Undefined}clear(){let e=this._first;for(;e!==a.Undefined;){let t=e.next;e.prev=a.Undefined,e.next=a.Undefined,e=t}this._first=a.Undefined,this._last=a.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new a(e);if(this._first===a.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==a.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==a.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==a.Undefined&&e.next!==a.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===a.Undefined&&e.next===a.Undefined?(this._first=a.Undefined,this._last=a.Undefined):e.next===a.Undefined?(this._last=this._last.prev,this._last.next=a.Undefined):e.prev===a.Undefined&&(this._first=this._first.next,this._first.prev=a.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==a.Undefined;)yield e.element,e=e.next}},Fe=0,w=class{constructor(e){this.value=e,this.id=Fe++}},b=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof w&&(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 w(e);this._listeners?this._listeners instanceof w?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 w?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},V=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new b,n=o=>t(...o.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire({event:e,...s.shift()})}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Je,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},j={};Ae(j,{None:()=>Be,filter:()=>$e,once:()=>se,toPromise:()=>Ve});var Be=()=>{console.log("[Jolibox SDK] None Event")};function Ve(e){return new Promise(t=>se(e)(t))}function se(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function $e(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new b(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var M=Symbol.for("Jolibox.hostEmitter"),He=()=>{let e=new V;return globalThis[M]||(globalThis[M]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[M]},oe=He();function Ge(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ze(e[n],t[n])}function ze(e,t){if(F(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ke(t)){try{if(e instanceof t)return}catch{}if(!Oe(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var D=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new b,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Ge(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};D=X([Z],D);var J=class{constructor(){this._onWillExecuteCommand=new b,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new b,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new D,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ce(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),j.toPromise(j.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}}};J=X([Z],J);var N=Symbol.for("Jolibox.commands");function p(){if(globalThis[N])return globalThis[N];let e=new D,t=new J,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[N]=r,r}document.addEventListener("DOMContentLoaded",()=>oe.emit("onDocumentReady",v.startTime));var We=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=We(),ie=p(),$=e=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`)})},E=$;window.addEventListener("unhandledrejection",$.bind(void 0));window.addEventListener("error",$.bind(void 0));window.onerror=(e,t,r,n,s)=>{ie.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:s})}}).catch(o=>{console.error(`Fallback report: ${o} ${JSON.stringify(e)}`)})};var H=e=>{let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[s,o,i]=[n[0]??"0",n[1]??"0",n[2]??"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},x=e=>parseInt(H(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:s}=H(e),{major:o,minor:i,patch:l}=H(t);return r!==o?r>o?1:-1:n!==i?n>i?1:-1:s!==l?s>l?1:-1:0};var ae=p(),L=(e,t)=>{ae.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},_=(e,t,r)=>{ae.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};var le="jolibox-sdk-loadermeta",I=JSON.parse(localStorage.getItem(le)??"{}"),G=Date.now(),ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,me=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);async function Qe(){let e="https://stg-api.jolibox.com/api/fe-configs/js-sdk/version_metadata";try{let t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:r,bootstrap_version:n}=await t.json(),s={...I,timestamp:G};if(n){let{bootstrap_version:o}=I;if(!(o&&T(o,n))){let i=await(await fetch(z(n))).text();me(i)&&(s={...s,bootstrap_version:n,bootstrap_script:i})}}if(r){let{implement_version:o}=I;if(!(o&&T(o,r))){let i=await(await fetch(W(r))).text();me(i)&&(s={...s,implement_version:r,implement_script:i})}}localStorage.setItem(le,JSON.stringify(s))}catch(t){console.warn("Failed to fetch loader metadata: ",t)}}var de=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:s}=e;function o(){let{bootstrap_version:c,bootstrap_script:f,timestamp:u}=I;if(c&&f&&u&&!ce(G,u)&&x(c)==t&&T(c,r)>0)return{script:f,type:"localscript"};try{let m=new XMLHttpRequest;return m.open("GET",n,!1),m.send(),{script:m.responseText,type:"fetch_from_cdn"}}catch(m){E(new te(`Bootstrap module faile to fetch ${m}`))}}function i(){let c=Date.now();L("jsSdkBegin",{t:c}),v.startTime=c;let{script:f,type:u}=o()??{};if(f){let m=document.createElement("script");m.type="text/javascript",m.innerHTML=f,document.head.appendChild(m),_("bootstrapModuleLoaded",Date.now()-c,{type:u})}}function l(c){(async u=>{try{let m=new Blob([u],{type:"application/javascript"}),h=URL.createObjectURL(m),De=await import(h);return URL.revokeObjectURL(h),De}catch(m){E(new R(`implement module evaluate error in h5:${m} `))}})(c)}function g(){let c=Date.now(),{implement_script:f,implement_version:u,timestamp:m}=I;if(f&&u&&m&&!ce(G,m)&&x(u)==t&&T(u,r)>0){l(f),_("implementModuleLoaded",Date.now()-c,{type:"loadscript"});return}let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=s,h.onload=()=>{_("bootstrapModuleLoaded",Date.now()-c,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{i(),g(),Qe()}catch(c){E(new R(`module evaluate error: ${c}`))}}};var ue=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(async i=>{try{let l=new Blob([i],{type:"application/javascript"}),g=URL.createObjectURL(l),c=await import(g);return URL.revokeObjectURL(g),c}catch(l){E(new R(`implement module evaluate error in native:${l} `))}})(s)}return()=>{try{let s=Date.now();L("jsSdkBegin",{t:s}),v.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),_("implementModuleLoaded",Date.now()-s,{type:"native"});let l=r(t.implementUrl);n(l),_("bootstrapModuleLoaded",Date.now()-s,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),E(new R(`module load failed ${s}`))}}};var Ye="1.1.4-beta.6",A=Ye,he=x(A),ge=window.webkit||window.JoliAndroidSDKBridge?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,Xe=typeof ge<"u",z=e=>`http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${e}/dist/index.js`,W=e=>`http://cdn.jsdelivr.net/npm/@jolibox/implement@${e}/dist/index.js`,qe=e=>/^\d+\.\d+\.\d+$/.test(e),Ee=qe(A)?he:A,pe=z(Ee),fe=W(Ee);function Ze(){Xe?ue(ge,{bootstrapUrl:pe,implementUrl:fe})():de({bootstrapUrl:pe,implementUrl:fe,currentMajorVersion:he,currentVersion:A})()}Ze();var _e=p();function ye(){return _e.excuteCommandSync("API.getSystemInfoSync")}function Re(){return _e.excuteCommandSync("API.env")}function Se(e,t){return ne.config[e]?.[t]}function be(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var xe="1.0.0";function y(e){let r=Re().data?.deviceInfo?.platform;if(!r)return!1;let[n,...s]=e.split(":"),o=Se(r=="h5"?r:"native",n);if(!o)return!1;let i=o.version;return typeof i!="string"||B(xe,i,"<")?!1:s.length===0?!0:ve(o,s)||ve(o.properties,s)}function ve(e,t){if(!e)return!1;let r=be(e,t);return r?q(r)?!0:F(r)?B(xe,r,">="):!1:!1}var Te=p();async function Ie(){return y("login")?await Te.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}}async function we(){return y("checkSession")?await Te.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}}var Ue=window.JoliboxRuntime;var d=class{constructor(){this.commands=p();this._emitter=new V}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var et="LifecycleSDK.onReady",C=class extends d{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(et,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var k=class extends d{async getItem(t){return await this.commands.executeCommand("StorageSDK.getItem",t)}async setItem(t,r){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:await this.commands.executeCommand("StorageSDK.setItem",t,r)}async removeItem(t){return this.commands.executeCommand("StorageSDK.removeItem",t)}async clear(){return this.commands.executeCommand("StorageSDK.clear")}};var O=class extends d{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var K=class extends d{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",t)}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var P=class extends d{async onLevelFinished(t,r,n){let s=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return s?Promise.resolve(s):await this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})}async onTaskFinished(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||await this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r})}async onTaskEvent(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||await this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r)}async onTaskPayment(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskPayment");return n||await this.commands.executeCommand("TaskTrackerSDK.taskPayment",t,{...r})}async onLevelUpgrade(t,r){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||await this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r)}async onHistoryUserLevel(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t)}async onHistoryUserScore(t){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||await this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t)}};var Q=class{constructor(){this.jssdkVersion="1.1.4-beta.6";this.runtime=new Ue;this.ads=new O;this.lifecycle=new C;this.storage=new k;this.keyboard=new K;this.task=new P;this.getSystemInfoSync=ye.bind(this);this.canIUse=y.bind(this);this.login=Ie.bind(this);this.checkSession=we.bind(this)}};window.JoliboxSDK=Q;})();
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.1.4-beta.4",
4
+ "version": "1.1.4-beta.6",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.1.4-beta.4",
11
- "@jolibox/types": "1.1.4-beta.4"
10
+ "@jolibox/common": "1.1.4-beta.6",
11
+ "@jolibox/types": "1.1.4-beta.6"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.1.4-beta.4 clean
3
+ > @jolibox/sdk@1.1.4-beta.6 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.4-beta.4 build:cjs
7
+ > @jolibox/sdk@1.1.4-beta.6 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.1.4-beta.4 build:esm
11
+ > @jolibox/sdk@1.1.4-beta.6 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.1.4-beta.4 build:iife
15
+ > @jolibox/sdk@1.1.4-beta.6 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
package/src/loader/h5.ts CHANGED
@@ -137,7 +137,7 @@ export const createLoadImplement = (params: {
137
137
  }
138
138
 
139
139
  // load remote impletation
140
- function loadRemoteImplementation() {
140
+ function loadRemoteImplement() {
141
141
  const implStartLoad = Date.now();
142
142
  const { implement_script, implement_version, timestamp } = CURRENT_VERSION_STORE;
143
143
  if (implement_script && implement_version && timestamp) {
@@ -167,7 +167,7 @@ export const createLoadImplement = (params: {
167
167
  return () => {
168
168
  try {
169
169
  loadBootstrapModule();
170
- loadRemoteImplementation();
170
+ loadRemoteImplement();
171
171
  fetchCurrentRemoteScript();
172
172
  } catch (e) {
173
173
  reportError(new InternalJSModuleEvalError(`module evaluate error: ${e}`));
@@ -46,7 +46,7 @@ const isNative = typeof loadScript !== 'undefined';
46
46
  export const getBoostrapModuleUrl = (version: string | number) =>
47
47
  `http://cdn.jsdelivr.net/npm/@jolibox/bootstrap@${version}/dist/index.js`;
48
48
  export const getImplementModuleUrl = (version: string | number) =>
49
- `http://cdn.jsdelivr.net/npm/@jolibox/implementation@${version}/dist/index.js`;
49
+ `http://cdn.jsdelivr.net/npm/@jolibox/implement@${version}/dist/index.js`;
50
50
  /**
51
51
  * localTest
52
52
  */