@jolibox/native-bridge 1.2.8 → 1.2.9-beta.9

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.js CHANGED
@@ -1 +1 @@
1
- var je=Object.defineProperty,$e=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))ce.call(t,r)&&ae(e,r,t[r]);if(D)for(var r of D(t))ue.call(t,r)&&ae(e,r,t[r]);return e},le=(e,t)=>$e(e,He(t));var de=(e,t)=>{var r={};for(var n in e)ce.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&ue.call(e,n)&&(r[n]=e[n]);return r};var E=(e,t,r)=>new Promise((n,i)=>{var s=u=>{try{o(r.next(u))}catch(c){i(c)}},a=u=>{try{o(r.throw(u))}catch(c){i(c)}},o=u=>u.done?n(u.value):Promise.resolve(u.value).then(s,a);o((r=r.apply(e,t)).next())});function Ve(e){return!!(e!=null&&e.__nativeBuffers__)}var Ge=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};function A(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!Ve(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let i;n.value?i=n.value:n.base64&&(i=Ge(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}var Ke=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};function ge(e={},t=!1){let r=e,n=[];for(let[i,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let a=t?{value:s,key:i}:{base64:Ke(s),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}var pe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var We=(e,t)=>{for(var r in t)pe(e,r,{get:t[r],enumerable:!0})},fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?ze(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&pe(t,r,i),i},Ye=(e,t,r)=>new Promise((n,i)=>{var s=u=>{try{o(r.next(u))}catch(c){i(c)}},a=u=>{try{o(r.throw(u))}catch(c){i(c)}},o=u=>u.done?n(u.value):Promise.resolve(u.value).then(s,a);o((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Qe(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}var ve=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 Q(e){return typeof e=="string"}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function X(e){return typeof e=="number"&&!isNaN(e)}function Xe(e){return typeof e=="undefined"}function Ze(e){return Xe(e)||e===null}function ye(e){return typeof e=="function"}function be(e){return _(e)&&ye(e.then)}function _e(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}var et=(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))(et||{}),tt=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}},L=class extends tt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Se=class extends L{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}};var Ne=class extends L{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}};var Ee=class extends L{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}};var U=class extends L{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};function k(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var x={log:k("log"),warn:k("warn"),info:k("info"),error:k("error"),debug:k("debug")};Object.assign(globalThis,{logger:x});var me=Symbol.for("Jolibox.canIUseMap"),rt={};globalThis[me]||(globalThis[me]=rt);function Re(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}var G=Symbol.for("Jolibox.canIUseMap.native"),nt={};globalThis[G]||(globalThis[G]=nt);var q={get config(){return globalThis[G]}};var it=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(it||{}),st=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(st||{}),ot=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(ot||{});function at(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}at();var R=typeof window=="undefined",xe=()=>!R&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Tt={isiOS:!R&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!R&&navigator.userAgent.includes("Android"),isMac:!R&&navigator.userAgent.includes("Mac"),isFacebook:!R&&navigator.userAgent.includes("FB_IAB"),isPC:!R&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")};var K=class z{constructor(t){this.element=t,this.next=z.Undefined,this.prev=z.Undefined}};K.Undefined=new K(void 0);var m=K,ct=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let 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 n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},ut=0,O=class{constructor(e){this.value=e,this.id=ut++}},C=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof O&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,s,a,o,u;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new O(t);return this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(u=(o=this.options)==null?void 0:o.onDidAddListener)==null||u.call(o,this),this._size++,()=>{var l,d,g,h;if(!this._disposed){if(this._listeners instanceof O)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(d=(l=this.options)==null?void 0:l.onDidRemoveLastListener)==null||d.call(l));else if(this._listeners){let f=this._listeners.indexOf(c);f>=0&&(this._listeners.splice(f,1),this._size--,this._size===0&&((h=(g=this.options)==null?void 0:g.onDidRemoveLastListener)==null||h.call(g)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof O?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},J=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new C,s=u=>t(...u.args),a=i.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,i);let o=this.cachedEventQueue.get(e);if(o&&r)for(let u of o)t(...u.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new ct,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},W={};We(W,{None:()=>lt,filter:()=>gt,once:()=>Te,toPromise:()=>dt});var lt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function dt(e){return new Promise(t=>Te(e)(t))}function Te(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function gt(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(s.fire,s)}},s=new C(i);return s.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}var V=Symbol.for("Jolibox.hostEmitter"),mt=()=>{let e=new J;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[V]},wt=mt();function ht(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)pt(e[n],t[n])}function pt(e,t){if(Q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(ye(t)){try{if(e instanceof t)return}catch(r){}if(!Ze(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 Y=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new C,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return ht(i,r),n(...i)}}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=fe([_e],Y);var he=class{constructor(){this._onWillExecuteCommand=new C,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new C,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Y,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Qe(3e4)),this._starActivation}executeCommand(e,...t){return Ye(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),W.toPromise(W.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};he=fe([_e],he);var At=Symbol.for("Jolibox.commands");I("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});I("requestProductDetailsAsync",{version:102e4});I("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});function I(e,t){if(q.config[e]){x.warn(`[can i use] ${e} already registered`);return}q.config[e]=v({},t)}var ft=(e,t)=>{function r(i){var d;let[s,...a]=i.split(":");if(!s)return!1;let o=q.config[s];if(!o)return!1;let u=(d=t==null?void 0:t())!=null?d:"";if(o.platforms&&!o.platforms.includes(u))return!1;let c=o.version;if(typeof c!="number")return!1;let l=e();return typeof l!="number"||l<c?!1:a.length===0?!0:n(o,a,l)||n(o.properties,a,l)}function n(i,s,a){if(!i)return!1;let o=Re(i,s);if(!o)return!1;if(_(o)){let u=o.version;return X(u)?typeof a=="number"&&a>=u:!0}return X(o)?typeof a=="number"&&a>=o:o===!0}return{canIUseNative:r}};function P(e,t){return`[${e}]:${t}`}var we=()=>xe();var S="custom_event_";var Ae=[],ke=[],Oe=["env","createRequestTask","login"],B="__batch_event__",Ce="__native_batch_event__";var vt=e=>e==="pv"?e:"default",N=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:i,tagNameOrder:s,metricName:a,type:o}=t;this.reporter=r,this.interval=n,this.eventName=i,this.tagNameOrder=s,this.metricName=a,this.type=vt(o)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,i,s,a)=>{let o=i.shift();if(o){let u=a[o];n[u]||(n[u]={}),r(n[u],i,s,a)}else n[s]||(n[s]=[]),n[s].push(a[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(i,s,a,o)=>{let u=s.shift();if(!u&&_(o))throw new U(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(u){let c=[];if(_(o))c.push(...Object.keys(o));else if(Q(o)){if(s.length>0)throw new U(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);c.push(o)}else throw new U(`expected metric value to be a string, but got a(n) ${typeof o}, ${JSON.stringify(n)}`);c.forEach(l=>{i[l]||(i[l]={});let d=_(o)?o[l]:o;r(i[l],[...s],a,d)})}else i[a]?i[a]++:i[a]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Ie=!1,Z,ee,te;function Pe(e,t){Ie||(Z=new N({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),ee=new N({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),te=new N({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Z.flush(),ee.flush(),te.flush()}),Ie=!0);function r(i){var T,w;let{method:s,args:a,startTime:o,isForeground:u,errMsg:c=`${s}:fail no errMsg`,errNo:l=0,__timing:d={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:g,invokeCallback:h}=d,f=(w=(T=c.match(/\S:(\S+)\s?/))==null?void 0:T[1])!=null?w:"fail";Z.report({status:f,method:n(s,a),errNo:`${l}`,errMsg:c,isForeground:u,duration:Date.now()-o}),o&&g&&h&&(ee.report({status:f,method:s,isForeground:u,duration:Number((g-o).toFixed(3))}),te.report({status:f,method:s,isForeground:u,duration:Number((Date.now()-h).toFixed(3))}))}function n(i,s){return(i==="callHostMethod"||i==="callHostMethodSync")&&s!=null&&s.method?`${i}-${s.method}`:i}return r}var re=[],yt=!1,ne=Symbol.for("Jolibox.invokeResolverInstance"),bt=new Map;globalThis[ne]||(globalThis[ne]=bt);var _t={get resolveMap(){return globalThis[ne]}};function De(e,t){let r=0,n=!0,i=_t.resolveMap,s=Pe(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,re.forEach(g=>E(this,[g],function*({method:c,args:l,resolve:d}){let h=yield o(c,l);d(h)})),re.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let g=A(l);d(g),i.delete(Number(c))},o=(c,l)=>{var se,oe;let d=Date.now(),g=`${n}`;r+=1;let h=new ve;if(i.set(r,h.resolve),!n&&ke.includes(c))return new Promise(b=>{re.push({method:c,args:l,resolve:b})});let T=le(v({},{method:c,startTime:d,args:l,isForeground:g}),{invokeType:"js-bridge"}),w=!yt&&Ae.includes(c),$=ge(l,w),H=w?$:JSON.stringify($),p;if(c.endsWith("Sync")||Oe.includes(c)?p=(se=e.call)==null?void 0:se.call(e,c,$,r):typeof H=="string"?p=e.invoke(c,H,r):p=(oe=e.call)==null?void 0:oe.call(e,c,H,r),p){try{typeof p=="string"&&(p=JSON.parse(p)),p=A(p)}catch(b){x.error(b)}return i.delete(r),p.errorCode&&(p.errorCode=P(c,p.errorCode)),s(v(v({},T),p)),p}return c.endsWith("Sync")&&i.delete(r),h.promise.then(b=>(b.errorCode&&(b.errorCode=P(c,b.errorCode)),s(v(v({},T),b)),b))};return{invokeNative:o,applyNative:(c,l)=>{let d=o(c,l);return be(d)?d.then(g=>Me(c,g)):Me(c,d)},invokeHandler:a}}function Me(e,t){if(!_(t)){x.warn(`[Jolibox SDK]${e} no response value`);return}let o=t,{errMsg:r,errNo:n,errorType:i,errorCode:s}=o,a=de(o,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Ne(r,n,i,s);return a}var F=Symbol.for("Jolibox.subscribeInstance");function Le(e){if(globalThis[F])return globalThis[F];let t=new J,r=new J,n=new N({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[F]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,s,a){let o=A(s),u;if(o.__extra){u=o.params;let{type:c,startTime:l}=o.__extra;n.report({type:c,event:i,duration:Date.now()-l})}else u=o;if(i===B){u.forEach(l=>{let[d,g]=l;try{r.emit(d.slice(S.length),g,a)}catch(h){}});return}if(i.startsWith(S)){r.emit(i.slice(S.length),u,a);return}t.emit(i,u,a)}},globalThis[F]}function Ue(e){let t=new Map,r=new Map,n,i;return{publish:(o,u,c,l)=>{if(l){let g=c!==void 0?c==="*"?"*":[c]:void 0;e.publish(`${S}${o}`,u,g);return}n||(n=Promise.resolve().then(()=>{t.forEach((g,h)=>{try{let f=h!==void 0?h==="*"?"*":[h]:void 0;e.publish(B,g,f)}catch(f){}}),n=void 0,t.clear()}));let d=t.get(c);d||(d=[],t.set(c,d)),d.push([`${S}${o}`,u])},emitNative:(o,u,c,l)=>{if(l){let g=c!==void 0?c==="*"?"*":[c]:void 0;e.publish(o,u,g),console.log("emitNative",o,u,g);return}i||(i=Promise.resolve().then(()=>{r.forEach((g,h)=>{try{let f=h!==void 0?h==="*"?"*":[h]:void 0;e.publish(Ce,g,f)}catch(f){}}),i=void 0,r.clear()}));let d=r.get(c);d||(d=[],r.set(c,d)),d.push([o,u])}}}function ie(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:s}=Le(e),{invokeNative:a,invokeHandler:o,applyNative:u}=De(e,r),{publish:c,emitNative:l}=Ue(e);return{invokeHandler:o,subscribeHandler:t,applyNative:u,invokeNative:a,onNative:r,offNative:n,emitNative:l,publish:c,subscribe:i,unsubscribe:s}}function j(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var M,y={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){y.trigger=e},onDoExit(e){y.exit=e},onDoBackPress(e){y.backPress=e}},qe=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new Se("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{y.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>E(void 0,null,function*(){let s=yield y.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:s})});M={onDocumentReady:t,doExit:r,invoke(i,s,a){e.invoke.postMessage({event:i,paramsString:s,callbackId:a})},publish(i,s,a){let o=j(s,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(o),webviewIds:a}))},call(i,s,a){let o=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(s),callbackId:a}));if(o)return JSON.parse(o)}};let n={onDocumentReady:t,env:qe,doExit:r};globalThis.joliboxJSCore=v({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let i,e=window.JoliAndroidSDKBridge,t=(s="")=>{y.trigger(),e.onDocumentReady(JSON.stringify({path:s}))},r=s=>E(void 0,null,function*(){let a=yield y.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:a}))});M={onDocumentReady:t,invoke(s,a,o){e.invoke(JSON.stringify({event:s,paramsString:a,callbackId:o}))},doExit:r,publish(s,a,o){let u=j(a,"joliboxJSCore");e.publish(JSON.stringify({event:s,paramsString:JSON.stringify(u),webviewIds:o}))},call(s,a,o){let u=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(a),callbackId:o}));if(u)return JSON.parse(u)},doBackPress(s){return E(this,null,function*(){let a=yield y.backPress();e.doBackPress(JSON.stringify({uuid:s,shouldInterrupt:a}))})}};let n={onDocumentReady:t,env:qe,doExit:r};globalThis.joliboxJSCore=v({},n)}var Be=M;if(!Be&&we())throw new Ee("No joliboxJScore is found, native bridge not found.");var St=v({},Be),Fe=ie(St),{invokeHandler:Je}=Fe,{applyNative:jr,invokeNative:$r,onNative:Nt,offNative:Hr,subscribeHandler:Et,publish:Vr,emitNative:Gr,subscribe:Kr,unsubscribe:zr}=Fe,Wr=(e,t)=>{Nt(e,(...r)=>{var n;(n=r[0])!=null&&n.errorCode&&(r[0].errorCode=P(e,r[0].errorCode)),t(...r)})};globalThis.joliboxJSBridge={callHandler:Je,invokeHandler:Je,subscribeHandler:Et};export{y as RuntimeLoader,jr as applyNative,Gr as emitNative,$r as invokeNative,Hr as offNative,Nt as onNative,Wr as onNativeWithError,Vr as publish,ft as registerCanIUseContext,Kr as subscribe,Et as subscribeHandler,zr as unsubscribe};
1
+ var je=Object.defineProperty,$e=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))ce.call(t,r)&&ae(e,r,t[r]);if(D)for(var r of D(t))ue.call(t,r)&&ae(e,r,t[r]);return e},le=(e,t)=>$e(e,He(t));var de=(e,t)=>{var r={};for(var n in e)ce.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&ue.call(e,n)&&(r[n]=e[n]);return r};var R=(e,t,r)=>new Promise((n,s)=>{var i=u=>{try{o(r.next(u))}catch(c){s(c)}},a=u=>{try{o(r.throw(u))}catch(c){s(c)}},o=u=>u.done?n(u.value):Promise.resolve(u.value).then(i,a);o((r=r.apply(e,t)).next())});function Ve(e){return!!(e!=null&&e.__nativeBuffers__)}var Ge=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let s=0;s<r;s++)n[s]=t.charCodeAt(s);return n.buffer};function I(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!Ve(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let s;n.value?s=n.value:n.base64&&(s=Ge(n.base64)),typeof s!="undefined"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}var Ke=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)};function ge(e={},t=!1){let r=e,n=[];for(let[s,i]of Object.entries(r))if(i!==void 0&&i instanceof ArrayBuffer&&i.byteLength!==void 0){let a=t?{value:i,key:s}:{base64:Ke(i),key:s};n.push(a),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var he=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var We=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},fe=(e,t,r,n)=>{for(var s=n>1?void 0:n?ze(t,r):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(s=(n?a(t,r,s):a(s))||s);return n&&s&&he(t,r,s),s},Ye=(e,t,r)=>new Promise((n,s)=>{var i=u=>{try{o(r.next(u))}catch(c){s(c)}},a=u=>{try{o(r.throw(u))}catch(c){s(c)}},o=u=>u.done?n(u.value):Promise.resolve(u.value).then(i,a);o((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Qe(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}var ve=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 Q(e){return typeof e=="string"}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function X(e){return typeof e=="number"&&!isNaN(e)}function Xe(e){return typeof e=="undefined"}function Ze(e){return Xe(e)||e===null}function be(e){return typeof e=="function"}function ye(e){return S(e)&&be(e.then)}function _e(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var et=(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))(et||{}),tt=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 tt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Se=class extends U{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}};var Ne=class extends U{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}};var Ee=class extends U{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}};var L=class extends U{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};function w(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var A={log:w("log"),warn:w("warn"),info:w("info"),error:w("error"),debug:w("debug")};Object.assign(globalThis,{logger:A});var me=Symbol.for("Jolibox.canIUseMap"),rt={};globalThis[me]||(globalThis[me]=rt);function Re(e,t,r){let n=e;for(let s of t)if(n&&typeof n=="object")n=n[s];else return r;return n===void 0?r:n}var G=Symbol.for("Jolibox.canIUseMap.native"),nt={};globalThis[G]||(globalThis[G]=nt);var q={get config(){return globalThis[G]}};var st=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(st||{}),it=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(it||{}),ot=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(ot||{});function at(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}at();var x=typeof window=="undefined",xe=()=>!x&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),At={isiOS:!x&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!x&&navigator.userAgent.includes("Android"),isMac:!x&&navigator.userAgent.includes("Mac"),isFacebook:!x&&navigator.userAgent.includes("FB_IAB"),isPC:!x&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")};var K=class z{constructor(t){this.element=t,this.next=z.Undefined,this.prev=z.Undefined}};K.Undefined=new K(void 0);var m=K,ct=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let 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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},ut=0,C=class{constructor(e){this.value=e,this.id=ut++}},O=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 C&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,i,a,o,u;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new C(t);return this._listeners?this._listeners instanceof C?this._listeners=[this._listeners,c]:this._listeners.push(c):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=c,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(u=(o=this.options)==null?void 0:o.onDidAddListener)==null||u.call(o,this),this._size++,()=>{var l,d,g,p;if(!this._disposed){if(this._listeners instanceof C)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(d=(l=this.options)==null?void 0:l.onDidRemoveLastListener)==null||d.call(l));else if(this._listeners){let f=this._listeners.indexOf(c);f>=0&&(this._listeners.splice(f,1),this._size--,this._size===0&&((p=(g=this.options)==null?void 0:g.onDidRemoveLastListener)==null||p.call(g)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof C?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},J=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new O,i=u=>t(...u.args),a=s.event(i);this.listerHandlerMap.set(t,{handler:i,dispose:a}),this.listeners.set(e,s);let o=this.cachedEventQueue.get(e);if(o&&r)for(let u of o)t(...u.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new ct,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},W={};We(W,{None:()=>lt,filter:()=>gt,once:()=>Ae,toPromise:()=>dt});var lt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function dt(e){return new Promise(t=>Ae(e)(t))}function Ae(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function gt(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(i.fire,i)}},i=new O(s);return i.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var V=Symbol.for("Jolibox.hostEmitter"),mt=()=>{let e=new J;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[V]},Tt=mt();function pt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ht(e[n],t[n])}function ht(e,t){if(Q(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(r){}if(!Ze(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 Y=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new O,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return pt(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Y=fe([_e],Y);var pe=class{constructor(){this._onWillExecuteCommand=new O,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new O,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Y,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Qe(3e4)),this._starActivation}executeCommand(e,...t){return Ye(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),W.toPromise(W.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};pe=fe([_e],pe);var kt=Symbol.for("Jolibox.commands");b("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});b("requestProductDetailsAsync",{version:102e4});b("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});b("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});b("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});b("userTrackAsync",{version:1e6});b("openMiniapp",{version:1050100});function b(e,t){if(q.config[e]){A.warn(`[can i use] ${e} already registered`);return}q.config[e]=v({},t)}var ft=(e,t)=>{function r(s){var d;let[i,...a]=s.split(":");if(!i)return!1;let o=q.config[i];if(!o)return!1;let u=(d=t==null?void 0:t())!=null?d:"",c=o.version;if(o.platforms&&u in o.platforms){let g=o.platforms[u];if(g===!1)return!1;typeof g=="number"&&(c=g)}if(typeof c!="number")return!1;let l=e();return typeof l!="number"||l<c?!1:a.length===0?!0:n(o,a,l)||n(o.properties,a,l)}function n(s,i,a){if(!s)return!1;let o=Re(s,i);if(!o)return!1;if(S(o)){let u=o.version;return X(u)?typeof a=="number"&&a>=u:!0}return X(o)?typeof a=="number"&&a>=o:o===!0}return{canIUseNative:r}};function P(e,t){return`[${e}]:${t}`}var Te=()=>xe();var N="custom_event_";var ke=[],Ie=[],we=["env","createRequestTask","login"],B="__batch_event__",Ce="__native_batch_event__";var vt=e=>e==="pv"?e:"default",E=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:s,tagNameOrder:i,metricName:a,type:o}=t;this.reporter=r,this.interval=n,this.eventName=s,this.tagNameOrder=i,this.metricName=a,this.type=vt(o)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,s,i,a)=>{let o=s.shift();if(o){let u=a[o];n[u]||(n[u]={}),r(n[u],s,i,a)}else n[i]||(n[i]=[]),n[i].push(a[i])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(s,i,a,o)=>{let u=i.shift();if(!u&&S(o))throw new L(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(u){let c=[];if(S(o))c.push(...Object.keys(o));else if(Q(o)){if(i.length>0)throw new L(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);c.push(o)}else throw new L(`expected metric value to be a string, but got a(n) ${typeof o}, ${JSON.stringify(n)}`);c.forEach(l=>{s[l]||(s[l]={});let d=S(o)?o[l]:o;r(s[l],[...i],a,d)})}else s[a]?s[a]++:s[a]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Oe=!1,Z,ee,te;function Pe(e,t){Oe||(Z=new E({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),ee=new E({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),te=new E({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Z.flush(),ee.flush(),te.flush()}),Oe=!0);function r(s){var T,k;let{method:i,args:a,startTime:o,isForeground:u,errMsg:c=`${i}:fail no errMsg`,errNo:l=0,__timing:d={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:g,invokeCallback:p}=d,f=(k=(T=c.match(/\S:(\S+)\s?/))==null?void 0:T[1])!=null?k:"fail";Z.report({status:f,method:n(i,a),errNo:`${l}`,errMsg:c,isForeground:u,duration:Date.now()-o}),o&&g&&p&&(ee.report({status:f,method:i,isForeground:u,duration:Number((g-o).toFixed(3))}),te.report({status:f,method:i,isForeground:u,duration:Number((Date.now()-p).toFixed(3))}))}function n(s,i){return(s==="callHostMethod"||s==="callHostMethodSync")&&i!=null&&i.method?`${s}-${i.method}`:s}return r}var re=[],bt=!1,ne=Symbol.for("Jolibox.invokeResolverInstance"),yt=new Map;globalThis[ne]||(globalThis[ne]=yt);var _t={get resolveMap(){return globalThis[ne]}};function De(e,t){let r=0,n=!0,s=_t.resolveMap,i=Pe(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,re.forEach(g=>R(this,[g],function*({method:c,args:l,resolve:d}){let p=yield o(c,l);d(p)})),re.length=0});let a=(c,l)=>{let d=s.get(Number(c));if(!d)return;let g=I(l);d(g),s.delete(Number(c))},o=(c,l)=>{var ie,oe;let d=Date.now(),g=`${n}`;r+=1;let p=new ve;if(s.set(r,p.resolve),!n&&Ie.includes(c))return new Promise(_=>{re.push({method:c,args:l,resolve:_})});let T=le(v({},{method:c,startTime:d,args:l,isForeground:g}),{invokeType:"js-bridge"}),k=!bt&&ke.includes(c),$=ge(l,k),H=k?$:JSON.stringify($),h;if(c.endsWith("Sync")||we.includes(c)?h=(ie=e.call)==null?void 0:ie.call(e,c,$,r):typeof H=="string"?h=e.invoke(c,H,r):h=(oe=e.call)==null?void 0:oe.call(e,c,H,r),h){try{typeof h=="string"&&(h=JSON.parse(h)),h=I(h)}catch(_){A.error(_)}return s.delete(r),h.errorCode&&(h.errorCode=P(c,h.errorCode)),i(v(v({},T),h)),h}return c.endsWith("Sync")&&s.delete(r),p.promise.then(_=>(_.errorCode&&(_.errorCode=P(c,_.errorCode)),i(v(v({},T),_)),_))};return{invokeNative:o,applyNative:(c,l)=>{let d=o(c,l);return ye(d)?d.then(g=>Me(c,g)):Me(c,d)},invokeHandler:a}}function Me(e,t){if(!S(t)){A.warn(`[Jolibox SDK]${e} no response value`);return}let o=t,{errMsg:r,errNo:n,errorType:s,errorCode:i}=o,a=de(o,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Ne(r,n,s,i);return a}var F=Symbol.for("Jolibox.subscribeInstance");function Ue(e){if(globalThis[F])return globalThis[F];let t=new J,r=new J,n=new E({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(s){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:s}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[F]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(s,i,a){let o=I(i),u;if(o.__extra){u=o.params;let{type:c,startTime:l}=o.__extra;n.report({type:c,event:s,duration:Date.now()-l})}else u=o;if(s===B){u.forEach(l=>{let[d,g]=l;try{r.emit(d.slice(N.length),g,a)}catch(p){}});return}if(s.startsWith(N)){r.emit(s.slice(N.length),u,a);return}t.emit(s,u,a)}},globalThis[F]}function Le(e){let t=new Map,r=new Map,n,s;return{publish:(o,u,c,l)=>{if(l){let g=c!==void 0?c==="*"?"*":[c]:void 0;e.publish(`${N}${o}`,u,g);return}n||(n=Promise.resolve().then(()=>{t.forEach((g,p)=>{try{let f=p!==void 0?p==="*"?"*":[p]:void 0;e.publish(B,g,f)}catch(f){}}),n=void 0,t.clear()}));let d=t.get(c);d||(d=[],t.set(c,d)),d.push([`${N}${o}`,u])},emitNative:(o,u,c,l)=>{if(l){let g=c!==void 0?c==="*"?"*":[c]:void 0;e.publish(o,u,g),console.log("emitNative",o,u,g);return}s||(s=Promise.resolve().then(()=>{r.forEach((g,p)=>{try{let f=p!==void 0?p==="*"?"*":[p]:void 0;e.publish(Ce,g,f)}catch(f){}}),s=void 0,r.clear()}));let d=r.get(c);d||(d=[],r.set(c,d)),d.push([o,u])}}}function se(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:s,unsubscribe:i}=Ue(e),{invokeNative:a,invokeHandler:o,applyNative:u}=De(e,r),{publish:c,emitNative:l}=Le(e);return{invokeHandler:o,subscribeHandler:t,applyNative:u,invokeNative:a,onNative:r,offNative:n,emitNative:l,publish:c,subscribe:s,unsubscribe:i}}function j(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var M,y={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){y.trigger=e},onDoExit(e){y.exit=e},onDoBackPress(e){y.backPress=e}},qe=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new Se("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{y.trigger(),e.onDocumentReady.postMessage({path:s})},r=s=>R(void 0,null,function*(){let i=yield y.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:i})});M={onDocumentReady:t,doExit:r,invoke(s,i,a){e.invoke.postMessage({event:s,paramsString:i,callbackId:a})},publish(s,i,a){let o=j(i,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:s,paramsString:JSON.stringify(o),webviewIds:a}))},call(s,i,a){let o=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(i),callbackId:a}));if(o)return JSON.parse(o)}};let n={onDocumentReady:t,env:qe,doExit:r};globalThis.joliboxJSCore=v({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let s,e=window.JoliAndroidSDKBridge,t=(i="")=>{y.trigger(),e.onDocumentReady(JSON.stringify({path:i}))},r=i=>R(void 0,null,function*(){let a=yield y.exit();e.doExit(JSON.stringify({uuid:i,shouldInterrupt:a}))});M={onDocumentReady:t,invoke(i,a,o){e.invoke(JSON.stringify({event:i,paramsString:a,callbackId:o}))},doExit:r,publish(i,a,o){let u=j(a,"joliboxJSCore");e.publish(JSON.stringify({event:i,paramsString:JSON.stringify(u),webviewIds:o}))},call(i,a,o){let u=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(a),callbackId:o}));if(u)return JSON.parse(u)},doBackPress(i){return R(this,null,function*(){let a=yield y.backPress();e.doBackPress(JSON.stringify({uuid:i,shouldInterrupt:a}))})}};let n={onDocumentReady:t,env:qe,doExit:r};globalThis.joliboxJSCore=v({},n)}var Be=M;if(!Be&&Te())throw new Ee("No joliboxJScore is found, native bridge not found.");var St=v({},Be),Fe=se(St),{invokeHandler:Je}=Fe,{applyNative:Hr,invokeNative:Vr,onNative:Nt,offNative:Gr,subscribeHandler:Et,publish:Kr,emitNative:zr,subscribe:Wr,unsubscribe:Yr}=Fe,Qr=(e,t)=>{Nt(e,(...r)=>{var n;(n=r[0])!=null&&n.errorCode&&(r[0].errorCode=P(e,r[0].errorCode)),t(...r)})};globalThis.joliboxJSBridge={callHandler:Je,invokeHandler:Je,subscribeHandler:Et};export{y as RuntimeLoader,Hr as applyNative,zr as emitNative,Vr as invokeNative,Gr as offNative,Nt as onNative,Qr as onNativeWithError,Kr as publish,ft as registerCanIUseContext,Wr as subscribe,Et as subscribeHandler,Yr as unsubscribe};
@@ -427,6 +427,64 @@ declare global {
427
427
  };
