handler-playable-sdk 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-XHKJ4F4G.mjs → chunk-KK4RWSSF.mjs} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/pixi/index.js +1 -1
- package/dist/pixi/index.mjs +1 -1
- package/dist/three/index.js +5 -5
- package/dist/three/index.mjs +11 -11
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var u={};function I(e,t,n=!1){u[e]||(u[e]=[]),u[e].push({fn:t,once:n})}function V(e,t){if(u[e]){if(!t){delete u[e];return}u[e]=u[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=u[e];if(n)for(let i of[...n])i.fn(...t),i.once&&V(e,i.fn)}function a(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.5",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,f.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(fe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(pe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ne(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{f.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function je(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(f.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),f.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var f={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),Ne(),je(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,f.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(N(e),t)},off(e,t){V(N(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>f.install(e),300)):(o("complete"),setTimeout(()=>f.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=f;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
var u={};function I(e,t,n=!1){u[e]||(u[e]=[]),u[e].push({fn:t,once:n})}function V(e,t){if(u[e]){if(!t){delete u[e];return}u[e]=u[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=u[e];if(n)for(let i of[...n])i.fn(...t),i.once&&V(e,i.fn)}function a(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.6",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,f.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(fe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(pe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ne(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{f.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function je(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(f.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),f.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var f={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),Ne(),je(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,f.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(N(e),t)},off(e,t){V(N(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>f.install(e),300)):(o("complete"),setTimeout(()=>f.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=f;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
2
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var f={};function I(e,t,n=!1){f[e]||(f[e]=[]),f[e].push({fn:t,once:n})}function H(e,t){if(f[e]){if(!t){delete f[e];return}f[e]=f[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=f[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.5",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ne=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",je={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:Ne,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(fe())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(pe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",je=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(N(e),t)},off(e,t){H(N(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var f={};function I(e,t,n=!1){f[e]||(f[e]=[]),f[e].push({fn:t,once:n})}function H(e,t){if(f[e]){if(!t){delete f[e];return}f[e]=f[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=f[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.6",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ne=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",je={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:Ne,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(fe())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(pe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",je=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(N(e),t)},off(e,t){H(N(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
2
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-KK4RWSSF.mjs";export{a as Handler,b as default};
|
package/dist/pixi/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ke=Object.defineProperty;var Ka=Object.getOwnPropertyDescriptor;var $a=Object.getOwnPropertyNames;var Ja=Object.prototype.hasOwnProperty;var Qa=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $a(t))!Ja.call(e,o)&&o!==n&&Ke(e,o,{get:()=>t[o],enumerable:!(a=Ka(t,o))||a.enumerable});return e};var Ua=e=>Za(Ke({},"__esModule",{value:!0}),e);var bi={};Qa(bi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>ca,createEndGamePanel:()=>na,createHandTutorial:()=>oa,createPixiBase:()=>Un,createTutorialLabel:()=>sa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>la,registerFont:()=>ea,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>ra});module.exports=Ua(bi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.1.5",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ti=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Mn=N++,Fn=N++,Ln=N++,Rn=N++,_=ti;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Mn}function Bn(){return _===Fn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Fn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},ni=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ai={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,Gn=!1,jn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ni,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function ii(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function si(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Gn=!0),!(Gn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ri(e){var a,o,i,s,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(o=window.TJ_API)==null?void 0:o.click)==null||i.call(o);else if(On())(r=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||r.call(s);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function li(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",o=>{var i;((i=o==null?void 0:o.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function ci(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function di(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function ui(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ai=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),pi(pe),In(),ii(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!jn){jn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}si(),li(),ci(),di(),ui(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),ri(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function pi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var Ke=Object.defineProperty;var Ka=Object.getOwnPropertyDescriptor;var $a=Object.getOwnPropertyNames;var Ja=Object.prototype.hasOwnProperty;var Qa=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $a(t))!Ja.call(e,o)&&o!==n&&Ke(e,o,{get:()=>t[o],enumerable:!(a=Ka(t,o))||a.enumerable});return e};var Ua=e=>Za(Ke({},"__esModule",{value:!0}),e);var bi={};Qa(bi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>ca,createEndGamePanel:()=>na,createHandTutorial:()=>oa,createPixiBase:()=>Un,createTutorialLabel:()=>sa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>la,registerFont:()=>ea,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>ra});module.exports=Ua(bi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.1.6",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ti=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Mn=N++,Fn=N++,Ln=N++,Rn=N++,_=ti;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Mn}function Bn(){return _===Fn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Fn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},ni=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ai={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,Gn=!1,jn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ni,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function ii(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function si(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Gn=!0),!(Gn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ri(e){var a,o,i,s,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(o=window.TJ_API)==null?void 0:o.click)==null||i.call(o);else if(On())(r=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||r.call(s);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function li(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",o=>{var i;((i=o==null?void 0:o.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function ci(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function di(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function ui(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ai=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),pi(pe),In(),ii(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!jn){jn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}si(),li(),ci(),di(),ui(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),ri(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function pi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
2
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
package/dist/pixi/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as lt}from"../chunk-XHKJ4F4G.mjs";import{Application as Pn}from"pixi.js";async function Mn(e,t={}){let a=new Pn;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let o=n=>{var c,d,p,u,h,l;let i=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(i,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(i=>i.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(i=>{i.currentTime>0&&!i.ended&&i.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{o({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>o()),requestAnimationFrame(()=>o()),{app:a,stage:a.stage,overlay:s,applySize:o}}var ct=class{constructor(t){var a,o;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(o=t==null?void 0:t.rotation)!=null?o:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,o,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(o=t==null?void 0:t.alpha)!=null?o:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,o,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=o,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let o=this.config.objects.get(t);if(!o)throw new Error(`Object config not found: ${t}`);let s=new ht(t,o.object_config||t,a,o);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,o]of this.objects.entries()){let s=t.objects.get(a);s&&o.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function En(e,t){pt[e]=t}function Dn(){return Object.keys(pt)}import{Container as Yn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function kn(e,t,a){var Dt,Yt,kt,zt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Me,Ee,De,Ye,ke,ze,He,We;let o=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),i=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((Dt=o==null?void 0:o.gameplay)==null?void 0:Dt.tuning)||{},m=(o==null?void 0:o.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(kt=l.panel_height)!=null?kt:400,_=(zt=l.panel_padding)!=null?zt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let M=new ut;M.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),M.stroke({color:16777215,width:1,alpha:.1}),T.addChild(M),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},z=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,qe=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=z,yt=z/P):(yt=z,N=z*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=z/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=qe,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},$e=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",xt=(E==null?void 0:E.font)||"brand.heading",Ve=(E==null?void 0:E.fontSize)||24,je=(jt=E==null?void 0:E.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Je=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Ke=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:$e,style:{fontFamily:X(xt),fontSize:Ve,fontWeight:Ke,fill:Je,align:"center",letterSpacing:je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Qe=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Qe),V.alpha=0,h.addChild(V);let D=i==null?void 0:i.ui,Ct=((ee=i==null?void 0:i.gameplay)==null?void 0:ee.tuning)||{},Ze=(D==null?void 0:D.text)||"RESCUE COMPLETE",St=(D==null?void 0:D.font)||"brand.body",Oe=(D==null?void 0:D.fontSize)||11,Ie=(ne=D==null?void 0:D.letterSpacing)!=null?ne:.5,nt=(ae=i==null?void 0:i.render)==null?void 0:ae.tint,Ue=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ze,style:{fontFamily:X(St),fontSize:Oe,fontWeight:q(St),fill:Ue,align:"center",letterSpacing:Ie}});Z.anchor.set(.5);let tn=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,tn),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},en=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",nn=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,an=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(ce=vt.max_width)!=null?ce:f-_*2,on=(de=vt.line_height)!=null?de:1.4,O=new tt({text:en,style:{fontFamily:X(At),fontSize:nn,fontWeight:q(At),fill:an,align:"center",wordWrap:!0,wordWrapWidth:sn,lineHeight:on}});O.anchor.set(.5);let rn=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,rn);let ln=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=ln,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},Y=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,cn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",dn=(be=G.button_bg_alpha)!=null?be:1,hn=G.button_border_color||"#ffffff",pn=(xe=G.button_border_width)!=null?xe:2,un=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let mn=cn.replace("#","");W.fill({color:parseInt(mn,16),alpha:dn});let fn=hn.replace("#","");W.stroke({color:parseInt(fn,16),width:pn,alpha:un});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let yn=(Y==null?void 0:Y.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(Y==null?void 0:Y.font)||"brand.heading",gn=(Y==null?void 0:Y.fontSize)||20,_n=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:yn,style:{fontFamily:X(Pt),fontSize:gn,fontWeight:q(Pt),fill:_n,align:"center",letterSpacing:(ve=Y==null?void 0:Y.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let k=d==null?void 0:d.ui,Mt=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},bn=(k==null?void 0:k.text)||"Play the full game",Et=(k==null?void 0:k.font)||"brand.body",xn=(k==null?void 0:k.fontSize)||11,wn=(Fe=k==null?void 0:k.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Tn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:bn,style:{fontFamily:X(Et),fontSize:xn,fontWeight:q(Et),fill:Tn,align:"center",letterSpacing:wn}});I.anchor.set(.5);let Cn=ot+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);I.position.set(0,Cn),I.alpha=0,I.animationStartYOffset=(Ee=Mt.animation_start_y_offset)!=null?Ee:5,h.addChild(I);let ft=((De=p==null?void 0:p.gameplay)==null?void 0:De.tuning)||{},Sn=(Ye=ft.hand_offset_x)!=null?Ye:50,vn=(ke=ft.hand_offset_y)!=null?ke:50,An=(He=(ze=p==null?void 0:p.transform)==null?void 0:ze.scale)!=null?He:.1875,Fn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(An*Fn),J.position.set(Sn,ot+vn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function zn(e,t,a){var v,w,T,g,A,M,B,$;let o=t.objects.get("ui_endgame_1"),s=((v=o==null?void 0:o.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,i=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(M=s.title_animation_delay_ms)!=null?M:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let z=Date.now()-x,R=Math.min(z/i,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Hn(l,n,t),c),setTimeout(()=>{Wn(m,n),setTimeout(()=>Bn(f,n),50)},d),setTimeout(()=>Rn(y,n),p),setTimeout(()=>{Ln(_,b,n),setTimeout(()=>Gn(C,n),50),a&&a()},u))};S()}function Hn(e,t,a){var h,l,m,f,y;let o=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=o==null?void 0:o.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,i=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-i,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Wn(e,t){let a=Date.now(),o=e.alpha,s=e.y,n=()=>{let i=Date.now()-a,r=Math.min(i/t,1),c=1-Math.pow(1-r,2);e.alpha=o+(1-o)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Bn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Rn(e,t){var i;let a=Date.now(),o=e.alpha,s=(i=e.targetAlpha)!=null?i:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=o+(s-o)*d,c<1&&requestAnimationFrame(n)};n()}function Ln(e,t,a){let o=Date.now(),s=e.alpha,n=()=>{let i=Date.now()-o,r=Math.min(i/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Gn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Nn(e,t,a,o){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},i=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var z,R,j;let T=Date.now()-x,g=Math.min(T/i,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let M=(R=(z=s==null?void 0:s.transform)==null?void 0:z.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=M*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),o()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as Xn,Text as qn}from"pixi.js";function $n(e,t,a){var p,u,h,l;let o=t.objects.get("hand_tutorial_1"),s=((p=o==null?void 0:o.gameplay)==null?void 0:p.tuning)||{},n=(o==null?void 0:o.render)||{},i=(o==null?void 0:o.transform)||{},r=new Xn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=i.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,o=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},i=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=o.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new qn({text:i,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=o.alpha)!=null?v:0,l.visible=(w=o.visible)!=null?w:!0,l}function jn(e,t,a,o,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),i=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!o){let f=(d=i.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=i.x_offset)!=null?p:0,C=(u=i.y_offset)!=null?u:0,x=(h=i.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let M=(l=r.scale)!=null?l:.1875,B=(m=i.hand_scale_multiplier)!=null?m:2.5;e.scale.set(M*B)}}import{Graphics as Ge,Assets as Ne,Texture as Jn,Rectangle as Kn,Color as bt}from"pixi.js";async function Xe(e,t,a=16777215,o=!1){try{let n=(globalThis.INLINE_ASSETS||{})[e];return await Ne.load(n||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return o?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Qn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let s=(globalThis.INLINE_ASSETS||{})[e]||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let M=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await Xe(e,t,new bt(M).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let i=n.source||n.baseTexture||n;i&&"valid"in i&&i.valid===!1&&typeof i.once=="function"&&await new Promise(g=>i.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=i==null?void 0:i.width)!=null?_:i==null?void 0:i.pixelWidth)!=null?C:(b=i==null?void 0:i.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=i==null?void 0:i.height)!=null?S:i==null?void 0:i.pixelHeight)!=null?w:(v=i==null?void 0:i.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!i)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Jn({source:i,frame:new Kn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Zn(e,t){var p,u,h,l;let a=t.gameplay.brush||{},o=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,i=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:o,alpha:i}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,zn as animatePanelEntrance,Zn as createBrushTexture,kn as createEndGamePanel,$n as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,Dn as getRegisteredFontIds,Xe as loadAsset,Qn as loadCharacterFrames,En as registerFont,X as resolveFont,q as resolveFontWeight,jn as updateHandAnimation};
|
|
1
|
+
import{b as lt}from"../chunk-KK4RWSSF.mjs";import{Application as Pn}from"pixi.js";async function Mn(e,t={}){let a=new Pn;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let o=n=>{var c,d,p,u,h,l;let i=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(i,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(i=>i.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(i=>{i.currentTime>0&&!i.ended&&i.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{o({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>o()),requestAnimationFrame(()=>o()),{app:a,stage:a.stage,overlay:s,applySize:o}}var ct=class{constructor(t){var a,o;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(o=t==null?void 0:t.rotation)!=null?o:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,o,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(o=t==null?void 0:t.alpha)!=null?o:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,o,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=o,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let o=this.config.objects.get(t);if(!o)throw new Error(`Object config not found: ${t}`);let s=new ht(t,o.object_config||t,a,o);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,o]of this.objects.entries()){let s=t.objects.get(a);s&&o.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function En(e,t){pt[e]=t}function Dn(){return Object.keys(pt)}import{Container as Yn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function kn(e,t,a){var Dt,Yt,kt,zt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Me,Ee,De,Ye,ke,ze,He,We;let o=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),i=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((Dt=o==null?void 0:o.gameplay)==null?void 0:Dt.tuning)||{},m=(o==null?void 0:o.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(kt=l.panel_height)!=null?kt:400,_=(zt=l.panel_padding)!=null?zt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let M=new ut;M.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),M.stroke({color:16777215,width:1,alpha:.1}),T.addChild(M),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},z=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,qe=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=z,yt=z/P):(yt=z,N=z*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=z/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=qe,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},$e=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",xt=(E==null?void 0:E.font)||"brand.heading",Ve=(E==null?void 0:E.fontSize)||24,je=(jt=E==null?void 0:E.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Je=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Ke=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:$e,style:{fontFamily:X(xt),fontSize:Ve,fontWeight:Ke,fill:Je,align:"center",letterSpacing:je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Qe=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Qe),V.alpha=0,h.addChild(V);let D=i==null?void 0:i.ui,Ct=((ee=i==null?void 0:i.gameplay)==null?void 0:ee.tuning)||{},Ze=(D==null?void 0:D.text)||"RESCUE COMPLETE",St=(D==null?void 0:D.font)||"brand.body",Oe=(D==null?void 0:D.fontSize)||11,Ie=(ne=D==null?void 0:D.letterSpacing)!=null?ne:.5,nt=(ae=i==null?void 0:i.render)==null?void 0:ae.tint,Ue=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ze,style:{fontFamily:X(St),fontSize:Oe,fontWeight:q(St),fill:Ue,align:"center",letterSpacing:Ie}});Z.anchor.set(.5);let tn=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,tn),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},en=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",nn=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,an=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(ce=vt.max_width)!=null?ce:f-_*2,on=(de=vt.line_height)!=null?de:1.4,O=new tt({text:en,style:{fontFamily:X(At),fontSize:nn,fontWeight:q(At),fill:an,align:"center",wordWrap:!0,wordWrapWidth:sn,lineHeight:on}});O.anchor.set(.5);let rn=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,rn);let ln=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=ln,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},Y=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,cn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",dn=(be=G.button_bg_alpha)!=null?be:1,hn=G.button_border_color||"#ffffff",pn=(xe=G.button_border_width)!=null?xe:2,un=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let mn=cn.replace("#","");W.fill({color:parseInt(mn,16),alpha:dn});let fn=hn.replace("#","");W.stroke({color:parseInt(fn,16),width:pn,alpha:un});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let yn=(Y==null?void 0:Y.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(Y==null?void 0:Y.font)||"brand.heading",gn=(Y==null?void 0:Y.fontSize)||20,_n=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:yn,style:{fontFamily:X(Pt),fontSize:gn,fontWeight:q(Pt),fill:_n,align:"center",letterSpacing:(ve=Y==null?void 0:Y.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let k=d==null?void 0:d.ui,Mt=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},bn=(k==null?void 0:k.text)||"Play the full game",Et=(k==null?void 0:k.font)||"brand.body",xn=(k==null?void 0:k.fontSize)||11,wn=(Fe=k==null?void 0:k.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Tn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:bn,style:{fontFamily:X(Et),fontSize:xn,fontWeight:q(Et),fill:Tn,align:"center",letterSpacing:wn}});I.anchor.set(.5);let Cn=ot+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);I.position.set(0,Cn),I.alpha=0,I.animationStartYOffset=(Ee=Mt.animation_start_y_offset)!=null?Ee:5,h.addChild(I);let ft=((De=p==null?void 0:p.gameplay)==null?void 0:De.tuning)||{},Sn=(Ye=ft.hand_offset_x)!=null?Ye:50,vn=(ke=ft.hand_offset_y)!=null?ke:50,An=(He=(ze=p==null?void 0:p.transform)==null?void 0:ze.scale)!=null?He:.1875,Fn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(An*Fn),J.position.set(Sn,ot+vn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function zn(e,t,a){var v,w,T,g,A,M,B,$;let o=t.objects.get("ui_endgame_1"),s=((v=o==null?void 0:o.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,i=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(M=s.title_animation_delay_ms)!=null?M:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let z=Date.now()-x,R=Math.min(z/i,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Hn(l,n,t),c),setTimeout(()=>{Wn(m,n),setTimeout(()=>Bn(f,n),50)},d),setTimeout(()=>Rn(y,n),p),setTimeout(()=>{Ln(_,b,n),setTimeout(()=>Gn(C,n),50),a&&a()},u))};S()}function Hn(e,t,a){var h,l,m,f,y;let o=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=o==null?void 0:o.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,i=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-i,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Wn(e,t){let a=Date.now(),o=e.alpha,s=e.y,n=()=>{let i=Date.now()-a,r=Math.min(i/t,1),c=1-Math.pow(1-r,2);e.alpha=o+(1-o)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Bn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Rn(e,t){var i;let a=Date.now(),o=e.alpha,s=(i=e.targetAlpha)!=null?i:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=o+(s-o)*d,c<1&&requestAnimationFrame(n)};n()}function Ln(e,t,a){let o=Date.now(),s=e.alpha,n=()=>{let i=Date.now()-o,r=Math.min(i/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Gn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Nn(e,t,a,o){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},i=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var z,R,j;let T=Date.now()-x,g=Math.min(T/i,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let M=(R=(z=s==null?void 0:s.transform)==null?void 0:z.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=M*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),o()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as Xn,Text as qn}from"pixi.js";function $n(e,t,a){var p,u,h,l;let o=t.objects.get("hand_tutorial_1"),s=((p=o==null?void 0:o.gameplay)==null?void 0:p.tuning)||{},n=(o==null?void 0:o.render)||{},i=(o==null?void 0:o.transform)||{},r=new Xn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=i.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,o=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},i=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=o.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new qn({text:i,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=o.alpha)!=null?v:0,l.visible=(w=o.visible)!=null?w:!0,l}function jn(e,t,a,o,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),i=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!o){let f=(d=i.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=i.x_offset)!=null?p:0,C=(u=i.y_offset)!=null?u:0,x=(h=i.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let M=(l=r.scale)!=null?l:.1875,B=(m=i.hand_scale_multiplier)!=null?m:2.5;e.scale.set(M*B)}}import{Graphics as Ge,Assets as Ne,Texture as Jn,Rectangle as Kn,Color as bt}from"pixi.js";async function Xe(e,t,a=16777215,o=!1){try{let n=(globalThis.INLINE_ASSETS||{})[e];return await Ne.load(n||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return o?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Qn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let s=(globalThis.INLINE_ASSETS||{})[e]||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let M=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await Xe(e,t,new bt(M).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let i=n.source||n.baseTexture||n;i&&"valid"in i&&i.valid===!1&&typeof i.once=="function"&&await new Promise(g=>i.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=i==null?void 0:i.width)!=null?_:i==null?void 0:i.pixelWidth)!=null?C:(b=i==null?void 0:i.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=i==null?void 0:i.height)!=null?S:i==null?void 0:i.pixelHeight)!=null?w:(v=i==null?void 0:i.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!i)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Jn({source:i,frame:new Kn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Zn(e,t){var p,u,h,l;let a=t.gameplay.brush||{},o=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,i=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:o,alpha:i}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,zn as animatePanelEntrance,Zn as createBrushTexture,kn as createEndGamePanel,$n as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,Dn as getRegisteredFontIds,Xe as loadAsset,Qn as loadCharacterFrames,En as registerFont,X as resolveFont,q as resolveFontWeight,jn as updateHandAnimation};
|
package/dist/three/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ni=Object.create;var Le=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var si=Object.getPrototypeOf,oi=Object.prototype.hasOwnProperty;var ri=(e,t)=>{for(var n in t)Le(e,n,{get:t[n],enumerable:!0})},Rn=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ii(t))!oi.call(e,i)&&i!==n&&Le(e,i,{get:()=>t[i],enumerable:!(a=ai(t,i))||a.enumerable});return e};var be=(e,t,n)=>(n=e!=null?ni(si(e)):{},Rn(t||!e||!e.__esModule?Le(n,"default",{value:e,enumerable:!0}):n,e)),li=e=>Rn(Le({},"__esModule",{value:!0}),e);var Ri={};ri(Ri,{GameObject:()=>Ce,GameObjectManager:()=>Ne,Renderer:()=>Ae,Transform:()=>Se,animateHandClick:()=>la,animatePanelEntrance:()=>ra,createBrushTexture:()=>fa,createEndGamePanel:()=>oa,createHandTutorial:()=>ca,createThreeBase:()=>aa,createTutorialLabel:()=>da,getRegisteredFontIds:()=>sa,loadAsset:()=>st,loadCharacterFrames:()=>ma,registerFont:()=>ia,resolveFont:()=>B,resolveFontWeight:()=>O,updateHandAnimation:()=>pa});module.exports=li(Ri);var fe=be(require("three"));var K={};function Fe(e,t,n=!1){K[e]||(K[e]=[]),K[e].push({fn:t,once:n})}function Qe(e,t){if(K[e]){if(!t){delete K[e];return}K[e]=K[e].filter(n=>n.fn!==t)}}function De(e,...t){let n=K[e];if(n)for(let a of[...n])a.fn(...t),a.once&&Qe(e,a.fn)}function P(e,t){Fe(e,t,!0)}var $e={name:"handler-playable-sdk",version:"0.1.5",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var z=0,di=z++,Hn=z++,Mn=z++,kn=z++,Ln=z++,Fn=z++,Dn=z++,$n=z++,Pn=z++,zn=z++,Wn=z++,Bn=z++,S=di;function On(){return S===Hn}function Nn(){return S===Mn}function Yn(){return S===kn}function In(){return S===Ln}function re(){return S===Fn}function le(){return S===Dn}function Gn(){return S===$n}function jn(){return S===Pn}function Vn(){return S===zn}function Ze(){return S===Wn}function Ue(){return S===Bn}function qn(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),S=Hn;return}catch{}else if(e==="dapi")try{dapi.isReady(),S=Mn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(S=kn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(S=Ln)}catch{}else if(t==="mintegral")window.gameReady&&(S=Fn);else if(t==="tapjoy")window.TJ_API&&(S=Dn);else if(t==="tiktok")window.openAppStore&&(S=$n);else if(t==="smadex")try{window.smxTracking&&(S=Pn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(S=zn)}catch{}else t==="vungle"?S=Wn:(e==="nucleo"||t==="nucleo")&&(S=Bn)}var Un={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},pi=Math.random().toString(36).slice(2),ce=null,xe={...Un},ea="web_embed",ui={},et=!1,_e=!1,Ee=!1,ta=!1,it=1,nt=0,Be=!1,q=!1,We="",de=Math.floor(window.innerWidth),pe=Math.floor(window.innerHeight),at=de>pe,X=!1,we=!1,Xn=!1,Kn=!1,tt=!1,Pe=null;function Jn(){if(ce)return ce;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),ce=e,e}function ze(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function na(e,t){return{event_name:e,ts:Date.now(),session_id:pi,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:ea==="mraid"?"mraid":"web",payload:t}}function _(e,t){let n=ze(e),a=na(n,t);De(n,a),n!==e&&De(e,a)}function Te(){Pe&&(Pe(de,pe),Pe=null)}function ue(e){it=e,_("volume",e)}function me(e){e&&(ta=!0),!Ee&&(Ee=!0,_("pause"),ue(0))}function ve(e){!e&&ta||Ee&&(Ee=!1,_("resume"),ue(it))}function Q(e,t){de=Math.floor(e||window.innerWidth),pe=Math.floor(t||window.innerHeight),at=de>pe,_("resize",{width:de,height:pe})}function mi(){if(On())try{let e=mraid.getMaxSize();Q(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():me()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();Q(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ue(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ue(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Be=!0,mraid.isViewable()&&mraid.getState()!=="hidden")X=!0,_("boot"),_("view"),_("ready"),q=!0,Te();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function fi(){if(Nn())try{let e=dapi.getScreenSize();Q(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():me()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();Q(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(ue(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ue(n?1:0)),Be=!0,dapi.isViewable())X=!0,_("boot"),_("view"),_("ready"),q=!0,Te();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function Qn(){let e=()=>{X||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(X=!0,_("boot"),_("view"),_("ready"),q=!0,Te(),we&&(we=!1,J.start()))};window.addEventListener("resize",()=>Q()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):me()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Be=!0}function yi(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Xn=!0),!(Xn&&t instanceof MouseEvent)&&(nt+=1,_("interaction",nt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function hi(e){var a,i,s,o,l,c,m,r,d,u,h,b;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(le())(s=(i=window.TJ_API)==null?void 0:i.click)==null||s.call(i);else if(Yn())(l=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||l.call(o);else if(Vn())(m=(c=window.ScPlayableAd)==null?void 0:c.onCTAClick)==null||m.call(c);else if(jn())try{(d=(r=window.smxTracking)==null?void 0:r.redirect)==null||d.call(r)}catch(p){console.warn("Smadex redirect failed",p)}else if(In()){let p=window.ExitApi;p&&typeof p.exit=="function"?p.exit(e||We||""):e&&window.open(e)}else re()?(u=window.install)==null||u.call(window):Gn()?(h=window.openAppStore)==null||h.call(window):Ze()?(b=parent==null?void 0:parent.postMessage)==null||b.call(parent,"download","*"):e&&window.open(e)}function gi(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;P("view",()=>t(n.mraid_viewable)),P("start",()=>t(n.game_viewable)),P("engagement",()=>t(n.engagement));let a=()=>t(n.complete);P("complete",a),Fe("engagement",i=>{var s;((s=i==null?void 0:i.payload)==null?void 0:s.count)>3&&a()}),P("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;P("view",()=>t(n.Ad_Load_Start)),P("start",()=>t(n.Ad_Viewable)),P("engagement",()=>t(n.First_Engagement)),P("complete",()=>t(n.Gameplay_Complete)),P("cta_click",()=>t(n.DSP_Click)),P("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function bi(){if(!le())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{J.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Zn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function _i(){re()&&(window.mintGameStart=()=>{ve(!0),Q()},window.mintGameClose=()=>{me(!0)})}function xi(){if(!Ue())return;let e=window.NUC;!e||!e.trigger||(J.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,We)}),J.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var J={init(e={},t){if(ea=e.profile||"web_embed",ui=e.consent||{},xe={...Un,...e.ids||{}},ce=e.rootEl||ce,We=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Pe=t),_("init"),document.body.oncontextmenu=()=>!1,Jn(),wi(ce),qn(),mi(),fi(),!Be){if(document.readyState==="complete")Qn();else if(!Kn){Kn=!0;let n=()=>{Qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}yi(),gi(),bi(),_i(),xi(),console.log(`%c @handler/playable-sdk %c v${$e.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),X&&!q&&(_("boot"),_("view"),_("ready"),we&&(we=!1,J.start()),q=!0),q=X},getRoot(){return Jn()},get version(){return $e.version||"0.0.0"},get maxWidth(){return de},get maxHeight(){return pe},get isLandscape(){return at},get isReady(){return q},get isStarted(){return et},get isPaused(){return Ee},get isFinished(){return _e},get volume(){return it},get interactions(){return nt},on(e,t){Fe(ze(e),t)},off(e,t){Qe(ze(e),t)},start(){var e,t;if(!et){if(!X){we=!0;return}if(et=!0,_("start"),Q(),re())me(),(e=window.gameReady)==null||e.call(window);else if(le()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:at?"landscape":"portrait",buildID:$e.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,_("complete"),re()?(e=window.gameEnd)==null||e.call(window):Ze()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):le()&&Zn())},install(e){if(!_e){_e=!0,le()?(Zn(),setTimeout(()=>J.install(e),300)):(_("complete"),setTimeout(()=>J.install(e),0));return}tt||(tt=!0,setTimeout(()=>tt=!1,500),_("cta_click"),_("conversion"),hi(e||We))},emit(e,t){let n=ze(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=na(n,t);De(n,a)},retry(){var e,t,n;if(re())(e=window.gameRetry)==null||e.call(window);else if(Ue()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}_("engagement",{action:"retry"})},pause(){me(!0)},resume(){ve(!0)},resize(e,t){Q(e,t)}},Oe=J;function wi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var ni=Object.create;var Le=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var si=Object.getPrototypeOf,oi=Object.prototype.hasOwnProperty;var ri=(e,t)=>{for(var n in t)Le(e,n,{get:t[n],enumerable:!0})},Rn=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ii(t))!oi.call(e,i)&&i!==n&&Le(e,i,{get:()=>t[i],enumerable:!(a=ai(t,i))||a.enumerable});return e};var be=(e,t,n)=>(n=e!=null?ni(si(e)):{},Rn(t||!e||!e.__esModule?Le(n,"default",{value:e,enumerable:!0}):n,e)),li=e=>Rn(Le({},"__esModule",{value:!0}),e);var Ri={};ri(Ri,{GameObject:()=>Ce,GameObjectManager:()=>Ne,Renderer:()=>Ae,Transform:()=>Se,animateHandClick:()=>la,animatePanelEntrance:()=>ra,createBrushTexture:()=>fa,createEndGamePanel:()=>oa,createHandTutorial:()=>ca,createThreeBase:()=>aa,createTutorialLabel:()=>da,getRegisteredFontIds:()=>sa,loadAsset:()=>st,loadCharacterFrames:()=>ma,registerFont:()=>ia,resolveFont:()=>B,resolveFontWeight:()=>O,updateHandAnimation:()=>pa});module.exports=li(Ri);var fe=be(require("three"));var K={};function Fe(e,t,n=!1){K[e]||(K[e]=[]),K[e].push({fn:t,once:n})}function Ze(e,t){if(K[e]){if(!t){delete K[e];return}K[e]=K[e].filter(n=>n.fn!==t)}}function De(e,...t){let n=K[e];if(n)for(let a of[...n])a.fn(...t),a.once&&Ze(e,a.fn)}function P(e,t){Fe(e,t,!0)}var $e={name:"handler-playable-sdk",version:"0.1.6",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var z=0,di=z++,Hn=z++,Mn=z++,kn=z++,Ln=z++,Fn=z++,Dn=z++,$n=z++,Pn=z++,zn=z++,Wn=z++,Bn=z++,S=di;function On(){return S===Hn}function Nn(){return S===Mn}function Yn(){return S===kn}function In(){return S===Ln}function re(){return S===Fn}function le(){return S===Dn}function Gn(){return S===$n}function jn(){return S===Pn}function Vn(){return S===zn}function Qe(){return S===Wn}function Ue(){return S===Bn}function qn(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),S=Hn;return}catch{}else if(e==="dapi")try{dapi.isReady(),S=Mn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(S=kn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(S=Ln)}catch{}else if(t==="mintegral")window.gameReady&&(S=Fn);else if(t==="tapjoy")window.TJ_API&&(S=Dn);else if(t==="tiktok")window.openAppStore&&(S=$n);else if(t==="smadex")try{window.smxTracking&&(S=Pn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(S=zn)}catch{}else t==="vungle"?S=Wn:(e==="nucleo"||t==="nucleo")&&(S=Bn)}var Un={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},pi=Math.random().toString(36).slice(2),ce=null,xe={...Un},ea="web_embed",ui={},et=!1,_e=!1,Ee=!1,ta=!1,it=1,nt=0,Be=!1,q=!1,We="",de=Math.floor(window.innerWidth),pe=Math.floor(window.innerHeight),at=de>pe,X=!1,we=!1,Xn=!1,Kn=!1,tt=!1,Pe=null;function Jn(){if(ce)return ce;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),ce=e,e}function ze(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function na(e,t){return{event_name:e,ts:Date.now(),session_id:pi,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:ea==="mraid"?"mraid":"web",payload:t}}function _(e,t){let n=ze(e),a=na(n,t);De(n,a),n!==e&&De(e,a)}function Te(){Pe&&(Pe(de,pe),Pe=null)}function ue(e){it=e,_("volume",e)}function me(e){e&&(ta=!0),!Ee&&(Ee=!0,_("pause"),ue(0))}function ve(e){!e&&ta||Ee&&(Ee=!1,_("resume"),ue(it))}function Z(e,t){de=Math.floor(e||window.innerWidth),pe=Math.floor(t||window.innerHeight),at=de>pe,_("resize",{width:de,height:pe})}function mi(){if(On())try{let e=mraid.getMaxSize();Z(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():me()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();Z(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ue(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ue(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Be=!0,mraid.isViewable()&&mraid.getState()!=="hidden")X=!0,_("boot"),_("view"),_("ready"),q=!0,Te();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function fi(){if(Nn())try{let e=dapi.getScreenSize();Z(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():me()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();Z(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(ue(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ue(n?1:0)),Be=!0,dapi.isViewable())X=!0,_("boot"),_("view"),_("ready"),q=!0,Te();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function Zn(){let e=()=>{X||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(X=!0,_("boot"),_("view"),_("ready"),q=!0,Te(),we&&(we=!1,J.start()))};window.addEventListener("resize",()=>Z()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):me()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Be=!0}function yi(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Xn=!0),!(Xn&&t instanceof MouseEvent)&&(nt+=1,_("interaction",nt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function hi(e){var a,i,s,o,l,c,m,r,d,u,h,b;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(le())(s=(i=window.TJ_API)==null?void 0:i.click)==null||s.call(i);else if(Yn())(l=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||l.call(o);else if(Vn())(m=(c=window.ScPlayableAd)==null?void 0:c.onCTAClick)==null||m.call(c);else if(jn())try{(d=(r=window.smxTracking)==null?void 0:r.redirect)==null||d.call(r)}catch(p){console.warn("Smadex redirect failed",p)}else if(In()){let p=window.ExitApi;p&&typeof p.exit=="function"?p.exit(e||We||""):e&&window.open(e)}else re()?(u=window.install)==null||u.call(window):Gn()?(h=window.openAppStore)==null||h.call(window):Qe()?(b=parent==null?void 0:parent.postMessage)==null||b.call(parent,"download","*"):e&&window.open(e)}function gi(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;P("view",()=>t(n.mraid_viewable)),P("start",()=>t(n.game_viewable)),P("engagement",()=>t(n.engagement));let a=()=>t(n.complete);P("complete",a),Fe("engagement",i=>{var s;((s=i==null?void 0:i.payload)==null?void 0:s.count)>3&&a()}),P("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;P("view",()=>t(n.Ad_Load_Start)),P("start",()=>t(n.Ad_Viewable)),P("engagement",()=>t(n.First_Engagement)),P("complete",()=>t(n.Gameplay_Complete)),P("cta_click",()=>t(n.DSP_Click)),P("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function bi(){if(!le())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{J.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Qn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function _i(){re()&&(window.mintGameStart=()=>{ve(!0),Z()},window.mintGameClose=()=>{me(!0)})}function xi(){if(!Ue())return;let e=window.NUC;!e||!e.trigger||(J.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,We)}),J.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var J={init(e={},t){if(ea=e.profile||"web_embed",ui=e.consent||{},xe={...Un,...e.ids||{}},ce=e.rootEl||ce,We=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Pe=t),_("init"),document.body.oncontextmenu=()=>!1,Jn(),wi(ce),qn(),mi(),fi(),!Be){if(document.readyState==="complete")Zn();else if(!Kn){Kn=!0;let n=()=>{Zn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}yi(),gi(),bi(),_i(),xi(),console.log(`%c @handler/playable-sdk %c v${$e.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),X&&!q&&(_("boot"),_("view"),_("ready"),we&&(we=!1,J.start()),q=!0),q=X},getRoot(){return Jn()},get version(){return $e.version||"0.0.0"},get maxWidth(){return de},get maxHeight(){return pe},get isLandscape(){return at},get isReady(){return q},get isStarted(){return et},get isPaused(){return Ee},get isFinished(){return _e},get volume(){return it},get interactions(){return nt},on(e,t){Fe(ze(e),t)},off(e,t){Ze(ze(e),t)},start(){var e,t;if(!et){if(!X){we=!0;return}if(et=!0,_("start"),Z(),re())me(),(e=window.gameReady)==null||e.call(window);else if(le()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:at?"landscape":"portrait",buildID:$e.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,_("complete"),re()?(e=window.gameEnd)==null||e.call(window):Qe()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):le()&&Qn())},install(e){if(!_e){_e=!0,le()?(Qn(),setTimeout(()=>J.install(e),300)):(_("complete"),setTimeout(()=>J.install(e),0));return}tt||(tt=!0,setTimeout(()=>tt=!1,500),_("cta_click"),_("conversion"),hi(e||We))},emit(e,t){let n=ze(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=na(n,t);De(n,a)},retry(){var e,t,n;if(re())(e=window.gameRetry)==null||e.call(window);else if(Ue()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}_("engagement",{action:"retry"})},pause(){me(!0)},resume(){ve(!0)},resize(e,t){Z(e,t)}},Oe=J;function wi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
2
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
16
16
|
})();
|
|
17
|
-
`,e.appendChild(t)}async function aa(e,t={}){let n=()=>{let p=e.style.width||"",f=e.style.height||"",y=320,g=480,E=window.getComputedStyle(e),w=p||E.width,T=f||E.height;if(w&&w!=="auto"&&!w.includes("%")){let x=parseFloat(w);!isNaN(x)&&x>0&&isFinite(x)&&(y=x)}if(T&&T!=="auto"&&!T.includes("%")){let x=parseFloat(T);!isNaN(x)&&x>0&&isFinite(x)&&(g=x)}let A=e.clientWidth,v=e.clientHeight;if((y===320||y<=0||!isFinite(y))&&A&&A>0&&(y=A),(g===480||g<=0||!isFinite(g))&&v&&v>0&&(g=v),y<=0||g<=0||!isFinite(y)||!isFinite(g)){let x=e.getBoundingClientRect();x.width>0&&isFinite(x.width)&&(y=x.width),x.height>0&&isFinite(x.height)&&(g=x.height)}return(y<=0||!isFinite(y))&&(y=e.clientWidth||window.innerWidth||320),(g<=0||!isFinite(g))&&(g=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:y,height:g,styleWidth:p,styleHeight:f,effectiveWidth:w,effectiveHeight:T,computedWidth:E.width,computedHeight:E.height,clientWidth:A,clientHeight:v,boundingRect:e.getBoundingClientRect()}),{width:y,height:g}},a=e.style.width&&!e.style.width.includes("%"),i=e.style.height&&!e.style.height.includes("%");e.style.position=e.style.position||"relative",e.style.display=e.style.display||"block",e.style.boxSizing=e.style.boxSizing||"border-box",e.style.overflow=e.style.overflow||"hidden",a||(e.style.width=e.style.width||"100%"),i||(e.style.height=e.style.height||"100%"),t.background&&(e.style.background=t.background);let s=document.createElement("div");s.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","display:block",`background:${t.background||"transparent"}`,"color:var(--h-text, #f4f6ff)",'font-family:var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif)',"box-sizing:border-box"].join(";")),e.appendChild(s);let o=document.createElement("div");o.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),s.appendChild(o);let l=new fe.Scene,{width:c,height:m}=n(),r=new fe.OrthographicCamera(-c/2,c/2,m/2,-m/2,.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0);let d=new fe.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});d.setPixelRatio(window.devicePixelRatio||1),d.setSize(c,m),d.setClearColor(0,0),d.domElement.style.position="absolute",d.domElement.style.top="0",d.domElement.style.left="0",d.domElement.style.width="100%",d.domElement.style.height="100%",d.domElement.style.display="block",d.domElement.style.pointerEvents="auto",o.appendChild(d.domElement);let u=p=>{let f,y;if(typeof(p==null?void 0:p.width)=="number"&&p.width>0?f=p.width:f=n().width,typeof(p==null?void 0:p.height)=="number"&&p.height>0?y=p.height:y=n().height,f<=0||y<=0||!isFinite(f)||!isFinite(y)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:f,newHeight:y,size:p});let g=n();f=g.width,y=g.height}console.log("[THREE-BASE] applySize:",{newWidth:f,newHeight:y,providedSize:p,containerSize:n()}),d.setSize(f,y),d.setPixelRatio(window.devicePixelRatio||1),r.left=-f/2,r.right=f/2,r.top=y/2,r.bottom=-y/2,r.updateProjectionMatrix()};requestAnimationFrame(()=>u());let h=!1;Oe.on("pause",()=>{h=!0,document.querySelectorAll("audio").forEach(f=>f.pause())}),Oe.on("resume",()=>{h=!1,document.querySelectorAll("audio").forEach(f=>{f.currentTime>0&&!f.ended&&f.play().catch(()=>{})})}),Oe.on("resize",({payload:p})=>{u({width:p==null?void 0:p.width,height:p==null?void 0:p.height})}),window.addEventListener("resize",()=>u());let b=document.createElement("div");return b.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(b),{scene:l,camera:r,renderer:d,overlay:b,applySize:u}}var R=be(require("three")),Se=class{constructor(t){var n,a;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(a=t==null?void 0:t.rotation)!=null?a:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){t.position.set(this.position.x,this.position.y,
|
|
17
|
+
`,e.appendChild(t)}async function aa(e,t={}){let n=()=>{let p=e.style.width||"",f=e.style.height||"",y=320,g=480,E=window.getComputedStyle(e),w=p||E.width,T=f||E.height;if(w&&w!=="auto"&&!w.includes("%")){let x=parseFloat(w);!isNaN(x)&&x>0&&isFinite(x)&&(y=x)}if(T&&T!=="auto"&&!T.includes("%")){let x=parseFloat(T);!isNaN(x)&&x>0&&isFinite(x)&&(g=x)}let A=e.clientWidth,v=e.clientHeight;if((y===320||y<=0||!isFinite(y))&&A&&A>0&&(y=A),(g===480||g<=0||!isFinite(g))&&v&&v>0&&(g=v),y<=0||g<=0||!isFinite(y)||!isFinite(g)){let x=e.getBoundingClientRect();x.width>0&&isFinite(x.width)&&(y=x.width),x.height>0&&isFinite(x.height)&&(g=x.height)}return(y<=0||!isFinite(y))&&(y=e.clientWidth||window.innerWidth||320),(g<=0||!isFinite(g))&&(g=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:y,height:g,styleWidth:p,styleHeight:f,effectiveWidth:w,effectiveHeight:T,computedWidth:E.width,computedHeight:E.height,clientWidth:A,clientHeight:v,boundingRect:e.getBoundingClientRect()}),{width:y,height:g}},a=e.style.width&&!e.style.width.includes("%"),i=e.style.height&&!e.style.height.includes("%");e.style.position=e.style.position||"relative",e.style.display=e.style.display||"block",e.style.boxSizing=e.style.boxSizing||"border-box",e.style.overflow=e.style.overflow||"hidden",a||(e.style.width=e.style.width||"100%"),i||(e.style.height=e.style.height||"100%"),t.background&&(e.style.background=t.background);let s=document.createElement("div");s.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","display:block",`background:${t.background||"transparent"}`,"color:var(--h-text, #f4f6ff)",'font-family:var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif)',"box-sizing:border-box"].join(";")),e.appendChild(s);let o=document.createElement("div");o.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),s.appendChild(o);let l=new fe.Scene,{width:c,height:m}=n(),r=new fe.OrthographicCamera(-c/2,c/2,m/2,-m/2,.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0);let d=new fe.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});d.setPixelRatio(window.devicePixelRatio||1),d.setSize(c,m),d.setClearColor(0,0),d.domElement.style.position="absolute",d.domElement.style.top="0",d.domElement.style.left="0",d.domElement.style.width="100%",d.domElement.style.height="100%",d.domElement.style.display="block",d.domElement.style.pointerEvents="auto",o.appendChild(d.domElement);let u=p=>{let f,y;if(typeof(p==null?void 0:p.width)=="number"&&p.width>0?f=p.width:f=n().width,typeof(p==null?void 0:p.height)=="number"&&p.height>0?y=p.height:y=n().height,f<=0||y<=0||!isFinite(f)||!isFinite(y)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:f,newHeight:y,size:p});let g=n();f=g.width,y=g.height}console.log("[THREE-BASE] applySize:",{newWidth:f,newHeight:y,providedSize:p,containerSize:n()}),d.setSize(f,y),d.setPixelRatio(window.devicePixelRatio||1),r.left=-f/2,r.right=f/2,r.top=y/2,r.bottom=-y/2,r.updateProjectionMatrix()};requestAnimationFrame(()=>u());let h=!1;Oe.on("pause",()=>{h=!0,document.querySelectorAll("audio").forEach(f=>f.pause())}),Oe.on("resume",()=>{h=!1,document.querySelectorAll("audio").forEach(f=>{f.currentTime>0&&!f.ended&&f.play().catch(()=>{})})}),Oe.on("resize",({payload:p})=>{u({width:p==null?void 0:p.width,height:p==null?void 0:p.height})}),window.addEventListener("resize",()=>u());let b=document.createElement("div");return b.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(b),{scene:l,camera:r,renderer:d,overlay:b,applySize:u}}var R=be(require("three")),Se=class{constructor(t){var n,a;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(a=t==null?void 0:t.rotation)!=null?a:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,a=n===0?.5:n;t.position.set(this.position.x,this.position.y,a),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},Ae=class{constructor(t){var n,a,i,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(a=t==null?void 0:t.alpha)!=null?a:1,this.visible=(i=t==null?void 0:t.visible)!=null?i:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof R.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof R.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof R.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof R.Mesh&&t.material){let n=typeof this.tint=="string"?new R.Color(this.tint):new R.Color(this.tint);Array.isArray(t.material)?t.material.forEach(a=>{(a instanceof R.MeshBasicMaterial||a instanceof R.MeshStandardMaterial)&&a.color.copy(n)}):(t.material instanceof R.MeshBasicMaterial||t.material instanceof R.MeshStandardMaterial)&&t.material.color.copy(n)}}},Ce=class{constructor(t,n,a,i){this.instanceId=t,this.objectConfig=n,this.threeObject=a,this._config=i,this.transform=new Se(i.transform),this.renderer=new Ae(i.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},Ne=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let a=this.config.objects.get(t);if(!a)throw new Error(`Object config not found: ${t}`);let i=new Ce(t,a.object_config||t,n,a);return this.objects.set(t,i),i}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let i=t.objects.get(n);i&&a.updateConfig(i)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var Ye={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function B(e){let t=Ye[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function O(e){var n;let t=Ye[e];return t&&(n=t.weight)!=null?n:"400"}function ia(e,t){Ye[e]=t}function sa(){return Object.keys(Ye)}var ye=be(require("three"));function ie(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function oa(e,t,n){var _t,xt,wt,Et,Tt,vt,St,At,Ct,Rt,Ht,Mt,kt,Lt,Ft,Dt,$t,Pt,zt,Wt,Bt,Ot,Nt,Yt,It,Gt,jt,Vt,qt,Xt,Kt,Jt,Zt,Qt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,pn,un,mn,fn,yn,hn,gn,bn,_n,xn,wn,En,Tn,vn,Sn,An,Cn;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),s=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),m=e.objects.get("ui_endgame_cta_hint_1"),r=e.objects.get("ui_endgame_hand_1"),d=e.engine.runtime||{},u=((_t=a==null?void 0:a.gameplay)==null?void 0:_t.tuning)||{},h=(a==null?void 0:a.render)||{},b=(xt=u.panel_width)!=null?xt:320,p=(wt=u.panel_height)!=null?wt:400,f=(Et=u.panel_padding)!=null?Et:32,y=(Tt=u.panel_radius)!=null?Tt:24,g=h.background_color||u.panel_bg_color||"#1a0a0a",E=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(vt=u.panel_bg_alpha)!=null?vt:.98,w=h.border_color||u.panel_border_color||"#ffffff",T=(St=u.panel_border_width)!=null?St:2,A=(At=u.panel_border_alpha)!=null?At:.3,v=document.createElement("div");v.style.cssText=`
|
|
18
18
|
position: absolute;
|
|
19
19
|
width: ${b}px;
|
|
20
20
|
height: ${p}px;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
opacity: 0;
|
|
32
32
|
visibility: hidden;
|
|
33
33
|
pointer-events: auto;
|
|
34
|
-
`;let x=ie(v);x.element=v;let N=((Ct=i==null?void 0:i.gameplay)==null?void 0:Ct.tuning)||{},H=(i==null?void 0:i.transform)||{},k=(Rt=N.logo_size)!=null?Rt:56,W=(Ht=H.scale)!=null?Ht:1,Y=(kt=(Mt=H.offset)==null?void 0:Mt.y)!=null?kt:-130,se=(Lt=N.logo_alpha)!=null?Lt:1,
|
|
34
|
+
`;let x=ie(v);x.element=v;let N=((Ct=i==null?void 0:i.gameplay)==null?void 0:Ct.tuning)||{},H=(i==null?void 0:i.transform)||{},k=(Rt=N.logo_size)!=null?Rt:56,W=(Ht=H.scale)!=null?Ht:1,Y=(kt=(Mt=H.offset)==null?void 0:Mt.y)!=null?kt:-130,se=(Lt=N.logo_alpha)!=null?Lt:1,Q=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),C=new ye.Sprite(Q);C.position.set(0,Y,0),C.material.opacity=0;let I=0,U=0;if(n&&(I=((Ft=n.image)==null?void 0:Ft.width)||100,U=((Dt=n.image)==null?void 0:Dt.height)||100),I>0&&U>0){let oe=I/U,Ke,Je;oe>1?(Ke=k,Je=k/oe):(Je=k,Ke=k*oe);let ei=Ke/I*W,ti=Je/U*W;C.scale.set(ei,ti,1)}else{let oe=k/100*W;C.scale.set(oe,oe,1)}C.targetAlpha=se,C.baseScaleX=C.scale.x,C.baseScaleY=C.scale.y;let L=s==null?void 0:s.ui,G=(($t=s==null?void 0:s.gameplay)==null?void 0:$t.tuning)||{},ya=(L==null?void 0:L.text)||"MISSION ACCOMPLISHED",ot=(L==null?void 0:L.font)||"brand.heading",ha=(L==null?void 0:L.fontSize)||24,ga=(Pt=L==null?void 0:L.letterSpacing)!=null?Pt:1,Re=(zt=s==null?void 0:s.render)==null?void 0:zt.tint,ba=typeof Re=="string"?Re:Re?`#${Re.toString(16).padStart(6,"0")}`:"#00FF88",_a=b-f*2-30,xa=G.font_weight_override?G.font_weight_override:O(ot),ee=document.createElement("div");ee.textContent=ya,ee.style.cssText=`
|
|
35
35
|
font-family: ${B(ot)};
|
|
36
36
|
font-size: ${ha}px;
|
|
37
37
|
font-weight: ${xa};
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
position: absolute;
|
|
57
57
|
transform: translate(-50%, -50%);
|
|
58
58
|
white-space: nowrap;
|
|
59
|
-
`;let Aa=rt+20+((Xt=ct.animation_start_y_offset)!=null?Xt:-10);te.style.top=`${Aa}px`,te.style.left="50%";let Ge=ie(te);Ge.element=te,Ge.animationStartYOffset=(Kt=ct.animation_start_y_offset)!=null?Kt:-10,v.appendChild(te);let j=l==null?void 0:l.ui,pt=((Jt=l==null?void 0:l.gameplay)==null?void 0:Jt.tuning)||{},Ca=(j==null?void 0:j.text)||((
|
|
59
|
+
`;let Aa=rt+20+((Xt=ct.animation_start_y_offset)!=null?Xt:-10);te.style.top=`${Aa}px`,te.style.left="50%";let Ge=ie(te);Ge.element=te,Ge.animationStartYOffset=(Kt=ct.animation_start_y_offset)!=null?Kt:-10,v.appendChild(te);let j=l==null?void 0:l.ui,pt=((Jt=l==null?void 0:l.gameplay)==null?void 0:Jt.tuning)||{},Ca=(j==null?void 0:j.text)||((Zt=d.ui)==null?void 0:Zt.cta_hint)||"Continue the adventure!",ut=(j==null?void 0:j.font)||"brand.body",Ra=(j==null?void 0:j.fontSize)||16,Me=(Qt=l==null?void 0:l.render)==null?void 0:Qt.tint,Ha=typeof Me=="string"?Me:Me?`#${Me.toString(16).padStart(6,"0")}`:"#FFFFFF",Ma=(Ut=pt.max_width)!=null?Ut:b-f*2,ka=(en=pt.line_height)!=null?en:1.4,ne=document.createElement("div");ne.textContent=Ca,ne.style.cssText=`
|
|
60
60
|
font-family: ${B(ut)};
|
|
61
61
|
font-size: ${Ra}px;
|
|
62
62
|
font-weight: ${O(ut)};
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
position: absolute;
|
|
92
92
|
transform: translate(-50%, -50%);
|
|
93
93
|
white-space: nowrap;
|
|
94
|
-
`;let Xa=Ve+35+((xn=ht.animation_start_y_offset)!=null?xn:5);ae.style.top=`${Xa}px`,ae.style.left="50%";let qe=ie(ae);qe.element=ae,qe.animationStartYOffset=(wn=ht.animation_start_y_offset)!=null?wn:5,v.appendChild(ae);let Xe=((En=r==null?void 0:r.gameplay)==null?void 0:En.tuning)||{},Ka=(Tn=Xe.hand_offset_x)!=null?Tn:50,Ja=(vn=Xe.hand_offset_y)!=null?vn:50,
|
|
94
|
+
`;let Xa=Ve+35+((xn=ht.animation_start_y_offset)!=null?xn:5);ae.style.top=`${Xa}px`,ae.style.left="50%";let qe=ie(ae);qe.element=ae,qe.animationStartYOffset=(wn=ht.animation_start_y_offset)!=null?wn:5,v.appendChild(ae);let Xe=((En=r==null?void 0:r.gameplay)==null?void 0:En.tuning)||{},Ka=(Tn=Xe.hand_offset_x)!=null?Tn:50,Ja=(vn=Xe.hand_offset_y)!=null?vn:50,Za=(An=(Sn=r==null?void 0:r.transform)==null?void 0:Sn.scale)!=null?An:.1875,Qa=(Cn=Xe.hand_scale_multiplier)!=null?Cn:2.5,Ua=new ye.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),ge=new ye.Sprite(Ua),bt=Za*Qa*100;return ge.scale.set(bt,bt,1),ge.position.set(Ka,Ve+Ja,0),ge.material.opacity=0,ge.visible=!1,{panel:x,logo:C,title:lt,subtitle:Ge,footer:je,ctaButton:mt,ctaText:yt,ctaHint:qe,hand:ge}}function ra(e,t,n){var A,v,x,N,H,k,W,Y;let a=t.objects.get("ui_endgame_1"),i=((A=a==null?void 0:a.gameplay)==null?void 0:A.tuning)||{},s=(v=i.animation_duration_ms)!=null?v:800,o=(x=i.fade_in_duration_ms)!=null?x:600,l=(N=i.scale_animation_intensity)!=null?N:.1,c=(H=i.logo_animation_delay_ms)!=null?H:100,m=(k=i.title_animation_delay_ms)!=null?k:200,r=(W=i.footer_animation_delay_ms)!=null?W:300,d=(Y=i.cta_animation_delay_ms)!=null?Y:400,{panel:u,logo:h,title:b,subtitle:p,footer:f,ctaButton:y,ctaText:g,ctaHint:E}=e;u.visible=!0,u.element.style.visibility="visible";let w=Date.now(),T=()=>{let se=Date.now()-w,Q=Math.min(se/o,1),C=1-Math.pow(1-Q,3);u.alpha=C,u.element.style.opacity=C.toString();let I=1+l*(1-C);u.element.style.transform=`translate(-50%, -50%) scale(${I})`,Q<1?requestAnimationFrame(T):(setTimeout(()=>Ei(h,s,t),c),setTimeout(()=>{Ti(b,s),setTimeout(()=>vi(p,s),50)},m),setTimeout(()=>Si(f,s),r),setTimeout(()=>{Ai(y,g,s),setTimeout(()=>Ci(E,s),50),n&&n()},d))};T()}function Ei(e,t,n){var u,h,b,p,f;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(h=(((u=a==null?void 0:a.gameplay)==null?void 0:u.tuning)||{}).animation_start_scale)!=null?h:1.2,o=Date.now(),l=e.material.opacity,c=(b=e.targetAlpha)!=null?b:1,m=(p=e.baseScaleX)!=null?p:e.scale.x,r=(f=e.baseScaleY)!=null?f:e.scale.y,d=()=>{let y=Date.now()-o,g=Math.min(y/t,1),E=1-Math.pow(1-g,2);e.material.opacity=l+(c-l)*E;let w=s+(1-s)*E;e.scale.set(m*w,r*w,1),g<1&&requestAnimationFrame(d)};d()}function Ti(e,t){let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=()=>{let o=Date.now()-n,l=Math.min(o/t,1),c=1-Math.pow(1-l,2);e.element.style.opacity=(a+(1-a)*c).toString(),e.element.style.top=`${i-20*(1-c)}px`,l<1&&requestAnimationFrame(s)};s()}function vi(e,t){var l;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=i-((l=e.animationStartYOffset)!=null?l:-10),o=()=>{let c=Date.now()-n,m=Math.min(c/t,1),r=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*r).toString(),e.element.style.top=`${i+(s-i)*r}px`,m<1&&requestAnimationFrame(o)};o()}function Si(e,t){var o;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=(o=e.targetAlpha)!=null?o:1,s=()=>{let l=Date.now()-n,c=Math.min(l/t,1),m=1-Math.pow(1-c,2);e.element.style.opacity=(a+(i-a)*m).toString(),c<1&&requestAnimationFrame(s)};s()}function Ai(e,t,n){let a=Date.now(),i=parseFloat(e.element.style.opacity||"0"),s=()=>{let o=Date.now()-a,l=Math.min(o/n,1),c=1-Math.pow(1-l,2);e.element.style.opacity=(i+(1-i)*c).toString(),t.element.style.opacity=(i+(1-i)*c).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-c)})`,l<1&&requestAnimationFrame(s)};s()}function Ci(e,t){var l;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=i-((l=e.animationStartYOffset)!=null?l:5),o=()=>{let c=Date.now()-n,m=Math.min(c/t,1),r=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*r).toString(),e.element.style.top=`${i+(s-i)*r}px`,m<1&&requestAnimationFrame(o)};o()}function la(e,t,n,a){var r,d,u,h;let i=n.objects.get("ui_endgame_hand_1"),s=((r=i==null?void 0:i.gameplay)==null?void 0:r.tuning)||{},o=(d=s.click_animation_duration_ms)!=null?d:600,l=(u=s.click_delay_ms)!=null?u:2e3,c=(h=s.click_repeat_delay_ms)!=null?h:3e3,m=()=>{var v,x;e.visible=!0,e.material.opacity=1;let b=e.position.x,p=e.position.y,f=(v=s.hand_offset_x)!=null?v:50,y=(x=s.hand_offset_y)!=null?x:50,g=t.element.getBoundingClientRect(),E=f,w=y,T=Date.now(),A=()=>{var C,I,U;let N=Date.now()-T,H=Math.min(N/o,1),k=H<.5?2*H*H:1-Math.pow(-2*H+2,2)/2;e.position.set(b+(E-b)*k,p+(w-p)*k,0);let W=(I=(C=i==null?void 0:i.transform)==null?void 0:C.scale)!=null?I:.1875,Y=(U=s.hand_scale_multiplier)!=null?U:2.5,se=W*Y*100,Q=se+se*.2*Math.sin(H*Math.PI);e.scale.set(Q,Q,1),H<1?requestAnimationFrame(A):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",a()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(b,p,0),m()},c)},500))};A()};setTimeout(m,l)}var Ie=be(require("three"));function ca(e,t,n){var d,u,h,b;let a=t.objects.get("hand_tutorial_1"),i=((d=a==null?void 0:a.gameplay)==null?void 0:d.tuning)||{},s=(a==null?void 0:a.render)||{},o=(a==null?void 0:a.transform)||{},l=new Ie.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),c=new Ie.Sprite(l);c.position.set(n.x,n.y,0),c.material.opacity=0;let m=(u=i.hand_scale_multiplier)!=null?u:2.5,r=(h=o.scale)!=null?h:.1875;return c.scale.set(r*m*100,r*m*100,1),c.renderOrder=(b=s.z_index)!=null?b:99999,c}function da(e){var b,p,f,y,g,E,w,T,A;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},i=((b=e.engine.runtime)==null?void 0:b.ui_styles)||{},s=((p=e.engine.runtime)==null?void 0:p.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",l=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||i.label_font_size||52,m=(y=n==null?void 0:n.letterSpacing)!=null?y:(f=i.label_letter_spacing)!=null?f:-1,r=(n==null?void 0:n.align)||"center",d=a.tint,u=typeof d=="string"?d:d?`#${d.toString(16).padStart(6,"0")}`:i.label_fill||"#FFF1C1",h=document.createElement("div");return h.textContent=o,h.style.cssText=`
|
|
95
95
|
font-family: ${B(l)};
|
|
96
96
|
font-size: ${c}px;
|
|
97
97
|
font-weight: ${O(l)};
|
package/dist/three/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ot}from"../chunk-
|
|
1
|
+
import{b as ot}from"../chunk-KK4RWSSF.mjs";import*as I from"three";async function Fn(e,t={}){let n=()=>{let h=e.style.width||"",u=e.style.height||"",y=320,f=480,_=window.getComputedStyle(e),x=h||_.width,E=u||_.height;if(x&&x!=="auto"&&!x.includes("%")){let T=parseFloat(x);!isNaN(T)&&T>0&&isFinite(T)&&(y=T)}if(E&&E!=="auto"&&!E.includes("%")){let T=parseFloat(E);!isNaN(T)&&T>0&&isFinite(T)&&(f=T)}let S=e.clientWidth,w=e.clientHeight;if((y===320||y<=0||!isFinite(y))&&S&&S>0&&(y=S),(f===480||f<=0||!isFinite(f))&&w&&w>0&&(f=w),y<=0||f<=0||!isFinite(y)||!isFinite(f)){let T=e.getBoundingClientRect();T.width>0&&isFinite(T.width)&&(y=T.width),T.height>0&&isFinite(T.height)&&(f=T.height)}return(y<=0||!isFinite(y))&&(y=e.clientWidth||window.innerWidth||320),(f<=0||!isFinite(f))&&(f=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:y,height:f,styleWidth:h,styleHeight:u,effectiveWidth:x,effectiveHeight:E,computedWidth:_.width,computedHeight:_.height,clientWidth:S,clientHeight:w,boundingRect:e.getBoundingClientRect()}),{width:y,height:f}},i=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position=e.style.position||"relative",e.style.display=e.style.display||"block",e.style.boxSizing=e.style.boxSizing||"border-box",e.style.overflow=e.style.overflow||"hidden",i||(e.style.width=e.style.width||"100%"),a||(e.style.height=e.style.height||"100%"),t.background&&(e.style.background=t.background);let s=document.createElement("div");s.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","display:block",`background:${t.background||"transparent"}`,"color:var(--h-text, #f4f6ff)",'font-family:var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif)',"box-sizing:border-box"].join(";")),e.appendChild(s);let o=document.createElement("div");o.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),s.appendChild(o);let r=new I.Scene,{width:d,height:m}=n(),l=new I.OrthographicCamera(-d/2,d/2,m/2,-m/2,.1,1e3);l.position.set(0,0,1),l.lookAt(0,0,0);let c=new I.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});c.setPixelRatio(window.devicePixelRatio||1),c.setSize(d,m),c.setClearColor(0,0),c.domElement.style.position="absolute",c.domElement.style.top="0",c.domElement.style.left="0",c.domElement.style.width="100%",c.domElement.style.height="100%",c.domElement.style.display="block",c.domElement.style.pointerEvents="auto",o.appendChild(c.domElement);let p=h=>{let u,y;if(typeof(h==null?void 0:h.width)=="number"&&h.width>0?u=h.width:u=n().width,typeof(h==null?void 0:h.height)=="number"&&h.height>0?y=h.height:y=n().height,u<=0||y<=0||!isFinite(u)||!isFinite(y)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:u,newHeight:y,size:h});let f=n();u=f.width,y=f.height}console.log("[THREE-BASE] applySize:",{newWidth:u,newHeight:y,providedSize:h,containerSize:n()}),c.setSize(u,y),c.setPixelRatio(window.devicePixelRatio||1),l.left=-u/2,l.right=u/2,l.top=y/2,l.bottom=-y/2,l.updateProjectionMatrix()};requestAnimationFrame(()=>p());let g=!1;ot.on("pause",()=>{g=!0,document.querySelectorAll("audio").forEach(u=>u.pause())}),ot.on("resume",()=>{g=!1,document.querySelectorAll("audio").forEach(u=>{u.currentTime>0&&!u.ended&&u.play().catch(()=>{})})}),ot.on("resize",({payload:h})=>{p({width:h==null?void 0:h.width,height:h==null?void 0:h.height})}),window.addEventListener("resize",()=>p());let b=document.createElement("div");return b.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(b),{scene:r,camera:l,renderer:c,overlay:b,applySize:p}}import*as R from"three";var rt=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,i=n===0?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},lt=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof R.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof R.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof R.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof R.Mesh&&t.material){let n=typeof this.tint=="string"?new R.Color(this.tint):new R.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof R.MeshBasicMaterial||i instanceof R.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof R.MeshBasicMaterial||t.material instanceof R.MeshStandardMaterial)&&t.material.color.copy(n)}}},ct=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new rt(a.transform),this.renderer=new lt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},Tt=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let a=new ct(t,i.object_config||t,n,i);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let a=t.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function N(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function G(e){var n;let t=pt[e];return t&&(n=t.weight)!=null?n:"400"}function An(e,t){pt[e]=t}function Ln(){return Object.keys(pt)}import*as U from"three";function Q(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Dn(e,t,n){var Lt,Dt,Wt,kt,zt,Bt,Yt,Pt,Nt,Gt,Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,pe,de,me,he,ue,ye,fe,ge,be,Te,xe,_e,Ee,we,Se,He,Re,ve,Ce,Me,$e,Fe,Ae,Le,De,We,ke,ze,Be,Ye,Pe;let i=e.objects.get("ui_endgame_1"),a=e.objects.get("ui_endgame_logo_1"),s=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),d=e.objects.get("ui_endgame_cta_1"),m=e.objects.get("ui_endgame_cta_hint_1"),l=e.objects.get("ui_endgame_hand_1"),c=e.engine.runtime||{},p=((Lt=i==null?void 0:i.gameplay)==null?void 0:Lt.tuning)||{},g=(i==null?void 0:i.render)||{},b=(Dt=p.panel_width)!=null?Dt:320,h=(Wt=p.panel_height)!=null?Wt:400,u=(kt=p.panel_padding)!=null?kt:32,y=(zt=p.panel_radius)!=null?zt:24,f=g.background_color||p.panel_bg_color||"#1a0a0a",_=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(Bt=p.panel_bg_alpha)!=null?Bt:.98,x=g.border_color||p.panel_border_color||"#ffffff",E=(Yt=p.panel_border_width)!=null?Yt:2,S=(Pt=p.panel_border_alpha)!=null?Pt:.3,w=document.createElement("div");w.style.cssText=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: ${b}px;
|
|
4
4
|
height: ${h}px;
|
|
@@ -15,11 +15,11 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
15
15
|
opacity: 0;
|
|
16
16
|
visibility: hidden;
|
|
17
17
|
pointer-events: auto;
|
|
18
|
-
`;let T=
|
|
18
|
+
`;let T=Q(w);T.element=w;let W=((Nt=a==null?void 0:a.gameplay)==null?void 0:Nt.tuning)||{},v=(a==null?void 0:a.transform)||{},M=(Gt=W.logo_size)!=null?Gt:56,D=(Xt=v.scale)!=null?Xt:1,k=(Vt=(qt=v.offset)==null?void 0:qt.y)!=null?Vt:-130,j=(Zt=W.logo_alpha)!=null?Zt:1,X=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),H=new U.Sprite(X);H.position.set(0,k,0),H.material.opacity=0;let z=0,q=0;if(n&&(z=((Jt=n.image)==null?void 0:Jt.width)||100,q=((Kt=n.image)==null?void 0:Kt.height)||100),z>0&&q>0){let O=z/q,gt,bt;O>1?(gt=M,bt=M/O):(bt=M,gt=M*O);let Mn=gt/z*D,$n=bt/q*D;H.scale.set(Mn,$n,1)}else{let O=M/100*D;H.scale.set(O,O,1)}H.targetAlpha=j,H.baseScaleX=H.scale.x,H.baseScaleY=H.scale.y;let $=s==null?void 0:s.ui,B=((Qt=s==null?void 0:s.gameplay)==null?void 0:Qt.tuning)||{},Xe=($==null?void 0:$.text)||"MISSION ACCOMPLISHED",xt=($==null?void 0:$.font)||"brand.heading",qe=($==null?void 0:$.fontSize)||24,Ve=(jt=$==null?void 0:$.letterSpacing)!=null?jt:1,nt=(Ot=s==null?void 0:s.render)==null?void 0:Ot.tint,Ze=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#00FF88",Je=b-u*2-30,Ke=B.font_weight_override?B.font_weight_override:G(xt),V=document.createElement("div");V.textContent=Xe,V.style.cssText=`
|
|
19
19
|
font-family: ${N(xt)};
|
|
20
20
|
font-size: ${qe}px;
|
|
21
|
-
font-weight: ${
|
|
22
|
-
color: ${
|
|
21
|
+
font-weight: ${Ke};
|
|
22
|
+
color: ${Ze};
|
|
23
23
|
text-align: center;
|
|
24
24
|
letter-spacing: ${Ve}px;
|
|
25
25
|
-webkit-text-stroke: ${(It=B.stroke_width)!=null?It:2}px ${B.stroke_color||"#000000"};
|
|
@@ -28,8 +28,8 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
28
28
|
position: absolute;
|
|
29
29
|
transform: translate(-50%, -50%);
|
|
30
30
|
white-space: nowrap;
|
|
31
|
-
max-width: ${
|
|
32
|
-
`;let _t=(ae=p.title_offset_y)!=null?ae:30,
|
|
31
|
+
max-width: ${Je}px;
|
|
32
|
+
`;let _t=(ae=p.title_offset_y)!=null?ae:30,Qe=_t+((se=B.animation_start_y_offset)!=null?se:-20);V.style.top=`${Qe}px`,V.style.left="50%";let Et=Q(V);Et.element=V,w.appendChild(V);let F=o==null?void 0:o.ui,wt=((ie=o==null?void 0:o.gameplay)==null?void 0:ie.tuning)||{},je=(F==null?void 0:F.text)||"RESCUE COMPLETE",St=(F==null?void 0:F.font)||"brand.body",Oe=(F==null?void 0:F.fontSize)||11,Ie=(oe=F==null?void 0:F.letterSpacing)!=null?oe:.5,at=(re=o==null?void 0:o.render)==null?void 0:re.tint,Ue=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=document.createElement("div");Z.textContent=je,Z.style.cssText=`
|
|
33
33
|
font-family: ${N(St)};
|
|
34
34
|
font-size: ${Oe}px;
|
|
35
35
|
font-weight: ${G(St)};
|
|
@@ -40,7 +40,7 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
40
40
|
position: absolute;
|
|
41
41
|
transform: translate(-50%, -50%);
|
|
42
42
|
white-space: nowrap;
|
|
43
|
-
`;let tn=_t+20+((le=wt.animation_start_y_offset)!=null?le:-10);
|
|
43
|
+
`;let tn=_t+20+((le=wt.animation_start_y_offset)!=null?le:-10);Z.style.top=`${tn}px`,Z.style.left="50%";let mt=Q(Z);mt.element=Z,mt.animationStartYOffset=(ce=wt.animation_start_y_offset)!=null?ce:-10,w.appendChild(Z);let Y=r==null?void 0:r.ui,Ht=((pe=r==null?void 0:r.gameplay)==null?void 0:pe.tuning)||{},en=(Y==null?void 0:Y.text)||((de=c.ui)==null?void 0:de.cta_hint)||"Continue the adventure!",Rt=(Y==null?void 0:Y.font)||"brand.body",nn=(Y==null?void 0:Y.fontSize)||16,st=(me=r==null?void 0:r.render)==null?void 0:me.tint,an=typeof st=="string"?st:st?`#${st.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(he=Ht.max_width)!=null?he:b-u*2,on=(ue=Ht.line_height)!=null?ue:1.4,J=document.createElement("div");J.textContent=en,J.style.cssText=`
|
|
44
44
|
font-family: ${N(Rt)};
|
|
45
45
|
font-size: ${nn}px;
|
|
46
46
|
font-weight: ${G(Rt)};
|
|
@@ -52,7 +52,7 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
52
52
|
max-width: ${sn}px;
|
|
53
53
|
line-height: ${on};
|
|
54
54
|
word-wrap: break-word;
|
|
55
|
-
`;let rn=(ye=p.footer_offset_y)!=null?ye:120;
|
|
55
|
+
`;let rn=(ye=p.footer_offset_y)!=null?ye:120;J.style.top=`${rn}px`,J.style.left="50%";let ht=Q(J);ht.element=J;let ln=((fe=r==null?void 0:r.render)==null?void 0:fe.alpha)!==void 0&&((ge=r==null?void 0:r.render)==null?void 0:ge.alpha)!==null?r.render.alpha:1;ht.targetAlpha=ln,w.appendChild(J);let P=((be=d==null?void 0:d.gameplay)==null?void 0:be.tuning)||{},A=d==null?void 0:d.ui,cn=(Te=P.button_width)!=null?Te:260,pn=(xe=P.button_height)!=null?xe:56,dn=(_e=P.button_radius)!=null?_e:16,mn=P.button_bg_color||((Ee=c.theme)==null?void 0:Ee.cta_background)||"#ffb43b",hn=(we=P.button_bg_alpha)!=null?we:1,un=P.button_border_color||"#ffffff",yn=(Se=P.button_border_width)!=null?Se:2,Qn=(He=P.button_border_alpha)!=null?He:.2,ut=(Re=p.cta_offset_y)!=null?Re:160,C=document.createElement("button");C.style.cssText=`
|
|
56
56
|
width: ${cn}px;
|
|
57
57
|
height: ${pn}px;
|
|
58
58
|
background: ${mn};
|
|
@@ -64,7 +64,7 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
64
64
|
position: absolute;
|
|
65
65
|
transform: translate(-50%, -50%);
|
|
66
66
|
box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
|
|
67
|
-
`,C.style.top=`${ut}px`,C.style.left="50%";let vt=
|
|
67
|
+
`,C.style.top=`${ut}px`,C.style.left="50%";let vt=Q(C);vt.element=C,w.appendChild(C);let fn=(A==null?void 0:A.text)||((ve=c.ui)==null?void 0:ve.cta_label_end)||"DOWNLOAD",Ct=(A==null?void 0:A.font)||"brand.heading",gn=(A==null?void 0:A.fontSize)||20,bn=P.button_text_color||((Ce=c.theme)==null?void 0:Ce.cta_text)||"#1a0a0a";C.textContent=fn,C.style.fontFamily=N(Ct),C.style.fontSize=`${gn}px`,C.style.fontWeight=String(G(Ct)),C.style.color=bn,C.style.letterSpacing=`${(Me=A==null?void 0:A.letterSpacing)!=null?Me:1}px`;let Mt=Q(C);Mt.element=C;let L=m==null?void 0:m.ui,$t=(($e=m==null?void 0:m.gameplay)==null?void 0:$e.tuning)||{},Tn=(L==null?void 0:L.text)||"Play the full game",Ft=(L==null?void 0:L.font)||"brand.body",xn=(L==null?void 0:L.fontSize)||11,_n=(Fe=L==null?void 0:L.letterSpacing)!=null?Fe:0,it=(Ae=m==null?void 0:m.render)==null?void 0:Ae.tint,En=typeof it=="string"?it:it?`#${it.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=Tn,K.style.cssText=`
|
|
68
68
|
font-family: ${N(Ft)};
|
|
69
69
|
font-size: ${xn}px;
|
|
70
70
|
font-weight: ${G(Ft)};
|
|
@@ -75,7 +75,7 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
75
75
|
position: absolute;
|
|
76
76
|
transform: translate(-50%, -50%);
|
|
77
77
|
white-space: nowrap;
|
|
78
|
-
`;let wn=ut+35+((Le=$t.animation_start_y_offset)!=null?Le:5);
|
|
78
|
+
`;let wn=ut+35+((Le=$t.animation_start_y_offset)!=null?Le:5);K.style.top=`${wn}px`,K.style.left="50%";let yt=Q(K);yt.element=K,yt.animationStartYOffset=(De=$t.animation_start_y_offset)!=null?De:5,w.appendChild(K);let ft=((We=l==null?void 0:l.gameplay)==null?void 0:We.tuning)||{},Sn=(ke=ft.hand_offset_x)!=null?ke:50,Hn=(ze=ft.hand_offset_y)!=null?ze:50,Rn=(Ye=(Be=l==null?void 0:l.transform)==null?void 0:Be.scale)!=null?Ye:.1875,vn=(Pe=ft.hand_scale_multiplier)!=null?Pe:2.5,Cn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(Cn),At=Rn*vn*100;return et.scale.set(At,At,1),et.position.set(Sn,ut+Hn,0),et.material.opacity=0,et.visible=!1,{panel:T,logo:H,title:Et,subtitle:mt,footer:ht,ctaButton:vt,ctaText:Mt,ctaHint:yt,hand:et}}function Wn(e,t,n){var S,w,T,W,v,M,D,k;let i=t.objects.get("ui_endgame_1"),a=((S=i==null?void 0:i.gameplay)==null?void 0:S.tuning)||{},s=(w=a.animation_duration_ms)!=null?w:800,o=(T=a.fade_in_duration_ms)!=null?T:600,r=(W=a.scale_animation_intensity)!=null?W:.1,d=(v=a.logo_animation_delay_ms)!=null?v:100,m=(M=a.title_animation_delay_ms)!=null?M:200,l=(D=a.footer_animation_delay_ms)!=null?D:300,c=(k=a.cta_animation_delay_ms)!=null?k:400,{panel:p,logo:g,title:b,subtitle:h,footer:u,ctaButton:y,ctaText:f,ctaHint:_}=e;p.visible=!0,p.element.style.visibility="visible";let x=Date.now(),E=()=>{let j=Date.now()-x,X=Math.min(j/o,1),H=1-Math.pow(1-X,3);p.alpha=H,p.element.style.opacity=H.toString();let z=1+r*(1-H);p.element.style.transform=`translate(-50%, -50%) scale(${z})`,X<1?requestAnimationFrame(E):(setTimeout(()=>kn(g,s,t),d),setTimeout(()=>{zn(b,s),setTimeout(()=>Bn(h,s),50)},m),setTimeout(()=>Yn(u,s),l),setTimeout(()=>{Pn(y,f,s),setTimeout(()=>Nn(_,s),50),n&&n()},c))};E()}function kn(e,t,n){var p,g,b,h,u;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(g=(((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{}).animation_start_scale)!=null?g:1.2,o=Date.now(),r=e.material.opacity,d=(b=e.targetAlpha)!=null?b:1,m=(h=e.baseScaleX)!=null?h:e.scale.x,l=(u=e.baseScaleY)!=null?u:e.scale.y,c=()=>{let y=Date.now()-o,f=Math.min(y/t,1),_=1-Math.pow(1-f,2);e.material.opacity=r+(d-r)*_;let x=s+(1-s)*_;e.scale.set(m*x,l*x,1),f<1&&requestAnimationFrame(c)};c()}function zn(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let o=Date.now()-n,r=Math.min(o/t,1),d=1-Math.pow(1-r,2);e.element.style.opacity=(i+(1-i)*d).toString(),e.element.style.top=`${a-20*(1-d)}px`,r<1&&requestAnimationFrame(s)};s()}function Bn(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let d=Date.now()-n,m=Math.min(d/t,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a+(s-a)*l}px`,m<1&&requestAnimationFrame(o)};o()}function Yn(e,t){var o;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(o=e.targetAlpha)!=null?o:1,s=()=>{let r=Date.now()-n,d=Math.min(r/t,1),m=1-Math.pow(1-d,2);e.element.style.opacity=(i+(a-i)*m).toString(),d<1&&requestAnimationFrame(s)};s()}function Pn(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let o=Date.now()-i,r=Math.min(o/n,1),d=1-Math.pow(1-r,2);e.element.style.opacity=(a+(1-a)*d).toString(),t.element.style.opacity=(a+(1-a)*d).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-d)})`,r<1&&requestAnimationFrame(s)};s()}function Nn(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let d=Date.now()-n,m=Math.min(d/t,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a+(s-a)*l}px`,m<1&&requestAnimationFrame(o)};o()}function Gn(e,t,n,i){var l,c,p,g;let a=n.objects.get("ui_endgame_hand_1"),s=((l=a==null?void 0:a.gameplay)==null?void 0:l.tuning)||{},o=(c=s.click_animation_duration_ms)!=null?c:600,r=(p=s.click_delay_ms)!=null?p:2e3,d=(g=s.click_repeat_delay_ms)!=null?g:3e3,m=()=>{var w,T;e.visible=!0,e.material.opacity=1;let b=e.position.x,h=e.position.y,u=(w=s.hand_offset_x)!=null?w:50,y=(T=s.hand_offset_y)!=null?T:50,f=t.element.getBoundingClientRect(),_=u,x=y,E=Date.now(),S=()=>{var H,z,q;let W=Date.now()-E,v=Math.min(W/o,1),M=v<.5?2*v*v:1-Math.pow(-2*v+2,2)/2;e.position.set(b+(_-b)*M,h+(x-h)*M,0);let D=(z=(H=a==null?void 0:a.transform)==null?void 0:H.scale)!=null?z:.1875,k=(q=s.hand_scale_multiplier)!=null?q:2.5,j=D*k*100,X=j+j*.2*Math.sin(v*Math.PI);e.scale.set(X,X,1),v<1?requestAnimationFrame(S):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(b,h,0),m()},d)},500))};S()};setTimeout(m,r)}import*as dt from"three";function Xn(e,t,n){var c,p,g,b;let i=t.objects.get("hand_tutorial_1"),a=((c=i==null?void 0:i.gameplay)==null?void 0:c.tuning)||{},s=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new dt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),d=new dt.Sprite(r);d.position.set(n.x,n.y,0),d.material.opacity=0;let m=(p=a.hand_scale_multiplier)!=null?p:2.5,l=(g=o.scale)!=null?g:.1875;return d.scale.set(l*m*100,l*m*100,1),d.renderOrder=(b=s.z_index)!=null?b:99999,d}function qn(e){var b,h,u,y,f,_,x,E,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((b=e.engine.runtime)==null?void 0:b.ui_styles)||{},s=((h=e.engine.runtime)==null?void 0:h.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",d=(n==null?void 0:n.fontSize)||a.label_font_size||52,m=(y=n==null?void 0:n.letterSpacing)!=null?y:(u=a.label_letter_spacing)!=null?u:-1,l=(n==null?void 0:n.align)||"center",c=i.tint,p=typeof c=="string"?c:c?`#${c.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",g=document.createElement("div");return g.textContent=o,g.style.cssText=`
|
|
79
79
|
font-family: ${N(r)};
|
|
80
80
|
font-size: ${d}px;
|
|
81
81
|
font-weight: ${G(r)};
|
|
@@ -90,4 +90,4 @@ import{b as ot}from"../chunk-XHKJ4F4G.mjs";import*as I from"three";async functio
|
|
|
90
90
|
position: absolute;
|
|
91
91
|
transform: translate(-50%, -50%);
|
|
92
92
|
white-space: nowrap;
|
|
93
|
-
`,g}function Vn(e,t,n,i,a){var d,m,l,c,p,g,b;let s=a.objects.get("hand_tutorial_1"),o=((d=s==null?void 0:s.gameplay)==null?void 0:d.tuning)||{},r=(s==null?void 0:s.transform)||{};if(!i){let h=(m=o.animation_duration)!=null?m:1.5,u=n%h/h,y=u<.5?2*u*u:-1+(4-2*u)*u,f=(l=o.x_offset)!=null?l:0,_=(c=o.y_offset)!=null?c:0,x=(p=o.animation_range)!=null?p:40,E=x*.7,S=x,w=t.x+f+E,T=t.y+_+S,W=w+E,v=T+S;e.position.set(w+(W-w)*y,T+(v-T)*y,0);let M=(g=r.scale)!=null?g:.1875,D=(b=o.hand_scale_multiplier)!=null?b:2.5,k=M*D*100;e.scale.set(k,k,1)}}import*as tt from"three";var Ne=new tt.TextureLoader;async function Ge(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await Ne.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let o=s.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new tt.CanvasTexture(s)}}async function
|
|
93
|
+
`,g}function Vn(e,t,n,i,a){var d,m,l,c,p,g,b;let s=a.objects.get("hand_tutorial_1"),o=((d=s==null?void 0:s.gameplay)==null?void 0:d.tuning)||{},r=(s==null?void 0:s.transform)||{};if(!i){let h=(m=o.animation_duration)!=null?m:1.5,u=n%h/h,y=u<.5?2*u*u:-1+(4-2*u)*u,f=(l=o.x_offset)!=null?l:0,_=(c=o.y_offset)!=null?c:0,x=(p=o.animation_range)!=null?p:40,E=x*.7,S=x,w=t.x+f+E,T=t.y+_+S,W=w+E,v=T+S;e.position.set(w+(W-w)*y,T+(v-T)*y,0);let M=(g=r.scale)!=null?g:.1875,D=(b=o.hand_scale_multiplier)!=null?b:2.5,k=M*D*100;e.scale.set(k,k,1)}}import*as tt from"three";var Ne=new tt.TextureLoader;async function Ge(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await Ne.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let o=s.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new tt.CanvasTexture(s)}}async function Zn(e,t,n){var b,h,u,y;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await Ne.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(f){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await Ge(e,t,parseInt(E,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:f})}if(!s)return[];let o=n.gameplay.character_sheet||{},r=(b=o.cols)!=null?b:3,d=(h=o.rows)!=null?h:2,m=((u=s.image)==null?void 0:u.width)||0,l=((y=s.image)==null?void 0:y.height)||0,c=m/r,p=l/d;if(!Number.isFinite(c)||!Number.isFinite(p)||c<=0||p<=0)return[s];let g=[];for(let f=0;f<d;f++)for(let _=0;_<r;_++){let x=document.createElement("canvas");x.width=c,x.height=p;let E=x.getContext("2d");E&&s.image&&E.drawImage(s.image,_*c,f*p,c,p,0,0,c,p),g.push(new tt.CanvasTexture(x))}return g.length>2&&g.push(...g.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:g.length}),g}function Jn(e,t){var c,p,g,b;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(c=n.radius)!=null?c:20,s=(p=n.inner_radius)!=null?p:15,o=(g=n.alpha)!=null?g:.8,r=(b=n.inner_alpha)!=null?b:.3,d=n.inner_color||"#ffffff",m=document.createElement("canvas");m.width=a*2,m.height=a*2;let l=m.getContext("2d");return l&&(l.clearRect(0,0,m.width,m.height),l.beginPath(),l.arc(a,a,a,0,Math.PI*2),l.fillStyle=i,l.globalAlpha=o,l.fill(),l.beginPath(),l.arc(a,a,s,0,Math.PI*2),l.fillStyle=d,l.globalAlpha=r,l.fill()),new tt.CanvasTexture(m)}export{ct as GameObject,Tt as GameObjectManager,lt as Renderer,rt as Transform,Gn as animateHandClick,Wn as animatePanelEntrance,Jn as createBrushTexture,Dn as createEndGamePanel,Xn as createHandTutorial,Fn as createThreeBase,qn as createTutorialLabel,Ln as getRegisteredFontIds,Ge as loadAsset,Zn as loadCharacterFrames,An as registerFont,N as resolveFont,G as resolveFontWeight,Vn as updateHandAnimation};
|
package/package.json
CHANGED