@jolibox/bootstrap 1.3.6 → 1.3.8

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.
@@ -3,9 +3,9 @@
3
3
  "packages/bootstrap/.rush/temp/shrinkwrap-deps.json": "85f115f9fbe6f1e962199c288bb411864903ba42",
4
4
  "packages/bootstrap/.eslintrc.js": "edf42cea6fba51042e3fc82241d56a202f11a83a",
5
5
  "packages/bootstrap/README.md": "9b60fc4ee630488fd6ce5cc43a6bbd5c06e175fb",
6
- "packages/bootstrap/package.json": "19680aa1d3bced36690f7792de3f8cb56d61deb5",
6
+ "packages/bootstrap/package.json": "48e76f79feeba6f180c773dede817ffa81c7bf0f",
7
7
  "packages/bootstrap/src/index.ts": "1db013adc75ad61e7425a64874d5141e45e222a8",
8
- "packages/bootstrap/src/runtime.ts": "24354968e44eb7e540819155fd9eca19d93639d3",
8
+ "packages/bootstrap/src/runtime.ts": "bb9fae78d3115688d8f437b0037ab1da1fc367f4",
9
9
  "packages/bootstrap/tsconfig.json": "ef597317f67bfb548a17f81a3b7a3ca64f08bb93"
10
10
  },
11
11
  "arguments": "npm run clean && esbuild ./src/index.ts --log-level=error --format=iife --outfile=./dist/index.js --bundle --minify && tsc "
@@ -1,5 +1,5 @@
1
1
  Invoking: npm run clean && esbuild ./src/index.ts --log-level=error --format=iife --outfile=./dist/index.js --bundle --minify && tsc
2
2
 
3
- > @jolibox/bootstrap@1.3.6 clean
3
+ > @jolibox/bootstrap@1.3.8 clean
4
4
  > rimraf ./dist