428
428
  }>;
429
429
 
430
+ /** 订阅档位价格查询 */
431
+ requestSubscriptionPlansAsync: (params: {
432
+ appStoreProductIds: string[];
433
+ type: 'game' | 'drama';
434
+ }) => Promise<{
435
+ errMsg: string;
436
+ errNo?: number;
437
+ data: {
438
+ [appStoreProductId: string]: {
439
+ basePlanId: string; // 基础计划Id
440
+ productId: string; // 产品Id
441
+ // 价格信息
442
+ pricing: {
443
+ formattedPrice: string;
444
+ originalPrice?: string;
445
+ discountPercentage?: number;
446
+ };
447
+ trial?: {
448
+ duration: number; // 7
449
+ description?: string; // "7天免费试用"
450
+ };
451
+ promotion?: {
452
+ type: 'new_user' | 'limited_time' | 'winback';
453
+ badge: string;
454
+ description: string;
455
+ };
456
+ };
457
+ };
458
+ }>;
459
+
460
+ requestSubscriptionSync: (params: {
461
+ params: {
462
+ basePlanId: string;
463
+ appStoreProductId: string;
464
+ productId?: string;
465
+
466
+ // for iOS
467
+ paymentBody?: {
468
+ appAccountToken: string;
469
+ appStoreProductId: string;
470
+ };
471
+ };
472
+ }) => {
473
+ errMsg: string;
474
+ errNo?: number;
475
+ data: {
476
+ subUUID: string;
477
+ };
478
+ };
479
+
480
+ invokeSubscriptionPanelSync: (params: { type: 'game' | 'drama' }) => {
481
+ errMsg: string;
482
+ errNo?: number;
483
+ data: {
484
+ subUUID: string;
485
+ };
486
+ };
487
+
430
488
  callHostMethodSync: (params: { method: string; params: any }) => {
431
489
  errMsg: string;
432
490
  errNo?: number;
@@ -477,6 +535,7 @@ declare global {
477
535
  uuid: string;
478
536
  token?: string;
479
537
  isFirstLogin?: boolean;
538
+ appAccountToken?: string; // for iOS
480
539
  extra?: {
481
540
  firstLogin?: {
482
541
  reward: {
@@ -532,6 +591,45 @@ declare global {
532
591
  };
533
592
  }
534
593
  ];
594
+
595
+ onSubscritptionStateChange: [
596
+ {
597
+ subUUID: string;
598
+ status: 'SUCCESS' | 'FAILED';
599
+ orderResponse: {
600
+ errNo?: number;
601
+ errMsg?: string;
602
+ subPlanId: string; // 订阅Id
603
+ tickedId?: string;
604
+ };
605
+ }
606
+ ];
607
+
608
+ onSubscriptionPanelStateChange: [
609
+ {
610
+ subUUID: string;
611
+ status: 'SUCCESS' | 'FAILED' | 'FAILURE_SUBSCRIPTED';
612
+ orderResponse: {
613
+ errNo?: number;
614
+ errMsg?: string;
615
+ subPlanId: string; // 订阅Id
616
+ tickedId?: string;
617
+ };
618
+ }
619
+ ];
620
+
621
+ /** global subscription state change */
622
+ onGlobalSubscriptionStateChange: [
623
+ {
624
+ status: 'SUCCESS' | 'FAILED';
625
+ orderResponse: {
626
+ errNo?: number;
627
+ errMsg?: string;
628
+ subPlanId: string; // 订阅Id
629
+ tickedId?: string; // for iOS
630
+ };
631
+ }
632
+ ];
535
633
  }
536
634
  }
537
635
  }
