@jolibox/common 1.1.13 → 1.1.14-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty,Pe=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var le=(n,e,t)=>e in n?v(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e)=>{for(var t in e||(e={}))me.call(e,t)&&le(n,t,e[t]);if(de)for(var t of de(e))Me.call(e,t)&&le(n,t,e[t]);return n},w=(n,e)=>Pe(n,Se(e));var ue=(n,e)=>{for(var t in e)v(n,t,{get:e[t],enumerable:!0})},Ue=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ke(e))!me.call(n,o)&&o!==t&&v(n,o,{get:()=>e[o],enumerable:!(r=ce(e,o))||r.enumerable});return n};var De=n=>Ue(v({},"__esModule",{value:!0}),n),O=(n,e,t,r)=>{for(var o=r>1?void 0:r?ce(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&v(e,t,o),o};var N=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{c(t.next(a))}catch(m){o(m)}},s=a=>{try{c(t.throw(a))}catch(m){o(m)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);c((t=t.apply(n,e)).next())});var Rn={};ue(Rn,{ADVERTISING_ID:()=>be,APIError:()=>q,BaseError:()=>x,DEVICE_ID:()=>ve,Deferred:()=>U,EPlatform:()=>he,EProject:()=>_e,EventEmitter:()=>h,EventType:()=>Ee,EventUtils:()=>T,InternalApplyNativeError:()=>z,InternalBufferError:()=>Q,InternalContextError:()=>X,InternalError:()=>u,InternalGlobalJSError:()=>Y,InternalInvokeMethodError:()=>B,InternalInvokeNativeError:()=>$,InternalJSCoreNotFoundError:()=>W,InternalJSModuleEvalError:()=>J,InternalJSModuleFetchError:()=>G,InternalMetricReportError:()=>Z,InternalReporterError:()=>ee,InternalSchemaParseError:()=>K,LoadScriptCode:()=>ye,Singleton:()=>b,UserCustomError:()=>I,UserError:()=>g,UserFetchError:()=>j,UserFunctionEvalError:()=>H,UserGlobalError:()=>F,UserValidateError:()=>V,canIUseConfig:()=>tn,compareVersion:()=>on,createCommands:()=>hn,createRunTaskQueue:()=>He,debounce:()=>qe,get:()=>rn,getAdvertisingId:()=>Ce,getDeviceId:()=>Ie,getOriginalLocalStorage:()=>re,getPlatform:()=>Re,getStorage:()=>oe,getUtmSource:()=>Ae,hostEmitter:()=>xn,isArray:()=>Je,isBoolean:()=>Be,isDefined:()=>We,isFunction:()=>S,isIterable:()=>ze,isNumber:()=>$e,isObject:()=>pe,isPromiseLike:()=>Qe,isString:()=>L,isStringArray:()=>Ke,isTypedArray:()=>Ge,isUndefined:()=>fe,isUndefinedOrNull:()=>P,isValidUUIDV4:()=>cn,logger:()=>ne,mergeArray:()=>Ye,mergeWith:()=>Xe,microTask:()=>je,platform:()=>A,promisifyAPI:()=>Fe,serializeEventPackage:()=>ln,sleep:()=>Ve,timeout:()=>D,uuidv4:()=>te,validateConstraint:()=>Oe,validateConstraints:()=>se,wrapUserFunction:()=>en,xUserAgent:()=>un});module.exports=De(Rn);if(typeof window!="undefined"&&!window.AbortController){let n=function(){this.signal=new e};n.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let t=new Event("abort");this.signal.dispatchEvent(t)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(t,r){this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(r)},e.prototype.removeEventListener=function(t,r){if(!this._eventListeners[t])return;let o=this._eventListeners[t].indexOf(r);o!==-1&&this._eventListeners[t].splice(o,1)},e.prototype.dispatchEvent=function(t){if(this._eventListeners[t.type])for(let r of this._eventListeners[t.type])r.call(this,t)},window.AbortController=n,window.AbortSignal=e}function D(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}function Ve(n){return new Promise(e=>setTimeout(e,n))}function Fe(n){return e=>new Promise((t,r)=>{n(w(f({},e),{success:t,fail(o){let i=new Error(o.errMsg);r(i)}}))})}function je(n){if(n)Promise.resolve().then(n);else return Promise.resolve()}var U=class{constructor(){this.state="pending";this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};function He(){let n=[],e=!1,t=()=>N(this,null,function*(){let r=n.shift();if(r){e=!0;try{yield r()}finally{e=!1,t()}}});return r=>{n.push(r),e||t()}}function L(n){return typeof n=="string"}function Ke(n){return Array.isArray(n)&&n.every(e=>L(e))}function pe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}function Ge(n){let e=Object.getPrototypeOf(Uint8Array);return typeof n=="object"&&n instanceof e}function Je(n){return typeof n=="object"&&Array.isArray(n)}function $e(n){return typeof n=="number"&&!isNaN(n)}function ze(n){return!!n&&typeof n[Symbol.iterator]=="function"}function Be(n){return n===!0||n===!1}function fe(n){return typeof n=="undefined"}function We(n){return!P(n)}function P(n){return fe(n)||n===null}function S(n){return typeof n=="function"}function Qe(n){return pe(n)&&S(n.then)}function b(n){let e=n,t=null,r=function(...o){return t||(t=new e(...o)),t};return r.prototype=e.prototype,r}function Xe(n,e,t){if(typeof t!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let c=o[s],a=i[s],m=t(c,a,s,o,i);m!==void 0?o[s]=m:ge(a)&&ge(c)?o[s]=r(f({},c),a):Array.isArray(a)&&Array.isArray(c)?o[s]=[...c,...a]:o[s]=a}return o}return r(n,e)}function ge(n){return n&&typeof n=="object"&&n.constructor===Object}function Ye(n,e){if(Array.isArray(n))return n.concat(e)}function qe(n,e,t={}){let r=null,o,i,s,{leading:c=!1,trailing:a=!0}=t,m=()=>(s=n.apply(i,o),o=void 0,i=void 0,s),d=function(...Le){o=Le,i=this;let ae=c&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,a&&!ae&&m()},e),ae)return m()};return d.cancel=()=>{r&&clearTimeout(r),r=null,o=i=void 0},d.flush=()=>{if(r)return clearTimeout(r),r=null,m()},d}var ye=(a=>(a[a.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",a[a.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",a[a.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",a[a.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",a[a.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",a[a.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",a[a.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",a[a.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",a))(ye||{}),x=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}},u=class extends x{constructor(){super(...arguments);this.kind="INTERNAL_ERROR"}},g=class extends x{constructor(){super(...arguments);this.kind="USER_ERROR"}},V=class extends g{constructor(){super(...arguments);this.name="USER_VALIDATE_ERROR"}},F=class extends g{constructor(){super(...arguments);this.name="USER_GLOBAL_ERROR";this.priority="P1"}},I=class extends g{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_CUSTOM_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},j=class extends g{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_FETCH_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},H=class extends g{constructor(){super(...arguments);this.name="USER_CALLBACK_ERROR"}},K=class extends u{constructor(){super(...arguments);this.name="INTERNAL_SCHEMA_PARSE_ERROR";this.priority="P0"}},G=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_FETCH_ERROR";this.priority="P0"}},J=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_EVAL_ERROR";this.priority="P0"}},$=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},z=class extends u{constructor(t,r,o,i){super(t);this.errNo=r;this.name="INTERNAL_APPLY_NATIVE_ERROR";this.errorType=o,this.errorCode=i}},B=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_METHOD_ERROR"}},W=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JSCORE_ERROR";this.priority="P0"}},Q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_BUFFER_ERROR"}},X=class extends u{constructor(t,r){super(t);this.message=t;this.name="INTERNAL_CONTEXT_ERROR";this.property=r}},Y=class extends u{constructor(){super(...arguments);this.name="INTERNAL_GLOBAL_JS_ERROR";this.priority="P1"}},q=class extends x{constructor(t,r,o,i,s){super(t);this.message=t;this.code=r;this.kind="API_ERROR";this.name="API_ERROR";o&&(this.errorType=o),i!==void 0&&(this.stack=i),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Z=class extends u{constructor(){super(...arguments);this.name="INTERNAL_METRIC_REPORT_ERROR"}},ee=class extends u{constructor(){super(...arguments);this.name="INTERNAL_REPORTER_ERROR"}};function Ze(n,e){return(...t)=>e(n,...t)}function en(n){return e=>Ze(e,function(t,...r){if(typeof t=="function")try{return t.apply(this,r)}catch(o){n(new I(`${o}`))}})}function C(n){return(...e)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[n])!=null?o:globalThis.console[n])(...e)}}var ne={log:C("log"),warn:C("warn"),info:C("info"),error:C("error"),debug:C("debug")};Object.assign(globalThis,{logger:ne});var Te=Symbol.for("Jolibox.canIUseMap"),nn={};globalThis[Te]=nn;var tn={get config(){return globalThis[Te]}};function rn(n,e,t){let r=n;for(let o of e)if(r&&typeof r=="object")r=r[o];else return t;return r===void 0?t:r}function on(n,e,t){let r=0;if(n!==e){let o=n.split("."),i=e.split("."),s=Math.max(o.length,i.length);for(let c=0;c<s;c++){let a=parseInt(o[c],10)||0,m=parseInt(i[c],10)||0;if(a>m){r=1;break}else if(a<m){r=-1;break}}}if(!t)return r;switch(t){case">":return r>0;case"<":return r<0;case"=":return r===0;case">=":return r>=0;case"<=":return r<=0;default:return!1}}var Ee=(r=>(r[r.System=1e3]="System",r[r.ErrorTrace=1001]="ErrorTrace",r[r.UserDefined=1002]="UserDefined",r))(Ee||{}),_e=(i=>(i.MiniGame="mini-game",i.MiniDrama="mini-drama",i.App="app",i.WebSDK="web-sdk",i.AppSDK="app-sdk",i))(_e||{}),he=(d=>(d[d.App=0]="App",d[d.H5=1]="H5",d[d.Weapp=2]="Weapp",d[d.Alipay=3]="Alipay",d[d.Gcash=4]="Gcash",d[d.Dana=5]="Dana",d[d.Umma=6]="Umma",d[d.WebSDK=1e3]="WebSDK",d[d.AppSDK=1001]="AppSDK",d[d.Other=9999]="Other",d))(he||{}),xe=["name","params"],sn=["name","type","location","target","extra","timestamp","userId"],an=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(n,e){return e.map(t=>{if(t==="params"&&n[t]){let r=n[t];return Object.keys(r).reduce((o,i)=>(o[i]=String(r[i]),o),{})}return n[t]})}function dn(n){let e=n.location?k(n.location,xe):null,t=n.target?k(n.target,xe):null;return k(w(f({},n),{location:e,target:t}),sn)}function ln(n){let e=n.events.map(r=>dn(r)),t=k(n.device,an);return[n.protocolVersion,e,t,n.project]}var te=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)}),cn=n=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(n);function re(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let n=Object.getOwnPropertyDescriptor(window,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}if(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),n&&n.get)return n.get.call(window);let e=Window.prototype,t=Object.getOwnPropertyDescriptor(e,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(n){return console.warn("Failed to get original localStorage, fallback to default implementation",n),localStorage}}re();var A={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let n=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Re=()=>A.isiOS?"iOS":A.isAndroid?"Android":A.isMac?"Mac":A.isFacebook?"Facebook":"PC",ve="device_id",be="advertising_id",oe=n=>(window.__joliboxLocalStorage__.getItem(n)||window.__joliboxLocalStorage__.setItem(n,te()),window.__joliboxLocalStorage__.getItem(n)),Ie=()=>oe(ve),Ce=()=>oe(be),mn=n=>n.charAt(0).toUpperCase()+n.slice(1),Ae=()=>{var e;let n=new URLSearchParams(window.location.search);return mn((e=n.get("utm_source"))!=null?e:"")||"JoliboxSDK"},un=n=>{let e="JoliboxWebSDK",t=Re(),r=navigator.language,o=Ie(),i=Ce();return`${e} (${Ae()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n||""}`};var E=class E{constructor(e){this.element=e,this.next=E.Undefined,this.prev=E.Undefined}};E.Undefined=new E(void 0);var l=E,M=class{constructor(){this._first=l.Undefined;this._last=l.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===l.Undefined}clear(){let e=this._first;for(;e!==l.Undefined;){let t=e.next;e.prev=l.Undefined,e.next=l.Undefined,e=t}this._first=l.Undefined,this._last=l.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new l(e);if(this._first===l.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==l.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==l.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==l.Undefined&&e.next!==l.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===l.Undefined&&e.next===l.Undefined?(this._first=l.Undefined,this._last=l.Undefined):e.next===l.Undefined?(this._last=this._last.prev,this._last.next=l.Undefined):e.prev===l.Undefined&&(this._first=this._first.next,this._first.prev=l.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==l.Undefined;)yield e.element,e=e.next}};var pn=0,_=class{constructor(e){this.value=e;this.id=pn++}},p=class{constructor(e){this.options=e;this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof _&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var i,s,c,a,m,d;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new _(t);this._listeners?this._listeners instanceof _?this._listeners=[this._listeners,o]:this._listeners.push(o):((s=(i=this.options)==null?void 0:i.onWillAddFirstListener)==null||s.call(i,this),this._listeners=o,(a=(c=this.options)==null?void 0:c.onDidFirstListener)==null||a.call(c,this)),(d=(m=this.options)==null?void 0:m.onDidAddListener)==null||d.call(m,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(i){r(i)}}fire(e){this._listeners&&(this._listeners instanceof _?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){var s;let r=(s=this.listeners.get(e))!=null?s:new p,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)r.fire(f({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new M,this.cachedEventQueue.set(e,o)),o.push({args:t})}}};var T={};ue(T,{None:()=>fn,filter:()=>yn,once:()=>we,toPromise:()=>gn});var fn=()=>{console.log("[Jolibox SDK] None Event")};function gn(n){return new Promise(e=>we(n)(e))}function we(n){return(e,t=null)=>{let r=!1;return n(i=>{if(!r)return r=!0,e.call(t,i)},null)}}function yn(n,e){return(r=>{let o,i={onWillAddFirstListener(){o=r(s.fire,s)}},s=new p(i);return s.event})((r,o=null)=>n(i=>e(i)&&r.call(o,i),null))}var ie=Symbol.for("Jolibox.hostEmitter"),Tn=()=>{let n=new h;return globalThis[ie]||(globalThis[ie]={on:n.on.bind(n),off:n.off.bind(n),emit:n.emit.bind(n)}),globalThis[ie]},xn=Tn();function se(n,e){let t=Math.min(n.length,e.length);for(let r=0;r<t;r++)Oe(n[r],e[r])}function Oe(n,e){if(L(e)){if(typeof n!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(S(e)){try{if(n instanceof e)return}catch(t){}if(!P(n)&&n.constructor===e||e.length===1&&e.call(void 0,n)===!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 y=class{constructor(){this._commands=new Map;this._onDidRegisterCommand=new p;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 o=[];for(let s of e.metadata.args)o.push(s.constraint);let i=e.handler;e.handler=function(...s){return se(s,o),i(...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}};y=O([b],y);var R=class{constructor(){this._onWillExecuteCommand=new p;this.onWillExecuteCommand=this._onWillExecuteCommand.event;this._onDidExecuteCommand=new p;this.onDidExecuteCommand=this._onDidExecuteCommand.event;this.registry=new y;this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=D(3e4)),this._starActivation}executeCommand(e,...t){return N(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),T.toPromise(T.filter(this.registry.onDidRegisterCommand,o=>o===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!!!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let o=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(o.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};R=O([b],R);var Ne=Symbol.for("Jolibox.commands");function En(){return typeof globalThis!="undefined"?globalThis[Ne]:void 0}function _n(n){typeof globalThis!="undefined"&&(globalThis[Ne]=n)}function hn(){let n=En();if(n)return n;let e=new y,t=new R,r={registerCommand(o,i,s){e.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return t.executeCommand(o,...i)},excuteCommandSync(o,...i){return t.executeCommandThowErr(o,...i)}};return _n(r),r}
1
+ "use strict";var v=Object.defineProperty,Pe=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var le=(n,e,t)=>e in n?v(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e)=>{for(var t in e||(e={}))me.call(e,t)&&le(n,t,e[t]);if(de)for(var t of de(e))Me.call(e,t)&&le(n,t,e[t]);return n},w=(n,e)=>Pe(n,Se(e));var ue=(n,e)=>{for(var t in e)v(n,t,{get:e[t],enumerable:!0})},Ue=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ke(e))!me.call(n,o)&&o!==t&&v(n,o,{get:()=>e[o],enumerable:!(r=ce(e,o))||r.enumerable});return n};var De=n=>Ue(v({},"__esModule",{value:!0}),n),O=(n,e,t,r)=>{for(var o=r>1?void 0:r?ce(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&v(e,t,o),o};var N=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{c(t.next(a))}catch(m){o(m)}},s=a=>{try{c(t.throw(a))}catch(m){o(m)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);c((t=t.apply(n,e)).next())});var Rn={};ue(Rn,{ADVERTISING_ID:()=>be,APIError:()=>Y,BaseError:()=>x,DEVICE_ID:()=>ve,Deferred:()=>U,EPlatform:()=>he,EProject:()=>_e,EventEmitter:()=>h,EventType:()=>Ee,EventUtils:()=>T,InternalApplyNativeError:()=>z,InternalBufferError:()=>Q,InternalContextError:()=>q,InternalError:()=>u,InternalGlobalJSError:()=>X,InternalInvokeMethodError:()=>B,InternalInvokeNativeError:()=>$,InternalJSCoreNotFoundError:()=>W,InternalJSModuleEvalError:()=>J,InternalJSModuleFetchError:()=>G,InternalMetricReportError:()=>Z,InternalReporterError:()=>ee,InternalSchemaParseError:()=>K,LoadScriptCode:()=>ye,Singleton:()=>b,UserCustomError:()=>I,UserError:()=>g,UserFetchError:()=>j,UserFunctionEvalError:()=>H,UserGlobalError:()=>F,UserValidateError:()=>V,canIUseConfig:()=>tn,compareVersion:()=>on,createCommands:()=>hn,createRunTaskQueue:()=>He,debounce:()=>Ye,get:()=>rn,getAdvertisingId:()=>Ce,getDeviceId:()=>Ie,getOriginalLocalStorage:()=>re,getPlatform:()=>Re,getStorage:()=>oe,getUtmSource:()=>Ae,hostEmitter:()=>xn,isArray:()=>Je,isBoolean:()=>Be,isDefined:()=>We,isFunction:()=>S,isIterable:()=>ze,isNumber:()=>$e,isObject:()=>pe,isPromiseLike:()=>Qe,isString:()=>L,isStringArray:()=>Ke,isTypedArray:()=>Ge,isUndefined:()=>fe,isUndefinedOrNull:()=>P,isValidUUIDV4:()=>cn,logger:()=>ne,mergeArray:()=>Xe,mergeWith:()=>qe,microTask:()=>je,platform:()=>A,promisifyAPI:()=>Fe,serializeEventPackage:()=>ln,sleep:()=>Ve,timeout:()=>D,uuidv4:()=>te,validateConstraint:()=>Oe,validateConstraints:()=>se,wrapUserFunction:()=>en,xUserAgent:()=>un});module.exports=De(Rn);if(typeof window!="undefined"&&!window.AbortController){let n=function(){this.signal=new e};n.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let t=new Event("abort");this.signal.dispatchEvent(t)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(t,r){this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(r)},e.prototype.removeEventListener=function(t,r){if(!this._eventListeners[t])return;let o=this._eventListeners[t].indexOf(r);o!==-1&&this._eventListeners[t].splice(o,1)},e.prototype.dispatchEvent=function(t){if(this._eventListeners[t.type])for(let r of this._eventListeners[t.type])r.call(this,t)},window.AbortController=n,window.AbortSignal=e}function D(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}function Ve(n){return new Promise(e=>setTimeout(e,n))}function Fe(n){return e=>new Promise((t,r)=>{n(w(f({},e),{success:t,fail(o){let i=new Error(o.errMsg);r(i)}}))})}function je(n){if(n)Promise.resolve().then(n);else return Promise.resolve()}var U=class{constructor(){this.state="pending";this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};function He(){let n=[],e=!1,t=()=>N(this,null,function*(){let r=n.shift();if(r){e=!0;try{yield r()}finally{e=!1,t()}}});return r=>{n.push(r),e||t()}}function L(n){return typeof n=="string"}function Ke(n){return Array.isArray(n)&&n.every(e=>L(e))}function pe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}function Ge(n){let e=Object.getPrototypeOf(Uint8Array);return typeof n=="object"&&n instanceof e}function Je(n){return typeof n=="object"&&Array.isArray(n)}function $e(n){return typeof n=="number"&&!isNaN(n)}function ze(n){return!!n&&typeof n[Symbol.iterator]=="function"}function Be(n){return n===!0||n===!1}function fe(n){return typeof n=="undefined"}function We(n){return!P(n)}function P(n){return fe(n)||n===null}function S(n){return typeof n=="function"}function Qe(n){return pe(n)&&S(n.then)}function b(n){let e=n,t=null,r=function(...o){return t||(t=new e(...o)),t};return r.prototype=e.prototype,r}function qe(n,e,t){if(typeof t!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let c=o[s],a=i[s],m=t(c,a,s,o,i);m!==void 0?o[s]=m:ge(a)&&ge(c)?o[s]=r(f({},c),a):Array.isArray(a)&&Array.isArray(c)?o[s]=[...c,...a]:o[s]=a}return o}return r(n,e)}function ge(n){return n&&typeof n=="object"&&n.constructor===Object}function Xe(n,e){if(Array.isArray(n))return n.concat(e)}function Ye(n,e,t={}){let r=null,o,i,s,{leading:c=!1,trailing:a=!0}=t,m=()=>(s=n.apply(i,o),o=void 0,i=void 0,s),d=function(...Le){o=Le,i=this;let ae=c&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,a&&!ae&&m()},e),ae)return m()};return d.cancel=()=>{r&&clearTimeout(r),r=null,o=i=void 0},d.flush=()=>{if(r)return clearTimeout(r),r=null,m()},d}var ye=(a=>(a[a.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",a[a.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",a[a.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",a[a.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",a[a.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",a[a.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",a[a.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",a[a.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",a))(ye||{}),x=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}},u=class extends x{constructor(){super(...arguments);this.kind="INTERNAL_ERROR"}},g=class extends x{constructor(){super(...arguments);this.kind="USER_ERROR"}},V=class extends g{constructor(){super(...arguments);this.name="USER_VALIDATE_ERROR"}},F=class extends g{constructor(){super(...arguments);this.name="USER_GLOBAL_ERROR";this.priority="P1"}},I=class extends g{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_CUSTOM_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},j=class extends g{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_FETCH_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},H=class extends g{constructor(){super(...arguments);this.name="USER_CALLBACK_ERROR"}},K=class extends u{constructor(){super(...arguments);this.name="INTERNAL_SCHEMA_PARSE_ERROR";this.priority="P0"}},G=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_FETCH_ERROR";this.priority="P0"}},J=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_EVAL_ERROR";this.priority="P0"}},$=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},z=class extends u{constructor(t,r,o,i){super(t);this.errNo=r;this.name="INTERNAL_APPLY_NATIVE_ERROR";this.errorType=o,this.errorCode=i}},B=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_METHOD_ERROR"}},W=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JSCORE_ERROR";this.priority="P0"}},Q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_BUFFER_ERROR"}},q=class extends u{constructor(t,r){super(t);this.message=t;this.name="INTERNAL_CONTEXT_ERROR";this.property=r}},X=class extends u{constructor(){super(...arguments);this.name="INTERNAL_GLOBAL_JS_ERROR";this.priority="P1"}},Y=class extends x{constructor(t,r,o,i,s){super(t);this.message=t;this.code=r;this.kind="API_ERROR";this.name="API_ERROR";o&&(this.errorType=o),i!==void 0&&(this.stack=i),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Z=class extends u{constructor(){super(...arguments);this.name="INTERNAL_METRIC_REPORT_ERROR"}},ee=class extends u{constructor(){super(...arguments);this.name="INTERNAL_REPORTER_ERROR"}};function Ze(n,e){return(...t)=>e(n,...t)}function en(n){return e=>Ze(e,function(t,...r){if(typeof t=="function")try{return t.apply(this,r)}catch(o){n(new I(`${o}`))}})}function C(n){return(...e)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[n])!=null?o:globalThis.console[n])(...e)}}var ne={log:C("log"),warn:C("warn"),info:C("info"),error:C("error"),debug:C("debug")};Object.assign(globalThis,{logger:ne});var Te=Symbol.for("Jolibox.canIUseMap"),nn={};globalThis[Te]=nn;var tn={get config(){return globalThis[Te]}};function rn(n,e,t){let r=n;for(let o of e)if(r&&typeof r=="object")r=r[o];else return t;return r===void 0?t:r}function on(n,e,t){let r=0;if(n!==e){let o=n.split("."),i=e.split("."),s=Math.max(o.length,i.length);for(let c=0;c<s;c++){let a=parseInt(o[c],10)||0,m=parseInt(i[c],10)||0;if(a>m){r=1;break}else if(a<m){r=-1;break}}}if(!t)return r;switch(t){case">":return r>0;case"<":return r<0;case"=":return r===0;case">=":return r>=0;case"<=":return r<=0;default:return!1}}var Ee=(r=>(r[r.System=1e3]="System",r[r.ErrorTrace=1001]="ErrorTrace",r[r.UserDefined=1002]="UserDefined",r))(Ee||{}),_e=(i=>(i.MiniGame="mini-game",i.MiniDrama="mini-drama",i.App="app",i.WebSDK="web-sdk",i.AppSDK="app-sdk",i))(_e||{}),he=(d=>(d[d.App=0]="App",d[d.H5=1]="H5",d[d.Weapp=2]="Weapp",d[d.Alipay=3]="Alipay",d[d.Gcash=4]="Gcash",d[d.Dana=5]="Dana",d[d.Umma=6]="Umma",d[d.WebSDK=1e3]="WebSDK",d[d.AppSDK=1001]="AppSDK",d[d.Other=9999]="Other",d))(he||{}),xe=["name","params"],sn=["name","type","location","target","extra","timestamp","userId"],an=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(n,e){return e.map(t=>{if(t==="params"&&n[t]){let r=n[t];return Object.keys(r).reduce((o,i)=>(o[i]=String(r[i]),o),{})}return n[t]})}function dn(n){let e=n.location?k(n.location,xe):null,t=n.target?k(n.target,xe):null;return k(w(f({},n),{location:e,target:t}),sn)}function ln(n){let e=n.events.map(r=>dn(r)),t=k(n.device,an);return[n.protocolVersion,e,t,n.project]}var te=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)}),cn=n=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(n);function re(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let n=Object.getOwnPropertyDescriptor(window,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}if(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),n&&n.get)return n.get.call(window);let e=Window.prototype,t=Object.getOwnPropertyDescriptor(e,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(n){return console.warn("Failed to get original localStorage, fallback to default implementation",n),localStorage}}re();var A={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let n=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Re=()=>A.isiOS?"iOS":A.isAndroid?"Android":A.isMac?"Mac":A.isFacebook?"Facebook":"PC",ve="device_id",be="advertising_id",oe=n=>(window.__joliboxLocalStorage__.getItem(n)||window.__joliboxLocalStorage__.setItem(n,te()),window.__joliboxLocalStorage__.getItem(n)),Ie=()=>{let e=new URLSearchParams(window.location.search).get("deviceId");return e||oe(ve)},Ce=()=>oe(be),mn=n=>n.charAt(0).toUpperCase()+n.slice(1),Ae=()=>{var e;let n=new URLSearchParams(window.location.search);return mn((e=n.get("utm_source"))!=null?e:"")||"JoliboxSDK"},un=n=>{let e="JoliboxWebSDK",t=Re(),r=navigator.language,o=Ie(),i=Ce();return`${e} (${Ae()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n||""}`};var E=class E{constructor(e){this.element=e,this.next=E.Undefined,this.prev=E.Undefined}};E.Undefined=new E(void 0);var l=E,M=class{constructor(){this._first=l.Undefined;this._last=l.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===l.Undefined}clear(){let e=this._first;for(;e!==l.Undefined;){let t=e.next;e.prev=l.Undefined,e.next=l.Undefined,e=t}this._first=l.Undefined,this._last=l.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new l(e);if(this._first===l.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==l.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==l.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==l.Undefined&&e.next!==l.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===l.Undefined&&e.next===l.Undefined?(this._first=l.Undefined,this._last=l.Undefined):e.next===l.Undefined?(this._last=this._last.prev,this._last.next=l.Undefined):e.prev===l.Undefined&&(this._first=this._first.next,this._first.prev=l.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==l.Undefined;)yield e.element,e=e.next}};var pn=0,_=class{constructor(e){this.value=e;this.id=pn++}},p=class{constructor(e){this.options=e;this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof _&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var i,s,c,a,m,d;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new _(t);this._listeners?this._listeners instanceof _?this._listeners=[this._listeners,o]:this._listeners.push(o):((s=(i=this.options)==null?void 0:i.onWillAddFirstListener)==null||s.call(i,this),this._listeners=o,(a=(c=this.options)==null?void 0:c.onDidFirstListener)==null||a.call(c,this)),(d=(m=this.options)==null?void 0:m.onDidAddListener)==null||d.call(m,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(i){r(i)}}fire(e){this._listeners&&(this._listeners instanceof _?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){var s;let r=(s=this.listeners.get(e))!=null?s:new p,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)r.fire(f({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new M,this.cachedEventQueue.set(e,o)),o.push({args:t})}}};var T={};ue(T,{None:()=>fn,filter:()=>yn,once:()=>we,toPromise:()=>gn});var fn=()=>{console.log("[Jolibox SDK] None Event")};function gn(n){return new Promise(e=>we(n)(e))}function we(n){return(e,t=null)=>{let r=!1;return n(i=>{if(!r)return r=!0,e.call(t,i)},null)}}function yn(n,e){return(r=>{let o,i={onWillAddFirstListener(){o=r(s.fire,s)}},s=new p(i);return s.event})((r,o=null)=>n(i=>e(i)&&r.call(o,i),null))}var ie=Symbol.for("Jolibox.hostEmitter"),Tn=()=>{let n=new h;return globalThis[ie]||(globalThis[ie]={on:n.on.bind(n),off:n.off.bind(n),emit:n.emit.bind(n)}),globalThis[ie]},xn=Tn();function se(n,e){let t=Math.min(n.length,e.length);for(let r=0;r<t;r++)Oe(n[r],e[r])}function Oe(n,e){if(L(e)){if(typeof n!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(S(e)){try{if(n instanceof e)return}catch(t){}if(!P(n)&&n.constructor===e||e.length===1&&e.call(void 0,n)===!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 y=class{constructor(){this._commands=new Map;this._onDidRegisterCommand=new p;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 o=[];for(let s of e.metadata.args)o.push(s.constraint);let i=e.handler;e.handler=function(...s){return se(s,o),i(...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}};y=O([b],y);var R=class{constructor(){this._onWillExecuteCommand=new p;this.onWillExecuteCommand=this._onWillExecuteCommand.event;this._onDidExecuteCommand=new p;this.onDidExecuteCommand=this._onDidExecuteCommand.event;this.registry=new y;this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=D(3e4)),this._starActivation}executeCommand(e,...t){return N(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),T.toPromise(T.filter(this.registry.onDidRegisterCommand,o=>o===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!!!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let o=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(o.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};R=O([b],R);var Ne=Symbol.for("Jolibox.commands");function En(){return typeof globalThis!="undefined"?globalThis[Ne]:void 0}function _n(n){typeof globalThis!="undefined"&&(globalThis[Ne]=n)}function hn(){let n=En();if(n)return n;let e=new y,t=new R,r={registerCommand(o,i,s){e.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return t.executeCommand(o,...i)},excuteCommandSync(o,...i){return t.executeCommandThowErr(o,...i)}};return _n(r),r}
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- var P=Object.defineProperty,ye=Object.defineProperties,Te=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var F=(n,e,t)=>e in n?P(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&F(n,t,e[t]);if(V)for(var t of V(e))_e.call(e,t)&&F(n,t,e[t]);return n},b=(n,e)=>ye(n,xe(e));var he=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})};var I=(n,e,t,r)=>{for(var o=r>1?void 0:r?Te(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&P(e,t,o),o};var C=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{c(t.next(a))}catch(m){o(m)}},s=a=>{try{c(t.throw(a))}catch(m){o(m)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);c((t=t.apply(n,e)).next())});if(typeof window!="undefined"&&!window.AbortController){let n=function(){this.signal=new e};n.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let t=new Event("abort");this.signal.dispatchEvent(t)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(t,r){this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(r)},e.prototype.removeEventListener=function(t,r){if(!this._eventListeners[t])return;let o=this._eventListeners[t].indexOf(r);o!==-1&&this._eventListeners[t].splice(o,1)},e.prototype.dispatchEvent=function(t){if(this._eventListeners[t.type])for(let r of this._eventListeners[t.type])r.call(this,t)},window.AbortController=n,window.AbortSignal=e}function H(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}function Qe(n){return new Promise(e=>setTimeout(e,n))}function Xe(n){return e=>new Promise((t,r)=>{n(b(f({},e),{success:t,fail(o){let i=new Error(o.errMsg);r(i)}}))})}function Ye(n){if(n)Promise.resolve().then(n);else return Promise.resolve()}var j=class{constructor(){this.state="pending";this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};function qe(){let n=[],e=!1,t=()=>C(this,null,function*(){let r=n.shift();if(r){e=!0;try{yield r()}finally{e=!1,t()}}});return r=>{n.push(r),e||t()}}function S(n){return typeof n=="string"}function tn(n){return Array.isArray(n)&&n.every(e=>S(e))}function Re(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}function rn(n){let e=Object.getPrototypeOf(Uint8Array);return typeof n=="object"&&n instanceof e}function on(n){return typeof n=="object"&&Array.isArray(n)}function sn(n){return typeof n=="number"&&!isNaN(n)}function an(n){return!!n&&typeof n[Symbol.iterator]=="function"}function dn(n){return n===!0||n===!1}function ve(n){return typeof n=="undefined"}function ln(n){return!k(n)}function k(n){return ve(n)||n===null}function M(n){return typeof n=="function"}function cn(n){return Re(n)&&M(n.then)}function A(n){let e=n,t=null,r=function(...o){return t||(t=new e(...o)),t};return r.prototype=e.prototype,r}function gn(n,e,t){if(typeof t!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let c=o[s],a=i[s],m=t(c,a,s,o,i);m!==void 0?o[s]=m:K(a)&&K(c)?o[s]=r(f({},c),a):Array.isArray(a)&&Array.isArray(c)?o[s]=[...c,...a]:o[s]=a}return o}return r(n,e)}function K(n){return n&&typeof n=="object"&&n.constructor===Object}function yn(n,e){if(Array.isArray(n))return n.concat(e)}function _n(n,e,t={}){let r=null,o,i,s,{leading:c=!1,trailing:a=!0}=t,m=()=>(s=n.apply(i,o),o=void 0,i=void 0,s),d=function(...ge){o=ge,i=this;let D=c&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,a&&!D&&m()},e),D)return m()};return d.cancel=()=>{r&&clearTimeout(r),r=null,o=i=void 0},d.flush=()=>{if(r)return clearTimeout(r),r=null,m()},d}var be=(a=>(a[a.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",a[a.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",a[a.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",a[a.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",a[a.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",a[a.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",a[a.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",a[a.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",a))(be||{}),h=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}},u=class extends h{constructor(){super(...arguments);this.kind="INTERNAL_ERROR"}},y=class extends h{constructor(){super(...arguments);this.kind="USER_ERROR"}},G=class extends y{constructor(){super(...arguments);this.name="USER_VALIDATE_ERROR"}},J=class extends y{constructor(){super(...arguments);this.name="USER_GLOBAL_ERROR";this.priority="P1"}},w=class extends y{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_CUSTOM_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},$=class extends y{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_FETCH_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},z=class extends y{constructor(){super(...arguments);this.name="USER_CALLBACK_ERROR"}},B=class extends u{constructor(){super(...arguments);this.name="INTERNAL_SCHEMA_PARSE_ERROR";this.priority="P0"}},W=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_FETCH_ERROR";this.priority="P0"}},Q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_EVAL_ERROR";this.priority="P0"}},X=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Y=class extends u{constructor(t,r,o,i){super(t);this.errNo=r;this.name="INTERNAL_APPLY_NATIVE_ERROR";this.errorType=o,this.errorCode=i}},q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_METHOD_ERROR"}},Z=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JSCORE_ERROR";this.priority="P0"}},ee=class extends u{constructor(){super(...arguments);this.name="INTERNAL_BUFFER_ERROR"}},ne=class extends u{constructor(t,r){super(t);this.message=t;this.name="INTERNAL_CONTEXT_ERROR";this.property=r}},te=class extends u{constructor(){super(...arguments);this.name="INTERNAL_GLOBAL_JS_ERROR";this.priority="P1"}},re=class extends h{constructor(t,r,o,i,s){super(t);this.message=t;this.code=r;this.kind="API_ERROR";this.name="API_ERROR";o&&(this.errorType=o),i!==void 0&&(this.stack=i),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},oe=class extends u{constructor(){super(...arguments);this.name="INTERNAL_METRIC_REPORT_ERROR"}},ie=class extends u{constructor(){super(...arguments);this.name="INTERNAL_REPORTER_ERROR"}};function Ie(n,e){return(...t)=>e(n,...t)}function An(n){return e=>Ie(e,function(t,...r){if(typeof t=="function")try{return t.apply(this,r)}catch(o){n(new w(`${o}`))}})}function R(n){return(...e)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[n])!=null?o:globalThis.console[n])(...e)}}var se={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:se});var ae=Symbol.for("Jolibox.canIUseMap"),Ce={};globalThis[ae]=Ce;var Un={get config(){return globalThis[ae]}};function Dn(n,e,t){let r=n;for(let o of e)if(r&&typeof r=="object")r=r[o];else return t;return r===void 0?t:r}function jn(n,e,t){let r=0;if(n!==e){let o=n.split("."),i=e.split("."),s=Math.max(o.length,i.length);for(let c=0;c<s;c++){let a=parseInt(o[c],10)||0,m=parseInt(i[c],10)||0;if(a>m){r=1;break}else if(a<m){r=-1;break}}}if(!t)return r;switch(t){case">":return r>0;case"<":return r<0;case"=":return r===0;case">=":return r>=0;case"<=":return r<=0;default:return!1}}var Ae=(r=>(r[r.System=1e3]="System",r[r.ErrorTrace=1001]="ErrorTrace",r[r.UserDefined=1002]="UserDefined",r))(Ae||{}),we=(i=>(i.MiniGame="mini-game",i.MiniDrama="mini-drama",i.App="app",i.WebSDK="web-sdk",i.AppSDK="app-sdk",i))(we||{}),Oe=(d=>(d[d.App=0]="App",d[d.H5=1]="H5",d[d.Weapp=2]="Weapp",d[d.Alipay=3]="Alipay",d[d.Gcash=4]="Gcash",d[d.Dana=5]="Dana",d[d.Umma=6]="Umma",d[d.WebSDK=1e3]="WebSDK",d[d.AppSDK=1001]="AppSDK",d[d.Other=9999]="Other",d))(Oe||{}),de=["name","params"],Ne=["name","type","location","target","extra","timestamp","userId"],Le=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(n,e){return e.map(t=>{if(t==="params"&&n[t]){let r=n[t];return Object.keys(r).reduce((o,i)=>(o[i]=String(r[i]),o),{})}return n[t]})}function Pe(n){let e=n.location?O(n.location,de):null,t=n.target?O(n.target,de):null;return O(b(f({},n),{location:e,target:t}),Ne)}function Gn(n){let e=n.events.map(r=>Pe(r)),t=O(n.device,Le);return[n.protocolVersion,e,t,n.project]}var le=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)}),Bn=n=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(n);function ce(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let n=Object.getOwnPropertyDescriptor(window,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}if(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),n&&n.get)return n.get.call(window);let e=Window.prototype,t=Object.getOwnPropertyDescriptor(e,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(n){return console.warn("Failed to get original localStorage, fallback to default implementation",n),localStorage}}ce();var N={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let n=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Se=()=>N.isiOS?"iOS":N.isAndroid?"Android":N.isMac?"Mac":N.isFacebook?"Facebook":"PC",ke="device_id",Me="advertising_id",me=n=>(window.__joliboxLocalStorage__.getItem(n)||window.__joliboxLocalStorage__.setItem(n,le()),window.__joliboxLocalStorage__.getItem(n)),Ue=()=>me(ke),De=()=>me(Me),Ve=n=>n.charAt(0).toUpperCase()+n.slice(1),Fe=()=>{var e;let n=new URLSearchParams(window.location.search);return Ve((e=n.get("utm_source"))!=null?e:"")||"JoliboxSDK"},et=n=>{let e="JoliboxWebSDK",t=Se(),r=navigator.language,o=Ue(),i=De();return`${e} (${Fe()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n||""}`};var T=class T{constructor(e){this.element=e,this.next=T.Undefined,this.prev=T.Undefined}};T.Undefined=new T(void 0);var l=T,L=class{constructor(){this._first=l.Undefined;this._last=l.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===l.Undefined}clear(){let e=this._first;for(;e!==l.Undefined;){let t=e.next;e.prev=l.Undefined,e.next=l.Undefined,e=t}this._first=l.Undefined,this._last=l.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new l(e);if(this._first===l.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==l.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==l.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==l.Undefined&&e.next!==l.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===l.Undefined&&e.next===l.Undefined?(this._first=l.Undefined,this._last=l.Undefined):e.next===l.Undefined?(this._last=this._last.prev,this._last.next=l.Undefined):e.prev===l.Undefined&&(this._first=this._first.next,this._first.prev=l.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==l.Undefined;)yield e.element,e=e.next}};var je=0,x=class{constructor(e){this.value=e;this.id=je++}},p=class{constructor(e){this.options=e;this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var i,s,c,a,m,d;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new x(t);this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,o]:this._listeners.push(o):((s=(i=this.options)==null?void 0:i.onWillAddFirstListener)==null||s.call(i,this),this._listeners=o,(a=(c=this.options)==null?void 0:c.onDidFirstListener)==null||a.call(c,this)),(d=(m=this.options)==null?void 0:m.onDidAddListener)==null||d.call(m,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(i){r(i)}}fire(e){this._listeners&&(this._listeners instanceof x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},v=class{constructor(){this.listeners=new Map;this.listerHandlerMap=new WeakMap;this.cachedEventQueue=new Map}on(e,t){var s;let r=(s=this.listeners.get(e))!=null?s:new p,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)r.fire(f({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new L,this.cachedEventQueue.set(e,o)),o.push({args:t})}}};var E={};he(E,{None:()=>He,filter:()=>Ge,once:()=>ue,toPromise:()=>Ke});var He=()=>{console.log("[Jolibox SDK] None Event")};function Ke(n){return new Promise(e=>ue(n)(e))}function ue(n){return(e,t=null)=>{let r=!1;return n(i=>{if(!r)return r=!0,e.call(t,i)},null)}}function Ge(n,e){return(r=>{let o,i={onWillAddFirstListener(){o=r(s.fire,s)}},s=new p(i);return s.event})((r,o=null)=>n(i=>e(i)&&r.call(o,i),null))}var U=Symbol.for("Jolibox.hostEmitter"),Je=()=>{let n=new v;return globalThis[U]||(globalThis[U]={on:n.on.bind(n),off:n.off.bind(n),emit:n.emit.bind(n)}),globalThis[U]},Nt=Je();function pe(n,e){let t=Math.min(n.length,e.length);for(let r=0;r<t;r++)$e(n[r],e[r])}function $e(n,e){if(S(e)){if(typeof n!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(M(e)){try{if(n instanceof e)return}catch(t){}if(!k(n)&&n.constructor===e||e.length===1&&e.call(void 0,n)===!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 g=class{constructor(){this._commands=new Map;this._onDidRegisterCommand=new p;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 o=[];for(let s of e.metadata.args)o.push(s.constraint);let i=e.handler;e.handler=function(...s){return pe(s,o),i(...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}};g=I([A],g);var _=class{constructor(){this._onWillExecuteCommand=new p;this.onWillExecuteCommand=this._onWillExecuteCommand.event;this._onDidExecuteCommand=new p;this.onDidExecuteCommand=this._onDidExecuteCommand.event;this.registry=new g;this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=H(3e4)),this._starActivation}executeCommand(e,...t){return C(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),E.toPromise(E.filter(this.registry.onDidRegisterCommand,o=>o===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!!!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let o=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(o.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};_=I([A],_);var fe=Symbol.for("Jolibox.commands");function ze(){return typeof globalThis!="undefined"?globalThis[fe]:void 0}function Be(n){typeof globalThis!="undefined"&&(globalThis[fe]=n)}function ir(){let n=ze();if(n)return n;let e=new g,t=new _,r={registerCommand(o,i,s){e.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return t.executeCommand(o,...i)},excuteCommandSync(o,...i){return t.executeCommandThowErr(o,...i)}};return Be(r),r}export{Me as ADVERTISING_ID,re as APIError,h as BaseError,ke as DEVICE_ID,j as Deferred,Oe as EPlatform,we as EProject,v as EventEmitter,Ae as EventType,E as EventUtils,Y as InternalApplyNativeError,ee as InternalBufferError,ne as InternalContextError,u as InternalError,te as InternalGlobalJSError,q as InternalInvokeMethodError,X as InternalInvokeNativeError,Z as InternalJSCoreNotFoundError,Q as InternalJSModuleEvalError,W as InternalJSModuleFetchError,oe as InternalMetricReportError,ie as InternalReporterError,B as InternalSchemaParseError,be as LoadScriptCode,A as Singleton,w as UserCustomError,y as UserError,$ as UserFetchError,z as UserFunctionEvalError,J as UserGlobalError,G as UserValidateError,Un as canIUseConfig,jn as compareVersion,ir as createCommands,qe as createRunTaskQueue,_n as debounce,Dn as get,De as getAdvertisingId,Ue as getDeviceId,ce as getOriginalLocalStorage,Se as getPlatform,me as getStorage,Fe as getUtmSource,Nt as hostEmitter,on as isArray,dn as isBoolean,ln as isDefined,M as isFunction,an as isIterable,sn as isNumber,Re as isObject,cn as isPromiseLike,S as isString,tn as isStringArray,rn as isTypedArray,ve as isUndefined,k as isUndefinedOrNull,Bn as isValidUUIDV4,se as logger,yn as mergeArray,gn as mergeWith,Ye as microTask,N as platform,Xe as promisifyAPI,Gn as serializeEventPackage,Qe as sleep,H as timeout,le as uuidv4,$e as validateConstraint,pe as validateConstraints,An as wrapUserFunction,et as xUserAgent};
1
+ var P=Object.defineProperty,ye=Object.defineProperties,Te=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var F=(n,e,t)=>e in n?P(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&F(n,t,e[t]);if(V)for(var t of V(e))_e.call(e,t)&&F(n,t,e[t]);return n},b=(n,e)=>ye(n,xe(e));var he=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})};var I=(n,e,t,r)=>{for(var o=r>1?void 0:r?Te(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&P(e,t,o),o};var C=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{c(t.next(a))}catch(m){o(m)}},s=a=>{try{c(t.throw(a))}catch(m){o(m)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);c((t=t.apply(n,e)).next())});if(typeof window!="undefined"&&!window.AbortController){let n=function(){this.signal=new e};n.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let t=new Event("abort");this.signal.dispatchEvent(t)};let e=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(e.prototype,"aborted",{get:function(){return this._aborted}}),e.prototype.addEventListener=function(t,r){this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(r)},e.prototype.removeEventListener=function(t,r){if(!this._eventListeners[t])return;let o=this._eventListeners[t].indexOf(r);o!==-1&&this._eventListeners[t].splice(o,1)},e.prototype.dispatchEvent=function(t){if(this._eventListeners[t.type])for(let r of this._eventListeners[t.type])r.call(this,t)},window.AbortController=n,window.AbortSignal=e}function H(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}function Qe(n){return new Promise(e=>setTimeout(e,n))}function qe(n){return e=>new Promise((t,r)=>{n(b(f({},e),{success:t,fail(o){let i=new Error(o.errMsg);r(i)}}))})}function Xe(n){if(n)Promise.resolve().then(n);else return Promise.resolve()}var j=class{constructor(){this.state="pending";this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};function Ye(){let n=[],e=!1,t=()=>C(this,null,function*(){let r=n.shift();if(r){e=!0;try{yield r()}finally{e=!1,t()}}});return r=>{n.push(r),e||t()}}function S(n){return typeof n=="string"}function tn(n){return Array.isArray(n)&&n.every(e=>S(e))}function Re(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}function rn(n){let e=Object.getPrototypeOf(Uint8Array);return typeof n=="object"&&n instanceof e}function on(n){return typeof n=="object"&&Array.isArray(n)}function sn(n){return typeof n=="number"&&!isNaN(n)}function an(n){return!!n&&typeof n[Symbol.iterator]=="function"}function dn(n){return n===!0||n===!1}function ve(n){return typeof n=="undefined"}function ln(n){return!k(n)}function k(n){return ve(n)||n===null}function M(n){return typeof n=="function"}function cn(n){return Re(n)&&M(n.then)}function A(n){let e=n,t=null,r=function(...o){return t||(t=new e(...o)),t};return r.prototype=e.prototype,r}function gn(n,e,t){if(typeof t!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function r(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let c=o[s],a=i[s],m=t(c,a,s,o,i);m!==void 0?o[s]=m:K(a)&&K(c)?o[s]=r(f({},c),a):Array.isArray(a)&&Array.isArray(c)?o[s]=[...c,...a]:o[s]=a}return o}return r(n,e)}function K(n){return n&&typeof n=="object"&&n.constructor===Object}function yn(n,e){if(Array.isArray(n))return n.concat(e)}function _n(n,e,t={}){let r=null,o,i,s,{leading:c=!1,trailing:a=!0}=t,m=()=>(s=n.apply(i,o),o=void 0,i=void 0,s),d=function(...ge){o=ge,i=this;let D=c&&!r;if(r&&clearTimeout(r),r=setTimeout(()=>{r=null,a&&!D&&m()},e),D)return m()};return d.cancel=()=>{r&&clearTimeout(r),r=null,o=i=void 0},d.flush=()=>{if(r)return clearTimeout(r),r=null,m()},d}var be=(a=>(a[a.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",a[a.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",a[a.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",a[a.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",a[a.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",a[a.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",a[a.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",a[a.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",a))(be||{}),h=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}},u=class extends h{constructor(){super(...arguments);this.kind="INTERNAL_ERROR"}},y=class extends h{constructor(){super(...arguments);this.kind="USER_ERROR"}},G=class extends y{constructor(){super(...arguments);this.name="USER_VALIDATE_ERROR"}},J=class extends y{constructor(){super(...arguments);this.name="USER_GLOBAL_ERROR";this.priority="P1"}},w=class extends y{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_CUSTOM_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},$=class extends y{constructor(t,r,o){super(t);this.message=t;this.errNo=r;this.name="USER_FETCH_ERROR";this.errMsg=t,o&&(this.extra=Object.assign({},this.extra,o))}},z=class extends y{constructor(){super(...arguments);this.name="USER_CALLBACK_ERROR"}},B=class extends u{constructor(){super(...arguments);this.name="INTERNAL_SCHEMA_PARSE_ERROR";this.priority="P0"}},W=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_FETCH_ERROR";this.priority="P0"}},Q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JS_MODULE_EVAL_ERROR";this.priority="P0"}},q=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},X=class extends u{constructor(t,r,o,i){super(t);this.errNo=r;this.name="INTERNAL_APPLY_NATIVE_ERROR";this.errorType=o,this.errorCode=i}},Y=class extends u{constructor(){super(...arguments);this.name="INTERNAL_INVOKE_METHOD_ERROR"}},Z=class extends u{constructor(){super(...arguments);this.name="INTERNAL_JSCORE_ERROR";this.priority="P0"}},ee=class extends u{constructor(){super(...arguments);this.name="INTERNAL_BUFFER_ERROR"}},ne=class extends u{constructor(t,r){super(t);this.message=t;this.name="INTERNAL_CONTEXT_ERROR";this.property=r}},te=class extends u{constructor(){super(...arguments);this.name="INTERNAL_GLOBAL_JS_ERROR";this.priority="P1"}},re=class extends h{constructor(t,r,o,i,s){super(t);this.message=t;this.code=r;this.kind="API_ERROR";this.name="API_ERROR";o&&(this.errorType=o),i!==void 0&&(this.stack=i),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},oe=class extends u{constructor(){super(...arguments);this.name="INTERNAL_METRIC_REPORT_ERROR"}},ie=class extends u{constructor(){super(...arguments);this.name="INTERNAL_REPORTER_ERROR"}};function Ie(n,e){return(...t)=>e(n,...t)}function An(n){return e=>Ie(e,function(t,...r){if(typeof t=="function")try{return t.apply(this,r)}catch(o){n(new w(`${o}`))}})}function R(n){return(...e)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[n])!=null?o:globalThis.console[n])(...e)}}var se={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:se});var ae=Symbol.for("Jolibox.canIUseMap"),Ce={};globalThis[ae]=Ce;var Un={get config(){return globalThis[ae]}};function Dn(n,e,t){let r=n;for(let o of e)if(r&&typeof r=="object")r=r[o];else return t;return r===void 0?t:r}function jn(n,e,t){let r=0;if(n!==e){let o=n.split("."),i=e.split("."),s=Math.max(o.length,i.length);for(let c=0;c<s;c++){let a=parseInt(o[c],10)||0,m=parseInt(i[c],10)||0;if(a>m){r=1;break}else if(a<m){r=-1;break}}}if(!t)return r;switch(t){case">":return r>0;case"<":return r<0;case"=":return r===0;case">=":return r>=0;case"<=":return r<=0;default:return!1}}var Ae=(r=>(r[r.System=1e3]="System",r[r.ErrorTrace=1001]="ErrorTrace",r[r.UserDefined=1002]="UserDefined",r))(Ae||{}),we=(i=>(i.MiniGame="mini-game",i.MiniDrama="mini-drama",i.App="app",i.WebSDK="web-sdk",i.AppSDK="app-sdk",i))(we||{}),Oe=(d=>(d[d.App=0]="App",d[d.H5=1]="H5",d[d.Weapp=2]="Weapp",d[d.Alipay=3]="Alipay",d[d.Gcash=4]="Gcash",d[d.Dana=5]="Dana",d[d.Umma=6]="Umma",d[d.WebSDK=1e3]="WebSDK",d[d.AppSDK=1001]="AppSDK",d[d.Other=9999]="Other",d))(Oe||{}),de=["name","params"],Ne=["name","type","location","target","extra","timestamp","userId"],Le=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(n,e){return e.map(t=>{if(t==="params"&&n[t]){let r=n[t];return Object.keys(r).reduce((o,i)=>(o[i]=String(r[i]),o),{})}return n[t]})}function Pe(n){let e=n.location?O(n.location,de):null,t=n.target?O(n.target,de):null;return O(b(f({},n),{location:e,target:t}),Ne)}function Gn(n){let e=n.events.map(r=>Pe(r)),t=O(n.device,Le);return[n.protocolVersion,e,t,n.project]}var le=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)}),Bn=n=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(n);function ce(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let n=Object.getOwnPropertyDescriptor(window,"localStorage");if(n&&n.get){let r=n.get.call(window);return window.__joliboxLocalStorage__=r,r}if(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),n&&n.get)return n.get.call(window);let e=Window.prototype,t=Object.getOwnPropertyDescriptor(e,"localStorage");if(t&&t.get){let r=t.get.call(window);return window.__joliboxLocalStorage__=r,r}return localStorage}catch(n){return console.warn("Failed to get original localStorage, fallback to default implementation",n),localStorage}}ce();var N={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let n=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Se=()=>N.isiOS?"iOS":N.isAndroid?"Android":N.isMac?"Mac":N.isFacebook?"Facebook":"PC",ke="device_id",Me="advertising_id",me=n=>(window.__joliboxLocalStorage__.getItem(n)||window.__joliboxLocalStorage__.setItem(n,le()),window.__joliboxLocalStorage__.getItem(n)),Ue=()=>{let e=new URLSearchParams(window.location.search).get("deviceId");return e||me(ke)},De=()=>me(Me),Ve=n=>n.charAt(0).toUpperCase()+n.slice(1),Fe=()=>{var e;let n=new URLSearchParams(window.location.search);return Ve((e=n.get("utm_source"))!=null?e:"")||"JoliboxSDK"},et=n=>{let e="JoliboxWebSDK",t=Se(),r=navigator.language,o=Ue(),i=De();return`${e} (${Fe()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n||""}`};var T=class T{constructor(e){this.element=e,this.next=T.Undefined,this.prev=T.Undefined}};T.Undefined=new T(void 0);var l=T,L=class{constructor(){this._first=l.Undefined;this._last=l.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===l.Undefined}clear(){let e=this._first;for(;e!==l.Undefined;){let t=e.next;e.prev=l.Undefined,e.next=l.Undefined,e=t}this._first=l.Undefined,this._last=l.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new l(e);if(this._first===l.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==l.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==l.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==l.Undefined&&e.next!==l.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===l.Undefined&&e.next===l.Undefined?(this._first=l.Undefined,this._last=l.Undefined):e.next===l.Undefined?(this._last=this._last.prev,this._last.next=l.Undefined):e.prev===l.Undefined&&(this._first=this._first.next,this._first.prev=l.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==l.Undefined;)yield e.element,e=e.next}};var je=0,x=class{constructor(e){this.value=e;this.id=je++}},p=class{constructor(e){this.options=e;this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var i,s,c,a,m,d;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new x(t);this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,o]:this._listeners.push(o):((s=(i=this.options)==null?void 0:i.onWillAddFirstListener)==null||s.call(i,this),this._listeners=o,(a=(c=this.options)==null?void 0:c.onDidFirstListener)==null||a.call(c,this)),(d=(m=this.options)==null?void 0:m.onDidAddListener)==null||d.call(m,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(i){r(i)}}fire(e){this._listeners&&(this._listeners instanceof x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},v=class{constructor(){this.listeners=new Map;this.listerHandlerMap=new WeakMap;this.cachedEventQueue=new Map}on(e,t){var s;let r=(s=this.listeners.get(e))!=null?s:new p,o=c=>t(...c.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)r.fire(f({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new L,this.cachedEventQueue.set(e,o)),o.push({args:t})}}};var E={};he(E,{None:()=>He,filter:()=>Ge,once:()=>ue,toPromise:()=>Ke});var He=()=>{console.log("[Jolibox SDK] None Event")};function Ke(n){return new Promise(e=>ue(n)(e))}function ue(n){return(e,t=null)=>{let r=!1;return n(i=>{if(!r)return r=!0,e.call(t,i)},null)}}function Ge(n,e){return(r=>{let o,i={onWillAddFirstListener(){o=r(s.fire,s)}},s=new p(i);return s.event})((r,o=null)=>n(i=>e(i)&&r.call(o,i),null))}var U=Symbol.for("Jolibox.hostEmitter"),Je=()=>{let n=new v;return globalThis[U]||(globalThis[U]={on:n.on.bind(n),off:n.off.bind(n),emit:n.emit.bind(n)}),globalThis[U]},Nt=Je();function pe(n,e){let t=Math.min(n.length,e.length);for(let r=0;r<t;r++)$e(n[r],e[r])}function $e(n,e){if(S(e)){if(typeof n!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(M(e)){try{if(n instanceof e)return}catch(t){}if(!k(n)&&n.constructor===e||e.length===1&&e.call(void 0,n)===!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 g=class{constructor(){this._commands=new Map;this._onDidRegisterCommand=new p;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 o=[];for(let s of e.metadata.args)o.push(s.constraint);let i=e.handler;e.handler=function(...s){return pe(s,o),i(...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}};g=I([A],g);var _=class{constructor(){this._onWillExecuteCommand=new p;this.onWillExecuteCommand=this._onWillExecuteCommand.event;this._onDidExecuteCommand=new p;this.onDidExecuteCommand=this._onDidExecuteCommand.event;this.registry=new g;this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=H(3e4)),this._starActivation}executeCommand(e,...t){return C(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),E.toPromise(E.filter(this.registry.onDidRegisterCommand,o=>o===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!!!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let o=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(o.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};_=I([A],_);var fe=Symbol.for("Jolibox.commands");function ze(){return typeof globalThis!="undefined"?globalThis[fe]:void 0}function Be(n){typeof globalThis!="undefined"&&(globalThis[fe]=n)}function ir(){let n=ze();if(n)return n;let e=new g,t=new _,r={registerCommand(o,i,s){e.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return t.executeCommand(o,...i)},excuteCommandSync(o,...i){return t.executeCommandThowErr(o,...i)}};return Be(r),r}export{Me as ADVERTISING_ID,re as APIError,h as BaseError,ke as DEVICE_ID,j as Deferred,Oe as EPlatform,we as EProject,v as EventEmitter,Ae as EventType,E as EventUtils,X as InternalApplyNativeError,ee as InternalBufferError,ne as InternalContextError,u as InternalError,te as InternalGlobalJSError,Y as InternalInvokeMethodError,q as InternalInvokeNativeError,Z as InternalJSCoreNotFoundError,Q as InternalJSModuleEvalError,W as InternalJSModuleFetchError,oe as InternalMetricReportError,ie as InternalReporterError,B as InternalSchemaParseError,be as LoadScriptCode,A as Singleton,w as UserCustomError,y as UserError,$ as UserFetchError,z as UserFunctionEvalError,J as UserGlobalError,G as UserValidateError,Un as canIUseConfig,jn as compareVersion,ir as createCommands,Ye as createRunTaskQueue,_n as debounce,Dn as get,De as getAdvertisingId,Ue as getDeviceId,ce as getOriginalLocalStorage,Se as getPlatform,me as getStorage,Fe as getUtmSource,Nt as hostEmitter,on as isArray,dn as isBoolean,ln as isDefined,M as isFunction,an as isIterable,sn as isNumber,Re as isObject,cn as isPromiseLike,S as isString,tn as isStringArray,rn as isTypedArray,ve as isUndefined,k as isUndefinedOrNull,Bn as isValidUUIDV4,se as logger,yn as mergeArray,gn as mergeWith,Xe as microTask,N as platform,qe as promisifyAPI,Gn as serializeEventPackage,Qe as sleep,H as timeout,le as uuidv4,$e as validateConstraint,pe as validateConstraints,An as wrapUserFunction,et as xUserAgent};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jolibox/common",
3
3
  "description": "This project is common utils for both sdk & implementation",
4
- "version": "1.1.13",
4
+ "version": "1.1.14-beta.2",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
- "@jolibox/types": "1.1.13"
14
+ "@jolibox/types": "1.1.14-beta.2"
15
15
  },
16
16
  "devDependencies": {
17
17
  "typescript": "5.7.3",