5
5
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var T=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var M=(e,t)=>{for(var r in t)T(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,s)=>{for(var n=s>1?void 0:s?k(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(s?a(t,r,n):a(n))||n);return s&&n&&T(t,r,n),n},j=(e,t,r)=>new Promise((s,n)=>{var o=c=>{try{l(r.next(c))}catch(u){n(u)}},a=c=>{try{l(r.throw(c))}catch(u){n(u)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(o,a);l((r=r.apply(e,t)).next())});if(typeof window<"u"&&!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,s){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(s)},t.prototype.removeEventListener=function(r,s){if(!this._eventListeners[r])return;let n=this._eventListeners[r].indexOf(s);n!==-1&&this._eventListeners[r].splice(n,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let s of this._eventListeners[r.type])s.call(this,r)},window.AbortController=e,window.AbortSignal=t}function F(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function $(e){return typeof e=="string"}function K(e){return typeof e>"u"}function J(e){return K(e)||e===null}function G(e){return typeof e=="function"}function P(e){let t=e,r=null,s=function(...n){return r||(r=new t(...n)),r};return s.prototype=t.prototype,s}var V=(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))(V||{});function h(e){return(...t)=>{var r,s;((s=(r=globalThis.VConsole)==null?void 0:r[e])!=null?s:globalThis.console[e])(...t)}}var W={log:h("log"),warn:h("warn"),info:h("info"),error:h("error"),debug:h("debug")};Object.assign(globalThis,{logger:W});var I=Symbol.for("Jolibox.canIUseMap"),H={};globalThis[I]||(globalThis[I]=H);var D=Symbol.for("Jolibox.canIUseMap.native"),z={};globalThis[D]||(globalThis[D]=z);var B=(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))(B||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),X=(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))(X||{});function Y(){if(typeof window>"u")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 s=e.get.call(window);return window.__joliboxLocalStorage__=s,s}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 s=r.get.call(window);return window.__joliboxLocalStorage__=s,s}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}Y();var d=typeof window>"u";var ue={isiOS:!d&&(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:!d&&navigator.userAgent.includes("Android"),isMac:!d&&navigator.userAgent.includes("Mac"),isFacebook:!d&&navigator.userAgent.includes("FB_IAB"),isPC:!d&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")};var v=class R{constructor(t){this.element=t,this.next=R.Undefined,this.prev=R.Undefined}};v.Undefined=new v(void 0);var i=v,Z=class{constructor(){this._first=i.Undefined,this._last=i.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===i.Undefined}clear(){let e=this._first;for(;e!==i.Undefined;){let t=e.next;e.prev=i.Undefined,e.next=i.Undefined,e=t}this._first=i.Undefined,this._last=i.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new i(e);if(this._first===i.Undefined)this._first=r,this._last=r;else if(t){let n=this._last;this._last=r,r.prev=n,n.next=r}else{let n=this._first;this._first=r,r.next=n,n.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==i.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==i.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==i.Undefined&&e.next!==i.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===i.Undefined&&e.next===i.Undefined?(this._first=i.Undefined,this._last=i.Undefined):e.next===i.Undefined?(this._last=this._last.prev,this._last.next=i.Undefined):e.prev===i.Undefined&&(this._first=this._first.next,this._first.prev=i.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==i.Undefined;)yield e.element,e=e.next}},ee=0,f=class{constructor(e){this.value=e,this.id=ee++}},m=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 f&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(s=>s?.value===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,n,o,a,l,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new f(t);return this._listeners?this._listeners instanceof f?this._listeners=[this._listeners,u]:this._listeners.push(u):((n=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||n.call(s,this),this._listeners=u,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(l=this.options)==null?void 0:l.onDidAddListener)==null||c.call(l,this),this._size++,()=>{var g,O,_,C;if(!this._disposed){if(this._listeners instanceof f)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(O=(g=this.options)==null?void 0:g.onDidRemoveLastListener)==null||O.call(g));else if(this._listeners){let b=this._listeners.indexOf(u);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((C=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||C.call(_)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let s=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}fire(e){this._listeners&&(this._listeners instanceof f?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},te=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var s;let n=(s=this.listeners.get(e))!=null?s:new m,o=c=>t(...c.args),a=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,n);let l=this.cachedEventQueue.get(e);if(l&&r)for(let c of l)t(...c.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),s=this.cachedEventQueue.get(e);s||(s=new Z,this.cachedEventQueue.set(e,s)),s.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...s)=>{t(...s),this.off(e,r)};this.on(e,r,!1)}},S={};M(S,{None:()=>re,filter:()=>ne,once:()=>q,toPromise:()=>se});var re=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function se(e){return new Promise(t=>q(e)(t))}function q(e){return(t,r=null)=>{let s=!1;return e(n=>{if(!s)return s=!0,t.call(r,n)},null)}}function ne(e,t){return(r=>{let s,n={onWillAddFirstListener(){s=r(o.fire,o)}},o=new m(n);return o.event})((r,s=null)=>e(n=>t(n)&&r.call(s,n),null))}var E=Symbol.for("Jolibox.hostEmitter"),ie=()=>{let e=new te;return globalThis[E]||(globalThis[E]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[E]},he=ie();function oe(e,t){let r=Math.min(e.length,t.length);for(let s=0;s<r;s++)ae(e[s],t[s])}function ae(e,t){if($(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(G(t)){try{if(e instanceof t)return}catch{}if(!J(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var p=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new m,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 n of e.metadata.args)r.push(n.constraint);let s=e.handler;e.handler=function(...n){return oe(n,r),s(...n)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};p=L([P],p);var y=class{constructor(){this._onWillExecuteCommand=new m,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new m,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new p,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=F(3e4)),this._starActivation}executeCommand(e,...t){return j(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),S.toPromise(S.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 s=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),s}_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 s=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(s)}catch(s){return Promise.reject(s)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};y=L([P],y);var N=Symbol.for("Jolibox.commands");function ce(){return typeof globalThis<"u"?globalThis[N]:void 0}function le(e){typeof globalThis<"u"&&(globalThis[N]=e)}function U(e=!1){let t=ce();if(!e&&t)return t;let r=new p,s=new y,n={registerCommand(o,a,l){r.registerCommand({id:o,handler:a,metadata:l})},executeCommand(o,...a){return s.executeCommand(o,...a)},excuteCommandSync(o,...a){return s.executeCommandThowErr(o,...a)}};return le(n),n}var x=(e,t)=>{window.parent&&window.parent.postMessage({type:e,data:t},"*")},A=U();window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));x("JOLIBOX_RUNTIME_LOAD_START",{});var w=class{constructor(){this.loadFinished=()=>{if(document?.head.querySelector('meta[name="dlightek"][content="jolibox"]'))window.postMessage("gameLoadingCompleted","*");else{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r)}x("JOLIBOX_RUNTIME_LOAD_FINISHED",{}),A.executeCommand("RuntimeSDK.loadFinishedEvent"),A.executeCommand("ReportSDK.traceSystem",{event:"CallRuntimeLoadFinished",info:{t:Date.now()}})};this.notifyLoadProgress=t=>{let r=Math.ceil(t),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(s),x("JOLIBOX_RUNTIME_LOAD_PROGRESS",{progress:r}),A.executeCommand("RuntimeSDK.loadProgressEvent",r)}}};window.JoliboxRuntime=w;})();
1
+ "use strict";(()=>{var T=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var k=(e,t)=>{for(var r in t)T(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,s)=>{for(var n=s>1?void 0:s?M(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(s?a(t,r,n):a(n))||n);return s&&n&&T(t,r,n),n},j=(e,t,r)=>new Promise((s,n)=>{var o=c=>{try{l(r.next(c))}catch(u){n(u)}},a=c=>{try{l(r.throw(c))}catch(u){n(u)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(o,a);l((r=r.apply(e,t)).next())});if(typeof window<"u"&&!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,s){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(s)},t.prototype.removeEventListener=function(r,s){if(!this._eventListeners[r])return;let n=this._eventListeners[r].indexOf(s);n!==-1&&this._eventListeners[r].splice(n,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let s of this._eventListeners[r.type])s.call(this,r)},window.AbortController=e,window.AbortSignal=t}function F(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function $(e){return typeof e=="string"}function G(e){return typeof e>"u"}function J(e){return G(e)||e===null}function K(e){return typeof e=="function"}function P(e){let t=e,r=null,s=function(...n){return r||(r=new t(...n)),r};return s.prototype=t.prototype,s}var V=(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))(V||{});function h(e){return(...t)=>{var r,s;((s=(r=globalThis.VConsole)==null?void 0:r[e])!=null?s:globalThis.console[e])(...t)}}var W={log:h("log"),warn:h("warn"),info:h("info"),error:h("error"),debug:h("debug")};Object.assign(globalThis,{logger:W});var I=Symbol.for("Jolibox.canIUseMap"),H={};globalThis[I]||(globalThis[I]=H);var D=Symbol.for("Jolibox.canIUseMap.native"),z={};globalThis[D]||(globalThis[D]=z);var B=(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))(B||{}),Q=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Q||{}),X=(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))(X||{});function Y(){if(typeof window>"u")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 s=e.get.call(window);return window.__joliboxLocalStorage__=s,s}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 s=r.get.call(window);return window.__joliboxLocalStorage__=s,s}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}Y();var d=typeof window>"u";var ue={isiOS:!d&&(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:!d&&navigator.userAgent.includes("Android"),isMac:!d&&navigator.userAgent.includes("Mac"),isFacebook:!d&&navigator.userAgent.includes("FB_IAB"),isPC:!d&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")};var S=class y{constructor(t){this.element=t,this.next=y.Undefined,this.prev=y.Undefined}};S.Undefined=new S(void 0);var i=S,Z=class{constructor(){this._first=i.Undefined,this._last=i.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===i.Undefined}clear(){let e=this._first;for(;e!==i.Undefined;){let t=e.next;e.prev=i.Undefined,e.next=i.Undefined,e=t}this._first=i.Undefined,this._last=i.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new i(e);if(this._first===i.Undefined)this._first=r,this._last=r;else if(t){let n=this._last;this._last=r,r.prev=n,n.next=r}else{let n=this._first;this._first=r,r.next=n,n.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==i.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==i.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==i.Undefined&&e.next!==i.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===i.Undefined&&e.next===i.Undefined?(this._first=i.Undefined,this._last=i.Undefined):e.next===i.Undefined?(this._last=this._last.prev,this._last.next=i.Undefined):e.prev===i.Undefined&&(this._first=this._first.next,this._first.prev=i.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==i.Undefined;)yield e.element,e=e.next}},ee=0,f=class{constructor(e){this.value=e,this.id=ee++}},m=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 f&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(s=>s?.value===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var s,n,o,a,l,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new f(t);return this._listeners?this._listeners instanceof f?this._listeners=[this._listeners,u]:this._listeners.push(u):((n=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||n.call(s,this),this._listeners=u,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(l=this.options)==null?void 0:l.onDidAddListener)==null||c.call(l,this),this._size++,()=>{var E,O,v,C;if(!this._disposed){if(this._listeners instanceof f)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(O=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||O.call(E));else if(this._listeners){let b=this._listeners.indexOf(u);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((C=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||C.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let s=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}fire(e){this._listeners&&(this._listeners instanceof f?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},te=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var s;let n=(s=this.listeners.get(e))!=null?s:new m,o=c=>t(...c.args),a=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,n);let l=this.cachedEventQueue.get(e);if(l&&r)for(let c of l)t(...c.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),s=this.cachedEventQueue.get(e);s||(s=new Z,this.cachedEventQueue.set(e,s)),s.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...s)=>{t(...s),this.off(e,r)};this.on(e,r,!1)}},A={};k(A,{None:()=>re,filter:()=>ne,once:()=>N,toPromise:()=>se});var re=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function se(e){return new Promise(t=>N(e)(t))}function N(e){return(t,r=null)=>{let s=!1;return e(n=>{if(!s)return s=!0,t.call(r,n)},null)}}function ne(e,t){return(r=>{let s,n={onWillAddFirstListener(){s=r(o.fire,o)}},o=new m(n);return o.event})((r,s=null)=>e(n=>t(n)&&r.call(s,n),null))}var R=Symbol.for("Jolibox.hostEmitter"),ie=()=>{let e=new te;return globalThis[R]||(globalThis[R]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[R]},he=ie();function oe(e,t){let r=Math.min(e.length,t.length);for(let s=0;s<r;s++)ae(e[s],t[s])}function ae(e,t){if($(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(K(t)){try{if(e instanceof t)return}catch{}if(!J(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var p=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new m,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 n of e.metadata.args)r.push(n.constraint);let s=e.handler;e.handler=function(...n){return oe(n,r),s(...n)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};p=L([P],p);var x=class{constructor(){this._onWillExecuteCommand=new m,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new m,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new p,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=F(3e4)),this._starActivation}executeCommand(e,...t){return j(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),A.toPromise(A.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 s=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),s}_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 s=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(s)}catch(s){return Promise.reject(s)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};x=L([P],x);var q=Symbol.for("Jolibox.commands");function ce(){return typeof globalThis<"u"?globalThis[q]:void 0}function le(e){typeof globalThis<"u"&&(globalThis[q]=e)}function U(e=!1){let t=ce();if(!e&&t)return t;let r=new p,s=new x,n={registerCommand(o,a,l){r.registerCommand({id:o,handler:a,metadata:l})},executeCommand(o,...a){return s.executeCommand(o,...a)},excuteCommandSync(o,...a){return s.executeCommandThowErr(o,...a)}};return le(n),n}var _=(e,t)=>{window.parent&&window.parent.postMessage({type:e,data:t},"*")},g=U();window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));_("JOLIBOX_RUNTIME_LOAD_START",{});var w=class{constructor(){this.loadFinished=()=>{if(document?.head.querySelector('meta[name="dlightek"][content="jolibox"]'))window.postMessage("gameLoadingCompleted","*");else{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r)}_("JOLIBOX_RUNTIME_LOAD_FINISHED",{}),g.executeCommand("RuntimeSDK.loadFinishedEvent"),g.executeCommand("ReportSDK.traceSystem",{event:"CallRuntimeLoadFinished",info:{t:Date.now()}})};this.notifyLoadProgress=t=>{let r=Math.ceil(t),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(s),_("JOLIBOX_RUNTIME_LOAD_PROGRESS",{progress:r}),g.executeCommand("RuntimeSDK.loadProgressEvent",r)};this.gameTTI=()=>{let t=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(t),_("JOLIBOX_RUNTIME_GAME_TTI",{}),g.executeCommand("RuntimeSDK.gameTTIEvent")}}};window.JoliboxRuntime=w;})();
package/dist/runtime.d.ts CHANGED
@@ -10,7 +10,11 @@ export declare enum JoliboxRuntimeEvents {
10
10
  /**
11
11
  * Event dispatched when the loading progress is updated
12
12
  */
13
- LOAD_PROGRESS = "JOLIBOX_RUNTIME_LOAD_PROGRESS"
13
+ LOAD_PROGRESS = "JOLIBOX_RUNTIME_LOAD_PROGRESS",
14
+ /**
15
+ * Event dispatched when the game TTI (Time to Interactive) is reported
16
+ */
17
+ GAME_TTI = "JOLIBOX_RUNTIME_GAME_TTI"
14
18
  }
15
19
  /**
16
20
  * Jolibox Runtime, a set of utilities to interact with the Jolibox runtime
@@ -26,6 +30,11 @@ export declare class JoliboxRuntime {
26
30
  * @param progress - The progress of the loading, should be an integer between 0 and 100
27
31
  */
28
32
  notifyLoadProgress: (progress: number) => void;
33
+ /**
34
+ * Report the game TTI (Time to Interactive)
35
+ * @param duration - The duration in milliseconds from game start to interactive
36
+ */
37
+ gameTTI: () => void;
29
38
  }
30
39
  declare global {
31
40
  interface Window {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@jolibox/bootstrap",
3
3
  "description": "This project is Jolibox JS-SDk bootstrap",
4
- "version": "1.3.6",
4
+ "version": "1.3.8",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.3.6"
9
+ "@jolibox/common": "1.3.8"
10
10
  },
11
11
  "devDependencies": {
12
12
  "typescript": "5.7.3",
package/src/runtime.ts CHANGED
@@ -14,7 +14,12 @@ export enum JoliboxRuntimeEvents {
14
14
  /**
15
15
  * Event dispatched when the loading progress is updated
16
16
  */
17
- LOAD_PROGRESS = 'JOLIBOX_RUNTIME_LOAD_PROGRESS'
17
+ LOAD_PROGRESS = 'JOLIBOX_RUNTIME_LOAD_PROGRESS',
18
+
19
+ /**
20
+ * Event dispatched when the game TTI (Time to Interactive) is reported
21
+ */
22
+ GAME_TTI = 'JOLIBOX_RUNTIME_GAME_TTI'
18
23
  }
19
24
 
20
25
  const notifyIframeRuntimeEvent = (eventName: string, data: any) => {
@@ -73,6 +78,17 @@ export class JoliboxRuntime {
73
78
  notifyIframeRuntimeEvent(JoliboxRuntimeEvents.LOAD_PROGRESS, { progress: detail });
74
79
  commands.executeCommand('RuntimeSDK.loadProgressEvent', detail);
75
80
  };
81
+
82
+ /**
83
+ * Report the game TTI (Time to Interactive)
84
+ * @param duration - The duration in milliseconds from game start to interactive
85
+ */
86
+ gameTTI = (): void => {
87
+ const event = new CustomEvent(JoliboxRuntimeEvents.GAME_TTI, {});
88
+ window.dispatchEvent(event);
89
+ notifyIframeRuntimeEvent(JoliboxRuntimeEvents.GAME_TTI, {});
90
+ commands.executeCommand('RuntimeSDK.gameTTIEvent');
91
+ };
76
92
  }
77
93
 
78
94
  declare global {