@@ -4,7 +4,10 @@
4
4
  import { NativeCanIUseInfo } from '@jolibox/common';
5
5
  import './registered/payment';
6
6
  import './registered/login';
7
- export declare function registerCanIUseNative(name: keyof jsb.service.NativeMethodMap, config: NativeCanIUseInfo): void;
7
+ import './registered/call-host-method';
8
+ type DynamicMethodName = 'getABTest' | 'userTrackAsync' | 'openMiniapp';
9
+ export declare function registerCanIUseNative(name: keyof jsb.service.NativeMethodMap | DynamicMethodName, config: NativeCanIUseInfo): void;
8
10
  export declare const registerCanIUseContext: (nativeSDKVersionCodeGetter: () => number | undefined, platformGetter: () => "h5" | "android" | "ios") => {
9
11
  canIUseNative: (schema: string) => boolean;
10
12
  };
13
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jolibox/native-bridge",
3
3
  "description": "This project is Jolibox JS-SDk bridge for Native",
4
- "version": "1.2.8",
4
+ "version": "1.2.9-beta.9",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -11,8 +11,8 @@
11
11
  ],
12
12
  "types": "./dist/index.d.ts",
13
13
  "dependencies": {
14
- "@jolibox/common": "1.2.8",
15
- "@jolibox/types": "1.2.8"
14
+ "@jolibox/common": "1.2.9-beta.9",
15
+ "@jolibox/types": "1.2.9-beta.9"
16
16
  },
17
17
  "devDependencies": {
18
18
  "typescript": "5.7.3",
@@ -427,6 +427,64 @@ declare global {
427
427
  };
428
428
  }>;
429
429
 
430
+ /** 订阅档位价格查询 */
431
+ requestSubscriptionPlansAsync: (params: {
432
+ appStoreProductIds: string[];
433
+ type: 'game' | 'drama';
434
+ }) => Promise<{
435
+ errMsg: string;
436
+ errNo?: number;
437
+ data: {
438
+ [appStoreProductId: string]: {
439
+ basePlanId: string; // 基础计划Id
440
+ productId: string; // 产品Id
441
+ // 价格信息
442
+ pricing: {
443
+ formattedPrice: string;
444
+ originalPrice?: string;
445
+ discountPercentage?: number;
446
+ };
447
+ trial?: {
448
+ duration: number; // 7
449
+ description?: string; // "7天免费试用"
450
+ };
451
+ promotion?: {
452
+ type: 'new_user' | 'limited_time' | 'winback';
453
+ badge: string;
454
+ description: string;
455
+ };
456
+ };
457
+ };
458
+ }>;
459
+
460
+ requestSubscriptionSync: (params: {
461
+ params: {
462
+ basePlanId: string;
463
+ appStoreProductId: string;
464
+ productId?: string;
465
+
466
+ // for iOS
467
+ paymentBody?: {
468
+ appAccountToken: string;
469
+ appStoreProductId: string;
470
+ };
471
+ };
472
+ }) => {
473
+ errMsg: string;
474
+ errNo?: number;
475
+ data: {
476
+ subUUID: string;
477
+ };
478
+ };
479
+
480
+ invokeSubscriptionPanelSync: (params: { type: 'game' | 'drama' }) => {
481
+ errMsg: string;
482
+ errNo?: number;
483
+ data: {
484
+ subUUID: string;
485
+ };
486
+ };
487
+
430
488
  callHostMethodSync: (params: { method: string; params: any }) => {
431
489
  errMsg: string;
432
490
  errNo?: number;
@@ -477,6 +535,7 @@ declare global {
477
535
  uuid: string;
478
536
  token?: string;
479
537
  isFirstLogin?: boolean;
538
+ appAccountToken?: string; // for iOS
480
539
  extra?: {
481
540
  firstLogin?: {
482
541
  reward: {
@@ -532,6 +591,45 @@ declare global {
532
591
  };
533
592
  }
534
593
  ];
594
+
595
+ onSubscritptionStateChange: [
596
+ {
597
+ subUUID: string;
598
+ status: 'SUCCESS' | 'FAILED';
599
+ orderResponse: {
600
+ errNo?: number;
601
+ errMsg?: string;
602
+ subPlanId: string; // 订阅Id
603
+ tickedId?: string;
604
+ };
605
+ }
606
+ ];
607
+
608
+ onSubscriptionPanelStateChange: [
609
+ {
610
+ subUUID: string;
611
+ status: 'SUCCESS' | 'FAILED' | 'FAILURE_SUBSCRIPTED';
612
+ orderResponse: {
613
+ errNo?: number;
614
+ errMsg?: string;
615
+ subPlanId: string; // 订阅Id
616
+ tickedId?: string;
617
+ };
618
+ }
619
+ ];
620
+
621
+ /** global subscription state change */
622
+ onGlobalSubscriptionStateChange: [
623
+ {
624
+ status: 'SUCCESS' | 'FAILED';
625
+ orderResponse: {
626
+ errNo?: number;
627
+ errMsg?: string;
628
+ subPlanId: string; // 订阅Id
629
+ tickedId?: string; // for iOS
630
+ };
631
+ }
632
+ ];
535
633
  }
536
634
  }
537
635
  }