handler-playable-sdk 0.1.11 → 0.1.13
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-3J2MAJRK.mjs → chunk-5QLNISH3.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 +38 -36
- package/dist/three/index.mjs +45 -43
- 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.11",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.13",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.11",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.13",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-5QLNISH3.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.11",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.13",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-3J2MAJRK.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-5QLNISH3.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 ca=Object.create;var Pe=Object.defineProperty;var da=Object.getOwnPropertyDescriptor;var pa=Object.getOwnPropertyNames;var ma=Object.getPrototypeOf,ua=Object.prototype.hasOwnProperty;var ha=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},Pn=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pa(t))!ua.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=da(t,a))||i.enumerable});return e};var xe=(e,t,n)=>(n=e!=null?ca(ma(e)):{},Pn(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),fa=e=>Pn(Pe({},"__esModule",{value:!0}),e);var $a={};ha($a,{AspectClass:()=>dt,GameObject:()=>Re,GameObjectManager:()=>je,Renderer:()=>Ae,ResponsiveUISystem:()=>he,Transform:()=>Ce,animateHandClick:()=>yi,animatePanelEntrance:()=>fi,createBrushTexture:()=>Ei,createEndGamePanel:()=>hi,createHandTutorial:()=>gi,createThreeBase:()=>pi,createTutorialLabel:()=>bi,getAspectClass:()=>Ve,getRegisteredFontIds:()=>ui,loadAsset:()=>pt,loadCharacterFrames:()=>wi,registerFont:()=>mi,resolveFont:()=>N,resolveFontWeight:()=>Y,updateHandAnimation:()=>xi});module.exports=fa($a);var fe=xe(require("three"));var J={};function We(e,t,n=!1){J[e]||(J[e]=[]),J[e].push({fn:t,once:n})}function nt(e,t){if(J[e]){if(!t){delete J[e];return}J[e]=J[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=J[e];if(n)for(let i of[...n])i.fn(...t),i.once&&nt(e,i.fn)}function k(e,t){We(e,t,!0)}var Be={name:"handler-playable-sdk",version:"0.1.11",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,ga=D++,Wn=D++,zn=D++,Bn=D++,On=D++,Nn=D++,Yn=D++,In=D++,Gn=D++,Vn=D++,jn=D++,qn=D++,E=ga;function Xn(){return E===Wn}function Kn(){return E===zn}function Jn(){return E===Bn}function Zn(){return E===On}function re(){return E===Nn}function le(){return E===Yn}function Qn(){return E===In}function Un(){return E===Gn}function ei(){return E===Vn}function it(){return E===jn}function at(){return E===qn}function ti(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),E=Wn;return}catch{}else if(e==="dapi")try{dapi.isReady(),E=zn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(E=Bn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(E=On)}catch{}else if(t==="mintegral")window.gameReady&&(E=Nn);else if(t==="tapjoy")window.TJ_API&&(E=Yn);else if(t==="tiktok")window.openAppStore&&(E=In);else if(t==="smadex")try{window.smxTracking&&(E=Gn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(E=Vn)}catch{}else t==="vungle"?E=jn:(e==="nucleo"||t==="nucleo")&&(E=qn)}var ri={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"},ba=Math.random().toString(36).slice(2),ce=null,we={...ri},li="web_embed",xa={},st=!1,_e=!1,Te=!1,ci=!1,ct=1,rt=0,Ie=!1,q=!1,Ye="",de=Math.floor(window.innerWidth),pe=Math.floor(window.innerHeight),lt=de>pe,X=!1,Ee=!1,ni=!1,ii=!1,ot=!1,Oe=null;function ai(){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 Ne(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function di(e,t){return{event_name:e,ts:Date.now(),session_id:ba,deployment_id:we.deployment_id,variant_id:we.variant_id,export_profile_id:we.profile_id,instance_id:we.instance_id||"default",env:li==="mraid"?"mraid":"web",payload:t}}function _(e,t){let n=Ne(e),i=di(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Oe&&(Oe(de,pe),Oe=null)}function me(e){ct=e,_("volume",e)}function ue(e){e&&(ci=!0),!Te&&(Te=!0,_("pause"),me(0))}function Se(e){!e&&ci||Te&&(Te=!1,_("resume"),me(ct))}function Q(e,t){de=Math.floor(e||window.innerWidth),pe=Math.floor(t||window.innerHeight),lt=de>pe,_("resize",{width:de,height:pe})}function _a(){if(Xn())try{let e=mraid.getMaxSize();Q(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Se():ue()};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();me(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&me(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),Ie=!0,mraid.isViewable()&&mraid.getState()!=="hidden")X=!0,_("boot"),_("view"),_("ready"),q=!0,ve();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,ve()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function wa(){if(Kn())try{let e=dapi.getScreenSize();Q(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Se():ue()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();Q(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(me(t?1:0),dapi.addEventListener("audioVolumeChange",n=>me(n?1:0)),Ie=!0,dapi.isViewable())X=!0,_("boot"),_("view"),_("ready"),q=!0,ve();else{let n=()=>{X=!0,_("boot"),_("view"),_("ready"),q=!0,ve()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function si(){let e=()=>{X||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(X=!0,_("boot"),_("view"),_("ready"),q=!0,ve(),Ee&&(Ee=!1,Z.start()))};window.addEventListener("resize",()=>Q()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Se(),e()):ue()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ie=!0}function Ea(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(ni=!0),!(ni&&t instanceof MouseEvent)&&(rt+=1,_("interaction",rt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Ta(e){var i,a,s,o,p,l,h,c,u,r,m,g;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(le())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(Jn())(p=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||p.call(o);else if(ei())(h=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||h.call(l);else if(Un())try{(u=(c=window.smxTracking)==null?void 0:c.redirect)==null||u.call(c)}catch(b){console.warn("Smadex redirect failed",b)}else if(Zn()){let b=window.ExitApi;b&&typeof b.exit=="function"?b.exit(e||Ye||""):e&&window.open(e)}else re()?(r=window.install)==null||r.call(window):Qn()?(m=window.openAppStore)==null||m.call(window):it()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):e&&window.open(e)}function va(){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;k("view",()=>t(n.mraid_viewable)),k("start",()=>t(n.game_viewable)),k("engagement",()=>t(n.engagement));let i=()=>t(n.complete);k("complete",i),We("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),k("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;k("view",()=>t(n.Ad_Load_Start)),k("start",()=>t(n.Ad_Viewable)),k("engagement",()=>t(n.First_Engagement)),k("complete",()=>t(n.Gameplay_Complete)),k("cta_click",()=>t(n.DSP_Click)),k("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Sa(){if(!le())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{Z.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function oi(){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 Ca(){re()&&(window.mintGameStart=()=>{Se(!0),Q()},window.mintGameClose=()=>{ue(!0)})}function Aa(){if(!at())return;let e=window.NUC;!e||!e.trigger||(Z.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ye)}),Z.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Z={init(e={},t){if(li=e.profile||"web_embed",xa=e.consent||{},we={...ri,...e.ids||{}},ce=e.rootEl||ce,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),_("init"),document.body.oncontextmenu=()=>!1,ai(),Ra(ce),ti(),_a(),wa(),!Ie){if(document.readyState==="complete")si();else if(!ii){ii=!0;let n=()=>{si(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Ea(),va(),Sa(),Ca(),Aa(),console.log(`%c @handler/playable-sdk %c v${Be.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"),Ee&&(Ee=!1,Z.start()),q=!0),q=X},getRoot(){return ai()},get version(){return Be.version||"0.0.0"},get maxWidth(){return de},get maxHeight(){return pe},get isLandscape(){return lt},get isReady(){return q},get isStarted(){return st},get isPaused(){return Te},get isFinished(){return _e},get volume(){return ct},get interactions(){return rt},on(e,t){We(Ne(e),t)},off(e,t){nt(Ne(e),t)},start(){var e,t;if(!st){if(!X){Ee=!0;return}if(st=!0,_("start"),Q(),re())ue(),(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:lt?"landscape":"portrait",buildID:Be.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,_("complete"),re()?(e=window.gameEnd)==null||e.call(window):it()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):le()&&oi())},install(e){if(!_e){_e=!0,le()?(oi(),setTimeout(()=>Z.install(e),300)):(_("complete"),setTimeout(()=>Z.install(e),0));return}ot||(ot=!0,setTimeout(()=>ot=!1,500),_("cta_click"),_("conversion"),Ta(e||Ye))},emit(e,t){let n=Ne(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=di(n,t);ze(n,i)},retry(){var e,t,n;if(re())(e=window.gameRetry)==null||e.call(window);else if(at()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}_("engagement",{action:"retry"})},pause(){ue(!0)},resume(){Se(!0)},resize(e,t){Q(e,t)}},Ge=Z;function Ra(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var ca=Object.create;var Pe=Object.defineProperty;var da=Object.getOwnPropertyDescriptor;var pa=Object.getOwnPropertyNames;var ma=Object.getPrototypeOf,ua=Object.prototype.hasOwnProperty;var ha=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},Pn=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pa(t))!ua.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=da(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ca(ma(e)):{},Pn(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),fa=e=>Pn(Pe({},"__esModule",{value:!0}),e);var $a={};ha($a,{AspectClass:()=>dt,GameObject:()=>Ce,GameObjectManager:()=>je,Renderer:()=>Ae,ResponsiveUISystem:()=>he,Transform:()=>Re,animateHandClick:()=>yi,animatePanelEntrance:()=>fi,createBrushTexture:()=>_i,createEndGamePanel:()=>hi,createHandTutorial:()=>gi,createThreeBase:()=>pi,createTutorialLabel:()=>bi,getAspectClass:()=>Ve,getRegisteredFontIds:()=>ui,loadAsset:()=>pt,loadCharacterFrames:()=>xi,registerFont:()=>mi,resolveFont:()=>Y,resolveFontWeight:()=>I,updateHandAnimation:()=>wi});module.exports=fa($a);var fe=we(require("three"));var J={};function We(e,t,n=!1){J[e]||(J[e]=[]),J[e].push({fn:t,once:n})}function nt(e,t){if(J[e]){if(!t){delete J[e];return}J[e]=J[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=J[e];if(n)for(let i of[...n])i.fn(...t),i.once&&nt(e,i.fn)}function P(e,t){We(e,t,!0)}var Be={name:"handler-playable-sdk",version:"0.1.13",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 W=0,ga=W++,Wn=W++,zn=W++,Bn=W++,On=W++,Nn=W++,Yn=W++,In=W++,Gn=W++,Vn=W++,jn=W++,qn=W++,T=ga;function Xn(){return T===Wn}function Kn(){return T===zn}function Jn(){return T===Bn}function Zn(){return T===On}function re(){return T===Nn}function le(){return T===Yn}function Qn(){return T===In}function Un(){return T===Gn}function ei(){return T===Vn}function it(){return T===jn}function at(){return T===qn}function ti(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),T=Wn;return}catch{}else if(e==="dapi")try{dapi.isReady(),T=zn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=Bn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(T=On)}catch{}else if(t==="mintegral")window.gameReady&&(T=Nn);else if(t==="tapjoy")window.TJ_API&&(T=Yn);else if(t==="tiktok")window.openAppStore&&(T=In);else if(t==="smadex")try{window.smxTracking&&(T=Gn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(T=Vn)}catch{}else t==="vungle"?T=jn:(e==="nucleo"||t==="nucleo")&&(T=qn)}var ri={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"},ba=Math.random().toString(36).slice(2),ce=null,xe={...ri},li="web_embed",wa={},st=!1,Ee=!1,Te=!1,ci=!1,ct=1,rt=0,Ie=!1,X=!1,Ye="",de=Math.floor(window.innerWidth),pe=Math.floor(window.innerHeight),lt=de>pe,K=!1,_e=!1,ni=!1,ii=!1,ot=!1,Oe=null;function ai(){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 Ne(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function di(e,t){return{event_name:e,ts:Date.now(),session_id:ba,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:li==="mraid"?"mraid":"web",payload:t}}function x(e,t){let n=Ne(e),i=di(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Oe&&(Oe(de,pe),Oe=null)}function me(e){ct=e,x("volume",e)}function ue(e){e&&(ci=!0),!Te&&(Te=!0,x("pause"),me(0))}function Se(e){!e&&ci||Te&&(Te=!1,x("resume"),me(ct))}function Q(e,t){de=Math.floor(e||window.innerWidth),pe=Math.floor(t||window.innerHeight),lt=de>pe,x("resize",{width:de,height:pe})}function Ea(){if(Xn())try{let e=mraid.getMaxSize();Q(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Se():ue()};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();me(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&me(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),Ie=!0,mraid.isViewable()&&mraid.getState()!=="hidden")K=!0,x("boot"),x("view"),x("ready"),X=!0,ve();else{let n=()=>{K=!0,x("boot"),x("view"),x("ready"),X=!0,ve()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function xa(){if(Kn())try{let e=dapi.getScreenSize();Q(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Se():ue()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();Q(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(me(t?1:0),dapi.addEventListener("audioVolumeChange",n=>me(n?1:0)),Ie=!0,dapi.isViewable())K=!0,x("boot"),x("view"),x("ready"),X=!0,ve();else{let n=()=>{K=!0,x("boot"),x("view"),x("ready"),X=!0,ve()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function si(){let e=()=>{K||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(K=!0,x("boot"),x("view"),x("ready"),X=!0,ve(),_e&&(_e=!1,Z.start()))};window.addEventListener("resize",()=>Q()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Se(),e()):ue()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ie=!0}function _a(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(ni=!0),!(ni&&t instanceof MouseEvent)&&(rt+=1,x("interaction",rt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Ta(e){var i,a,s,r,p,l,f,c,h,o,u,g;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(le())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(Jn())(p=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||p.call(r);else if(ei())(f=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||f.call(l);else if(Un())try{(h=(c=window.smxTracking)==null?void 0:c.redirect)==null||h.call(c)}catch(b){console.warn("Smadex redirect failed",b)}else if(Zn()){let b=window.ExitApi;b&&typeof b.exit=="function"?b.exit(e||Ye||""):e&&window.open(e)}else re()?(o=window.install)==null||o.call(window):Qn()?(u=window.openAppStore)==null||u.call(window):it()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):e&&window.open(e)}function va(){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;P("view",()=>t(n.mraid_viewable)),P("start",()=>t(n.game_viewable)),P("engagement",()=>t(n.engagement));let i=()=>t(n.complete);P("complete",i),We("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),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(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Sa(){if(!le())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{Z.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function oi(){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 Ra(){re()&&(window.mintGameStart=()=>{Se(!0),Q()},window.mintGameClose=()=>{ue(!0)})}function Aa(){if(!at())return;let e=window.NUC;!e||!e.trigger||(Z.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ye)}),Z.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Z={init(e={},t){if(li=e.profile||"web_embed",wa=e.consent||{},xe={...ri,...e.ids||{}},ce=e.rootEl||ce,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),x("init"),document.body.oncontextmenu=()=>!1,ai(),Ca(ce),ti(),Ea(),xa(),!Ie){if(document.readyState==="complete")si();else if(!ii){ii=!0;let n=()=>{si(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}_a(),va(),Sa(),Ra(),Aa(),console.log(`%c @handler/playable-sdk %c v${Be.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;"),K&&!X&&(x("boot"),x("view"),x("ready"),_e&&(_e=!1,Z.start()),X=!0),X=K},getRoot(){return ai()},get version(){return Be.version||"0.0.0"},get maxWidth(){return de},get maxHeight(){return pe},get isLandscape(){return lt},get isReady(){return X},get isStarted(){return st},get isPaused(){return Te},get isFinished(){return Ee},get volume(){return ct},get interactions(){return rt},on(e,t){We(Ne(e),t)},off(e,t){nt(Ne(e),t)},start(){var e,t;if(!st){if(!K){_e=!0;return}if(st=!0,x("start"),Q(),re())ue(),(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:lt?"landscape":"portrait",buildID:Be.version||"dev"})}}},finish(){var e,t;Ee||(Ee=!0,x("complete"),re()?(e=window.gameEnd)==null||e.call(window):it()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):le()&&oi())},install(e){if(!Ee){Ee=!0,le()?(oi(),setTimeout(()=>Z.install(e),300)):(x("complete"),setTimeout(()=>Z.install(e),0));return}ot||(ot=!0,setTimeout(()=>ot=!1,500),x("cta_click"),x("conversion"),Ta(e||Ye))},emit(e,t){let n=Ne(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=di(n,t);ze(n,i)},retry(){var e,t,n;if(re())(e=window.gameRetry)==null||e.call(window);else if(at()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}x("engagement",{action:"retry"})},pause(){ue(!0)},resume(){Se(!0)},resize(e,t){Q(e,t)}},Ge=Z;function Ca(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)}var dt=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(dt||{});function Ve(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var he=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=Ve(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return Ve(t.width,t.height)}};async function pi(e,t={}){let n=()=>{let d=e.getBoundingClientRect(),
|
|
17
|
+
`,e.appendChild(t)}var dt=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(dt||{});function Ve(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var he=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=Ve(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return Ve(t.width,t.height)}};async function pi(e,t={}){let n=()=>{let d=e.getBoundingClientRect(),m=Math.floor(d.width),y=Math.floor(d.height);return(m<=0||!isFinite(m)||m!==m)&&(m=e.clientWidth||window.innerWidth||320),(y<=0||!isFinite(y)||y!==y)&&(y=e.clientHeight||window.innerHeight||480),(m<=0||!isFinite(m)||m!==m)&&(m=320),(y<=0||!isFinite(y)||y!==y)&&(y=480),console.log("[THREE-BASE] getSize result:",{width:m,height:y,boundingRect:{width:d.width,height:d.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleWidth:e.style.width,styleHeight:e.style.height,note:"Using boundingRect as primary source (actual rendered size)"}),{width:m,height:y}},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.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let s=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",s,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let r=document.createElement("div");r.style.cssText=`
|
|
18
18
|
position: absolute !important;
|
|
19
19
|
inset: 0 !important;
|
|
20
20
|
width: 100% !important;
|
|
@@ -35,15 +35,17 @@
|
|
|
35
35
|
padding: 0 !important;
|
|
36
36
|
border: none !important;
|
|
37
37
|
overflow: hidden !important;
|
|
38
|
-
`,e.appendChild(
|
|
38
|
+
`,e.appendChild(r);let p=document.createElement("div");p.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),r.appendChild(p);let l=new fe.Scene,{width:f,height:c}=n(),h=new fe.PerspectiveCamera(55,f/c,.1,100);h.position.set(0,0,3.2),h.lookAt(0,0,0),h.updateMatrixWorld();let o=new fe.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(f,c),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",p.appendChild(o.domElement);let u=d=>{var C;let m=e.getBoundingClientRect(),y=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:m.width,height:m.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:y.width,height:y.height,transform:y.transform,scale:y.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(C=new Error().stack)==null?void 0:C.split(`
|
|
39
|
+
`).slice(1,4).join(`
|
|
40
|
+
`)});let E=m.width,w=m.height;if((E<=0||!isFinite(E))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:m.width,clientWidth:e.clientWidth}),E=e.clientWidth||window.innerWidth||320),(w<=0||!isFinite(w))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:m.height,clientHeight:e.clientHeight}),w=e.clientHeight||window.innerHeight||480),typeof(d==null?void 0:d.width)=="number"&&d.width>0){let H=Math.abs(d.width-m.width);H>1&&console.warn("[THREE-BASE] Provided width differs from container:",{provided:d.width,container:m.width,difference:H,willUse:"provided (override)"}),E=d.width}if(typeof(d==null?void 0:d.height)=="number"&&d.height>0){let H=Math.abs(d.height-m.height);H>1&&console.warn("[THREE-BASE] Provided height differs from container:",{provided:d.height,container:m.height,difference:H,willUse:"provided (override)"}),w=d.height}(E<=0||w<=0||!isFinite(E)||!isFinite(w))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:E,newHeight:w,size:d,rootRect:m}),E=m.width||e.clientWidth||320,w=m.height||e.clientHeight||480);let _=Math.floor(E),v=Math.floor(w);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:_,finalHeight:v,aspectRatio:_/v,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(_,v),o.setPixelRatio(window.devicePixelRatio||1),h.aspect=_/v,h.updateProjectionMatrix();let S=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:o.domElement.width,height:o.domElement.height},rendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height},containerRect:{width:S.width,height:S.height},cameraAspect:h.aspect,matches:{width:Math.abs(o.domElement.width-S.width)<1,height:Math.abs(o.domElement.height-S.height)<1},sizeDifference:{width:o.domElement.width-S.width,height:o.domElement.height-S.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{u()})});let g=!1;Ge.on("pause",()=>{g=!0,document.querySelectorAll("audio").forEach(m=>m.pause())}),Ge.on("resume",()=>{g=!1,document.querySelectorAll("audio").forEach(m=>{m.currentTime>0&&!m.ended&&m.play().catch(()=>{})})});let b=new he(e,r);return Ge.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),u({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),b.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),u(),b.updateLayout()}),{scene:l,camera:h,renderer:o,uiSystem:b,applySize:u}}var A=we(require("three")),Re=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||!isFinite(n)?.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}},Ae=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 A.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof A.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof A.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof A.Mesh&&t.material){let n=typeof this.tint=="string"?new A.Color(this.tint):new A.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof A.MeshBasicMaterial||i instanceof A.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof A.MeshBasicMaterial||t.material instanceof A.MeshStandardMaterial)&&t.material.color.copy(n)}}},Ce=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new Re(a.transform),this.renderer=new Ae(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)}},je=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 Ce(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 qe={"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 Y(e){let t=qe[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function I(e){var n;let t=qe[e];return t&&(n=t.weight)!=null?n:"400"}function mi(e,t){qe[e]=t}function ui(){return Object.keys(qe)}var ye=we(require("three"));function ae(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 hi(e,t,n,i){var At,Ct,Ht,Mt,Lt,kt,Ft,Dt,$t,Pt,Wt,zt,Bt,Ot,Nt,Yt,It,Gt,Vt,jt,qt,Xt,Kt,Jt,Zt,Qt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,pn,mn,un,hn,fn,yn,gn,bn,wn,En,xn,_n,Tn,vn,Sn,Rn,An,Cn,Hn,Mn,Ln,kn,Fn,Dn,$n;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),r=e.objects.get("ui_endgame_title_1"),p=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),f=e.objects.get("ui_endgame_cta_1"),c=e.objects.get("ui_endgame_cta_hint_1"),h=e.objects.get("ui_endgame_hand_1"),o=e.engine.runtime||{},u=((At=a==null?void 0:a.gameplay)==null?void 0:At.tuning)||{},g=(a==null?void 0:a.render)||{},b=i.getBoundingClientRect(),d=b.width>0?b.width*.9:320,m=b.height>0?b.height*.85:400,y=Math.min((Ct=u.panel_width)!=null?Ct:320,d),E=Math.min((Ht=u.panel_height)!=null?Ht:400,m),w=(Mt=u.panel_padding)!=null?Mt:32,_=(Lt=u.panel_radius)!=null?Lt:24,v=g.background_color||u.panel_bg_color||"#1a0a0a",S=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(kt=u.panel_bg_alpha)!=null?kt:.98,C=g.border_color||u.panel_border_color||"#ffffff",H=(Ft=u.panel_border_width)!=null?Ft:2,L=(Dt=u.panel_border_alpha)!=null?Dt:.3,R=document.createElement("div");R.style.cssText=`
|
|
39
41
|
position: absolute;
|
|
40
42
|
width: ${y}px;
|
|
41
|
-
height: ${
|
|
42
|
-
background: ${
|
|
43
|
-
opacity: ${
|
|
44
|
-
border: ${
|
|
45
|
-
border-opacity: ${
|
|
46
|
-
border-radius: ${
|
|
43
|
+
height: ${E}px;
|
|
44
|
+
background: ${v};
|
|
45
|
+
opacity: ${S};
|
|
46
|
+
border: ${H}px solid ${C};
|
|
47
|
+
border-opacity: ${L};
|
|
48
|
+
border-radius: ${_}px;
|
|
47
49
|
display: block;
|
|
48
50
|
transform: translate(-50%, -50%);
|
|
49
51
|
opacity: 0;
|
|
@@ -54,35 +56,35 @@
|
|
|
54
56
|
z-index: 1000;
|
|
55
57
|
box-sizing: border-box;
|
|
56
58
|
padding: ${w}px;
|
|
57
|
-
`,i.appendChild(
|
|
58
|
-
font-family: ${
|
|
59
|
+
`,i.appendChild(R);let G=ae(R);G.element=R;let B=(($t=s==null?void 0:s.gameplay)==null?void 0:$t.tuning)||{},U=(s==null?void 0:s.transform)||{},z=(Pt=B.logo_size)!=null?Pt:56,O=(Wt=U.scale)!=null?Wt:1,se=(Bt=(zt=U.offset)==null?void 0:zt.y)!=null?Bt:-130,He=(Ot=B.logo_alpha)!=null?Ot:1,Ti=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),N=new ye.Sprite(Ti);N.position.set(0,se,0),N.material.opacity=0;let Me=0,Le=0;if(n&&(Me=((Nt=n.image)==null?void 0:Nt.width)||100,Le=((Yt=n.image)==null?void 0:Yt.height)||100),Me>0&&Le>0){let oe=Me/Le,et,tt;oe>1?(et=z,tt=z/oe):(tt=z,et=z*oe);let ra=et/Me*O,la=tt/Le*O;N.scale.set(ra,la,1)}else{let oe=z/100*O;N.scale.set(oe,oe,1)}N.targetAlpha=He,N.baseScaleX=N.scale.x,N.baseScaleY=N.scale.y;let k=r==null?void 0:r.ui,V=((It=r==null?void 0:r.gameplay)==null?void 0:It.tuning)||{},vi=(k==null?void 0:k.text)||"MISSION ACCOMPLISHED",mt=(k==null?void 0:k.font)||"brand.heading",ut=(k==null?void 0:k.fontSize)||24,Si=(Gt=k==null?void 0:k.letterSpacing)!=null?Gt:1,ke=(Vt=r==null?void 0:r.render)==null?void 0:Vt.tint,Ri=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#00FF88",Ai=y-w*2-30,Ci=V.font_weight_override?V.font_weight_override:I(mt),ee=document.createElement("div");ee.textContent=vi,ee.style.cssText=`
|
|
60
|
+
font-family: ${Y(mt)};
|
|
59
61
|
font-size: ${ut}px;
|
|
60
|
-
font-weight: ${
|
|
61
|
-
color: ${
|
|
62
|
+
font-weight: ${Ci};
|
|
63
|
+
color: ${Ri};
|
|
62
64
|
text-align: center;
|
|
63
65
|
letter-spacing: ${Si}px;
|
|
64
|
-
-webkit-text-stroke: ${(jt=
|
|
65
|
-
text-shadow: ${(qt=
|
|
66
|
+
-webkit-text-stroke: ${(jt=V.stroke_width)!=null?jt:2}px ${V.stroke_color||"#000000"};
|
|
67
|
+
text-shadow: ${(qt=V.shadow_distance)!=null?qt:4}px ${(Xt=V.shadow_distance)!=null?Xt:4}px ${(Kt=V.shadow_blur)!=null?Kt:8}px rgba(0,0,0,${(Jt=V.shadow_alpha)!=null?Jt:.9});
|
|
66
68
|
opacity: 0;
|
|
67
69
|
position: absolute;
|
|
68
70
|
transform: translate(-50%, -50%);
|
|
69
71
|
white-space: nowrap;
|
|
70
72
|
max-width: ${Ai}px;
|
|
71
|
-
`;let ht=(Zt=
|
|
72
|
-
font-family: ${
|
|
73
|
+
`;let ht=(Zt=u.title_offset_y)!=null?Zt:E*.25,Hi=ht+((Qt=V.animation_start_y_offset)!=null?Qt:-20);ee.style.top=`${Hi}px`,ee.style.left="50%";let ft=ae(ee);ft.element=ee,R.appendChild(ee);let F=p==null?void 0:p.ui,yt=((Ut=p==null?void 0:p.gameplay)==null?void 0:Ut.tuning)||{},Mi=(F==null?void 0:F.text)||"RESCUE COMPLETE",gt=(F==null?void 0:F.font)||"brand.body",Li=(F==null?void 0:F.fontSize)||11,ki=(en=F==null?void 0:F.letterSpacing)!=null?en:.5,Fe=(tn=p==null?void 0:p.render)==null?void 0:tn.tint,Fi=typeof Fe=="string"?Fe:Fe?`#${Fe.toString(16).padStart(6,"0")}`:"#B0B0B0",te=document.createElement("div");te.textContent=Mi,te.style.cssText=`
|
|
74
|
+
font-family: ${Y(gt)};
|
|
73
75
|
font-size: ${Li}px;
|
|
74
|
-
font-weight: ${
|
|
75
|
-
color: ${
|
|
76
|
+
font-weight: ${I(gt)};
|
|
77
|
+
color: ${Fi};
|
|
76
78
|
text-align: center;
|
|
77
|
-
letter-spacing: ${
|
|
79
|
+
letter-spacing: ${ki}px;
|
|
78
80
|
opacity: 0;
|
|
79
81
|
position: absolute;
|
|
80
82
|
transform: translate(-50%, -50%);
|
|
81
83
|
white-space: nowrap;
|
|
82
|
-
`;let Di=ht+ut*2.5+((nn=yt.animation_start_y_offset)!=null?nn:-10);te.style.top=`${Di}px`,te.style.left="50%";let Ke=ae(te);Ke.element=te,Ke.animationStartYOffset=(an=yt.animation_start_y_offset)!=null?an:-10,
|
|
83
|
-
font-family: ${
|
|
84
|
+
`;let Di=ht+ut*2.5+((nn=yt.animation_start_y_offset)!=null?nn:-10);te.style.top=`${Di}px`,te.style.left="50%";let Ke=ae(te);Ke.element=te,Ke.animationStartYOffset=(an=yt.animation_start_y_offset)!=null?an:-10,R.appendChild(te);let j=l==null?void 0:l.ui,bt=((sn=l==null?void 0:l.gameplay)==null?void 0:sn.tuning)||{},$i=(j==null?void 0:j.text)||((on=o.ui)==null?void 0:on.cta_hint)||"Continue the adventure!",wt=(j==null?void 0:j.font)||"brand.body",Pi=(j==null?void 0:j.fontSize)||16,De=(rn=l==null?void 0:l.render)==null?void 0:rn.tint,Wi=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",zi=(ln=bt.max_width)!=null?ln:y-w*2,Bi=(cn=bt.line_height)!=null?cn:1.4,ne=document.createElement("div");ne.textContent=$i,ne.style.cssText=`
|
|
85
|
+
font-family: ${Y(wt)};
|
|
84
86
|
font-size: ${Pi}px;
|
|
85
|
-
font-weight: ${
|
|
87
|
+
font-weight: ${I(wt)};
|
|
86
88
|
color: ${Wi};
|
|
87
89
|
text-align: center;
|
|
88
90
|
opacity: 0;
|
|
@@ -91,9 +93,9 @@
|
|
|
91
93
|
max-width: ${zi}px;
|
|
92
94
|
line-height: ${Bi};
|
|
93
95
|
word-wrap: break-word;
|
|
94
|
-
`;let Oi=(dn=
|
|
96
|
+
`;let Oi=(dn=u.footer_offset_y)!=null?dn:E*.5;ne.style.top=`${Oi}px`,ne.style.left="50%";let Je=ae(ne);Je.element=ne;let Ni=((pn=l==null?void 0:l.render)==null?void 0:pn.alpha)!==void 0&&((mn=l==null?void 0:l.render)==null?void 0:mn.alpha)!==null?l.render.alpha:1;Je.targetAlpha=Ni,R.appendChild(ne);let q=((un=f==null?void 0:f.gameplay)==null?void 0:un.tuning)||{},D=f==null?void 0:f.ui,Yi=(hn=q.button_width)!=null?hn:260,Et=(fn=q.button_height)!=null?fn:56,Ii=(yn=q.button_radius)!=null?yn:16,Gi=q.button_bg_color||((gn=o.theme)==null?void 0:gn.cta_background)||"#ffb43b",Vi=(bn=q.button_bg_alpha)!=null?bn:1,ji=q.button_border_color||"#ffffff",qi=(wn=q.button_border_width)!=null?wn:2,Wa=(En=q.button_border_alpha)!=null?En:.2,Ze=(xn=u.cta_offset_y)!=null?xn:E*.75,M=document.createElement("button");M.style.cssText=`
|
|
95
97
|
width: ${Yi}px;
|
|
96
|
-
height: ${
|
|
98
|
+
height: ${Et}px;
|
|
97
99
|
background: ${Gi};
|
|
98
100
|
opacity: ${Vi};
|
|
99
101
|
border: ${qi}px solid ${ji};
|
|
@@ -103,10 +105,10 @@
|
|
|
103
105
|
position: absolute;
|
|
104
106
|
transform: translate(-50%, -50%);
|
|
105
107
|
box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
|
|
106
|
-
`,
|
|
107
|
-
font-family: ${
|
|
108
|
+
`,M.style.top=`${Ze}px`,M.style.left="50%";let xt=ae(M);xt.element=M,R.appendChild(M);let Xi=(D==null?void 0:D.text)||((_n=o.ui)==null?void 0:_n.cta_label_end)||"DOWNLOAD",_t=(D==null?void 0:D.font)||"brand.heading",Ki=(D==null?void 0:D.fontSize)||20,Ji=q.button_text_color||((Tn=o.theme)==null?void 0:Tn.cta_text)||"#1a0a0a";M.textContent=Xi,M.style.fontFamily=Y(_t),M.style.fontSize=`${Ki}px`,M.style.fontWeight=String(I(_t)),M.style.color=Ji,M.style.letterSpacing=`${(vn=D==null?void 0:D.letterSpacing)!=null?vn:1}px`;let Tt=ae(M);Tt.element=M;let $=c==null?void 0:c.ui,vt=((Sn=c==null?void 0:c.gameplay)==null?void 0:Sn.tuning)||{},Zi=($==null?void 0:$.text)||"Play the full game",St=($==null?void 0:$.font)||"brand.body",Qi=($==null?void 0:$.fontSize)||11,Ui=(Rn=$==null?void 0:$.letterSpacing)!=null?Rn:0,$e=(An=c==null?void 0:c.render)==null?void 0:An.tint,ea=typeof $e=="string"?$e:$e?`#${$e.toString(16).padStart(6,"0")}`:"#CCCCCC",ie=document.createElement("div");ie.textContent=Zi,ie.style.cssText=`
|
|
109
|
+
font-family: ${Y(St)};
|
|
108
110
|
font-size: ${Qi}px;
|
|
109
|
-
font-weight: ${
|
|
111
|
+
font-weight: ${I(St)};
|
|
110
112
|
color: ${ea};
|
|
111
113
|
text-align: center;
|
|
112
114
|
letter-spacing: ${Ui}px;
|
|
@@ -114,19 +116,19 @@
|
|
|
114
116
|
position: absolute;
|
|
115
117
|
transform: translate(-50%, -50%);
|
|
116
118
|
white-space: nowrap;
|
|
117
|
-
`;let ta=Ze+
|
|
118
|
-
font-family: ${
|
|
119
|
+
`;let ta=Ze+Et/2+15+((Cn=vt.animation_start_y_offset)!=null?Cn:5);ie.style.top=`${ta}px`,ie.style.left="50%";let Qe=ae(ie);Qe.element=ie,Qe.animationStartYOffset=(Hn=vt.animation_start_y_offset)!=null?Hn:5,R.appendChild(ie);let Ue=((Mn=h==null?void 0:h.gameplay)==null?void 0:Mn.tuning)||{},na=(Ln=Ue.hand_offset_x)!=null?Ln:50,ia=(kn=Ue.hand_offset_y)!=null?kn:50,aa=(Dn=(Fn=h==null?void 0:h.transform)==null?void 0:Fn.scale)!=null?Dn:.1875,sa=($n=Ue.hand_scale_multiplier)!=null?$n:2.5,oa=new ye.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),be=new ye.Sprite(oa),Rt=aa*sa*100;return be.scale.set(Rt,Rt,1),be.position.set(na,Ze+ia,0),be.material.opacity=0,be.visible=!1,{panel:G,logo:N,title:ft,subtitle:Ke,footer:Je,ctaButton:xt,ctaText:Tt,ctaHint:Qe,hand:be}}function fi(e,t,n){var v,S,C,H,L,R,G,B;let i=t.objects.get("ui_endgame_1"),a=((v=i==null?void 0:i.gameplay)==null?void 0:v.tuning)||{},s=(S=a.animation_duration_ms)!=null?S:800,r=(C=a.fade_in_duration_ms)!=null?C:600,p=(H=a.scale_animation_intensity)!=null?H:.1,l=(L=a.logo_animation_delay_ms)!=null?L:100,f=(R=a.title_animation_delay_ms)!=null?R:200,c=(G=a.footer_animation_delay_ms)!=null?G:300,h=(B=a.cta_animation_delay_ms)!=null?B:400,{panel:o,logo:u,title:g,subtitle:b,footer:d,ctaButton:m,ctaText:y,ctaHint:E}=e;o.visible=!0,o.element.style.visibility="visible";let w=Date.now(),_=()=>{let U=Date.now()-w,z=Math.min(U/r,1),O=1-Math.pow(1-z,3);o.alpha=O,o.element.style.opacity=O.toString();let se=1+p*(1-O);o.element.style.transform=`translate(-50%, -50%) scale(${se})`,z<1?requestAnimationFrame(_):(setTimeout(()=>Ha(u,s,t),l),setTimeout(()=>{Ma(g,s),setTimeout(()=>La(b,s),50)},f),setTimeout(()=>ka(d,s),c),setTimeout(()=>{Fa(m,y,s),setTimeout(()=>Da(E,s),50),n&&n()},h))};_()}function Ha(e,t,n){var o,u,g,b,d;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(u=(((o=i==null?void 0:i.gameplay)==null?void 0:o.tuning)||{}).animation_start_scale)!=null?u:1.2,r=Date.now(),p=e.material.opacity,l=(g=e.targetAlpha)!=null?g:1,f=(b=e.baseScaleX)!=null?b:e.scale.x,c=(d=e.baseScaleY)!=null?d:e.scale.y,h=()=>{let m=Date.now()-r,y=Math.min(m/t,1),E=1-Math.pow(1-y,2);e.material.opacity=p+(l-p)*E;let w=s+(1-s)*E;e.scale.set(f*w,c*w,1),y<1&&requestAnimationFrame(h)};h()}function Ma(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let r=Date.now()-n,p=Math.min(r/t,1),l=1-Math.pow(1-p,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a-20*(1-l)}px`,p<1&&requestAnimationFrame(s)};s()}function La(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((p=e.animationStartYOffset)!=null?p:-10),r=()=>{let l=Date.now()-n,f=Math.min(l/t,1),c=1-Math.pow(1-f,2);e.element.style.opacity=(i+(1-i)*c).toString(),e.element.style.top=`${a+(s-a)*c}px`,f<1&&requestAnimationFrame(r)};r()}function ka(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(r=e.targetAlpha)!=null?r:1,s=()=>{let p=Date.now()-n,l=Math.min(p/t,1),f=1-Math.pow(1-l,2);e.element.style.opacity=(i+(a-i)*f).toString(),l<1&&requestAnimationFrame(s)};s()}function Fa(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let r=Date.now()-i,p=Math.min(r/n,1),l=1-Math.pow(1-p,2);e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,p<1&&requestAnimationFrame(s)};s()}function Da(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((p=e.animationStartYOffset)!=null?p:5),r=()=>{let l=Date.now()-n,f=Math.min(l/t,1),c=1-Math.pow(1-f,2);e.element.style.opacity=(i+(1-i)*c).toString(),e.element.style.top=`${a+(s-a)*c}px`,f<1&&requestAnimationFrame(r)};r()}function yi(e,t,n,i){var c,h,o,u;let a=n.objects.get("ui_endgame_hand_1"),s=((c=a==null?void 0:a.gameplay)==null?void 0:c.tuning)||{},r=(h=s.click_animation_duration_ms)!=null?h:600,p=(o=s.click_delay_ms)!=null?o:2e3,l=(u=s.click_repeat_delay_ms)!=null?u:3e3,f=()=>{var S,C;e.visible=!0,e.material.opacity=1;let g=e.position.x,b=e.position.y,d=(S=s.hand_offset_x)!=null?S:50,m=(C=s.hand_offset_y)!=null?C:50,y=t.element.getBoundingClientRect(),E=d,w=m,_=Date.now(),v=()=>{var O,se,He;let H=Date.now()-_,L=Math.min(H/r,1),R=L<.5?2*L*L:1-Math.pow(-2*L+2,2)/2;e.position.set(g+(E-g)*R,b+(w-b)*R,0);let G=(se=(O=a==null?void 0:a.transform)==null?void 0:O.scale)!=null?se:.1875,B=(He=s.hand_scale_multiplier)!=null?He:2.5,U=G*B*100,z=U+U*.2*Math.sin(L*Math.PI);e.scale.set(z,z,1),L<1?requestAnimationFrame(v):(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(g,b,0),f()},l)},500))};v()};setTimeout(f,p)}var Xe=we(require("three"));function gi(e,t,n){var h,o,u,g;let i=t.objects.get("hand_tutorial_1"),a=((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{},s=(i==null?void 0:i.render)||{},r=(i==null?void 0:i.transform)||{},p=new Xe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),l=new Xe.Sprite(p);l.position.set(n.x,n.y,0),l.material.opacity=0;let f=(o=a.hand_scale_multiplier)!=null?o:2.5,c=(u=r.scale)!=null?u:.1875;return l.scale.set(c*f*100,c*f*100,1),l.renderOrder=(g=s.z_index)!=null?g:99999,l}function bi(e){var g,b,d,m,y,E,w,_,v;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((g=e.engine.runtime)==null?void 0:g.ui_styles)||{},s=((b=e.engine.runtime)==null?void 0:b.ui)||{},r=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",p=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,f=(m=n==null?void 0:n.letterSpacing)!=null?m:(d=a.label_letter_spacing)!=null?d:-1,c=(n==null?void 0:n.align)||"center",h=i.tint,o=typeof h=="string"?h:h?`#${h.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=r,u.style.cssText=`
|
|
120
|
+
font-family: ${Y(p)};
|
|
119
121
|
font-size: ${l}px;
|
|
120
|
-
font-weight: ${
|
|
121
|
-
color: ${
|
|
122
|
+
font-weight: ${I(p)};
|
|
123
|
+
color: ${o};
|
|
122
124
|
text-align: ${c};
|
|
123
|
-
letter-spacing: ${
|
|
124
|
-
text-shadow: ${(y=a.label_shadow_distance)!=null?y:2}px ${(
|
|
125
|
+
letter-spacing: ${f}px;
|
|
126
|
+
text-shadow: ${(y=a.label_shadow_distance)!=null?y:2}px ${(E=a.label_shadow_distance)!=null?E:2}px ${(w=a.label_shadow_blur)!=null?w:4}px rgba(0,0,0,${(_=a.label_shadow_alpha)!=null?_:.8});
|
|
125
127
|
-webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
|
|
126
|
-
opacity: ${(
|
|
128
|
+
opacity: ${(v=i.alpha)!=null?v:0};
|
|
127
129
|
visibility: ${i.visible!==!1?"visible":"hidden"};
|
|
128
130
|
pointer-events: none;
|
|
129
131
|
position: absolute;
|
|
130
132
|
transform: translate(-50%, -50%);
|
|
131
133
|
white-space: nowrap;
|
|
132
|
-
`,
|
|
134
|
+
`,u}function wi(e,t,n,i,a){var l,f,c,h,o,u,g;let s=a.objects.get("hand_tutorial_1"),r=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},p=(s==null?void 0:s.transform)||{};if(!i){let b=(f=r.animation_duration)!=null?f:1.5,d=n%b/b,m=d<.5?2*d*d:-1+(4-2*d)*d,y=(c=r.x_offset)!=null?c:0,E=(h=r.y_offset)!=null?h:0,w=(o=r.animation_range)!=null?o:40,_=w*.7,v=w,S=t.x+y+_,C=t.y+E+v,H=S+_,L=C+v;e.position.set(S+(H-S)*m,C+(L-C)*m,0);let R=(u=p.scale)!=null?u:.1875,G=(g=r.hand_scale_multiplier)!=null?g:2.5,B=R*G*100;e.scale.set(B,B,1)}}var ge=we(require("three")),Ei=new ge.TextureLoader;async function pt(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await Ei.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let r=s.getContext("2d");return r&&(r.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?r.fillRect(0,0,30,60):(r.beginPath(),r.arc(32,32,30,0,Math.PI*2),r.fill(),r.fillRect(27,32,10,40))),new ge.CanvasTexture(s)}}async function xi(e,t,n){var g,b,d,m;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await Ei.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(y){let _=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await pt(e,t,parseInt(_,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:y})}if(!s)return[];let r=n.gameplay.character_sheet||{},p=(g=r.cols)!=null?g:3,l=(b=r.rows)!=null?b:2,f=((d=s.image)==null?void 0:d.width)||0,c=((m=s.image)==null?void 0:m.height)||0,h=f/p,o=c/l;if(!Number.isFinite(h)||!Number.isFinite(o)||h<=0||o<=0)return[s];let u=[];for(let y=0;y<l;y++)for(let E=0;E<p;E++){let w=document.createElement("canvas");w.width=h,w.height=o;let _=w.getContext("2d");_&&s.image&&_.drawImage(s.image,E*h,y*o,h,o,0,0,h,o),u.push(new ge.CanvasTexture(w))}return u.length>2&&u.push(...u.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:u.length}),u}function _i(e,t){var h,o,u,g;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(h=n.radius)!=null?h:20,s=(o=n.inner_radius)!=null?o:15,r=(u=n.alpha)!=null?u:.8,p=(g=n.inner_alpha)!=null?g:.3,l=n.inner_color||"#ffffff",f=document.createElement("canvas");f.width=a*2,f.height=a*2;let c=f.getContext("2d");return c&&(c.clearRect(0,0,f.width,f.height),c.beginPath(),c.arc(a,a,a,0,Math.PI*2),c.fillStyle=i,c.globalAlpha=r,c.fill(),c.beginPath(),c.arc(a,a,s,0,Math.PI*2),c.fillStyle=l,c.globalAlpha=p,c.fill()),new ge.CanvasTexture(f)}0&&(module.exports={AspectClass,GameObject,GameObjectManager,Renderer,ResponsiveUISystem,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createThreeBase,createTutorialLabel,getAspectClass,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
|
package/dist/three/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as dt}from"../chunk-5QLNISH3.mjs";import*as O from"three";var Ke=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(Ke||{});function _t(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var nt=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=_t(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return _t(t.width,t.height)}};async function Dn(e,t={}){let n=()=>{let c=e.getBoundingClientRect(),d=Math.floor(c.width),g=Math.floor(c.height);return(d<=0||!isFinite(d)||d!==d)&&(d=e.clientWidth||window.innerWidth||320),(g<=0||!isFinite(g)||g!==g)&&(g=e.clientHeight||window.innerHeight||480),(d<=0||!isFinite(d)||d!==d)&&(d=320),(g<=0||!isFinite(g)||g!==g)&&(g=480),console.log("[THREE-BASE] getSize result:",{width:d,height:g,boundingRect:{width:c.width,height:c.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleWidth:e.style.width,styleHeight:e.style.height,note:"Using boundingRect as primary source (actual rendered size)"}),{width:d,height:g}},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.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let o=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",o,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let r=document.createElement("div");r.style.cssText=`
|
|
2
2
|
position: absolute !important;
|
|
3
3
|
inset: 0 !important;
|
|
4
4
|
width: 100% !important;
|
|
@@ -8,7 +8,7 @@ import{b as pt}from"../chunk-3J2MAJRK.mjs";import*as I from"three";var Ke=(s=>(s
|
|
|
8
8
|
max-width: 100% !important;
|
|
9
9
|
max-height: 100% !important;
|
|
10
10
|
display: block !important;
|
|
11
|
-
background: ${
|
|
11
|
+
background: ${o} !important;
|
|
12
12
|
background-size: cover !important;
|
|
13
13
|
background-position: center !important;
|
|
14
14
|
background-repeat: no-repeat !important;
|
|
@@ -19,15 +19,17 @@ import{b as pt}from"../chunk-3J2MAJRK.mjs";import*as I from"three";var Ke=(s=>(s
|
|
|
19
19
|
padding: 0 !important;
|
|
20
20
|
border: none !important;
|
|
21
21
|
overflow: hidden !important;
|
|
22
|
-
`,e.appendChild(r);let
|
|
22
|
+
`,e.appendChild(r);let p=document.createElement("div");p.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),r.appendChild(p);let l=new O.Scene,{width:y,height:h}=n(),u=new O.PerspectiveCamera(55,y/h,.1,100);u.position.set(0,0,3.2),u.lookAt(0,0,0),u.updateMatrixWorld();let s=new O.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});s.setPixelRatio(window.devicePixelRatio||1),s.setSize(y,h),s.setClearColor(0,0),s.domElement.style.position="absolute",s.domElement.style.top="0",s.domElement.style.left="0",s.domElement.style.right="0",s.domElement.style.bottom="0",s.domElement.style.width="100%",s.domElement.style.height="100%",s.domElement.style.minWidth="100%",s.domElement.style.minHeight="100%",s.domElement.style.maxWidth="100%",s.domElement.style.maxHeight="100%",s.domElement.style.display="block",s.domElement.style.pointerEvents="auto",s.domElement.style.margin="0",s.domElement.style.padding="0",s.domElement.style.boxSizing="border-box",p.appendChild(s.domElement);let m=c=>{var R;let d=e.getBoundingClientRect(),g=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:c,rootRect:{width:d.width,height:d.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:g.width,height:g.height,transform:g.transform,scale:g.scale},rendererCurrentSize:{width:s.domElement.width,height:s.domElement.height},rendererStyleSize:{width:s.domElement.style.width,height:s.domElement.style.height},stackTrace:(R=new Error().stack)==null?void 0:R.split(`
|
|
23
|
+
`).slice(1,4).join(`
|
|
24
|
+
`)});let b=d.width,E=d.height;if((b<=0||!isFinite(b))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:d.width,clientWidth:e.clientWidth}),b=e.clientWidth||window.innerWidth||320),(E<=0||!isFinite(E))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:d.height,clientHeight:e.clientHeight}),E=e.clientHeight||window.innerHeight||480),typeof(c==null?void 0:c.width)=="number"&&c.width>0){let v=Math.abs(c.width-d.width);v>1&&console.warn("[THREE-BASE] Provided width differs from container:",{provided:c.width,container:d.width,difference:v,willUse:"provided (override)"}),b=c.width}if(typeof(c==null?void 0:c.height)=="number"&&c.height>0){let v=Math.abs(c.height-d.height);v>1&&console.warn("[THREE-BASE] Provided height differs from container:",{provided:c.height,container:d.height,difference:v,willUse:"provided (override)"}),E=c.height}(b<=0||E<=0||!isFinite(b)||!isFinite(E))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:b,newHeight:E,size:c,rootRect:d}),b=d.width||e.clientWidth||320,E=d.height||e.clientHeight||480);let x=Math.floor(b),w=Math.floor(E);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:x,finalHeight:w,aspectRatio:x/w,beforeRendererSize:{width:s.domElement.width,height:s.domElement.height},beforeRendererStyle:{width:s.domElement.style.width,height:s.domElement.style.height}}),s.setSize(x,w),s.setPixelRatio(window.devicePixelRatio||1),u.aspect=x/w,u.updateProjectionMatrix();let _=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:s.domElement.width,height:s.domElement.height},rendererStyle:{width:s.domElement.style.width,height:s.domElement.style.height},containerRect:{width:_.width,height:_.height},cameraAspect:u.aspect,matches:{width:Math.abs(s.domElement.width-_.width)<1,height:Math.abs(s.domElement.height-_.height)<1},sizeDifference:{width:s.domElement.width-_.width,height:s.domElement.height-_.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{m()})});let f=!1;dt.on("pause",()=>{f=!0,document.querySelectorAll("audio").forEach(d=>d.pause())}),dt.on("resume",()=>{f=!1,document.querySelectorAll("audio").forEach(d=>{d.currentTime>0&&!d.ended&&d.play().catch(()=>{})})});let T=new nt(e,r);return dt.on("resize",({payload:c})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:c,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),m({width:c==null?void 0:c.width,height:c==null?void 0:c.height}),T.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),m(),T.updateLayout()}),{scene:l,camera:u,renderer:s,uiSystem:T,applySize:m}}import*as H from"three";var ht=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||!isFinite(n)?.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}},pt=class{constructor(t){var n,i,a,o;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=(o=t==null?void 0:t.tint)!=null?o: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 H.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof H.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof H.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof H.Mesh&&t.material){let n=typeof this.tint=="string"?new H.Color(this.tint):new H.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof H.MeshBasicMaterial||i instanceof H.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof H.MeshBasicMaterial||t.material instanceof H.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new ht(a.transform),this.renderer=new pt(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)}},St=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 mt(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 ut={"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 G(e){let t=ut[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function X(e){var n;let t=ut[e];return t&&(n=t.weight)!=null?n:"400"}function Pn(e,t){ut[e]=t}function Yn(){return Object.keys(ut)}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 Nn(e,t,n,i){var Yt,Nt,Gt,Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,It,Ot,Ut,te,ee,ne,ae,ie,se,oe,re,le,ce,de,he,pe,me,ue,ye,ge,fe,Ee,be,Te,xe,we,_e,Se,He,Re,ve,Ce,Me,Ae,Fe,$e,Le,We,ke,Be,ze,De,Pe,Ye,Ne,Ge,Xe,qe,Ve,Ze,Je;let a=e.objects.get("ui_endgame_1"),o=e.objects.get("ui_endgame_logo_1"),r=e.objects.get("ui_endgame_title_1"),p=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),y=e.objects.get("ui_endgame_cta_1"),h=e.objects.get("ui_endgame_cta_hint_1"),u=e.objects.get("ui_endgame_hand_1"),s=e.engine.runtime||{},m=((Yt=a==null?void 0:a.gameplay)==null?void 0:Yt.tuning)||{},f=(a==null?void 0:a.render)||{},T=i.getBoundingClientRect(),c=T.width>0?T.width*.9:320,d=T.height>0?T.height*.85:400,g=Math.min((Nt=m.panel_width)!=null?Nt:320,c),b=Math.min((Gt=m.panel_height)!=null?Gt:400,d),E=(Xt=m.panel_padding)!=null?Xt:32,x=(qt=m.panel_radius)!=null?qt:24,w=f.background_color||m.panel_bg_color||"#1a0a0a",_=f.background_alpha!==void 0&&f.background_alpha!==null?f.background_alpha:(Vt=m.panel_bg_alpha)!=null?Vt:.98,R=f.border_color||m.panel_border_color||"#ffffff",v=(Zt=m.panel_border_width)!=null?Zt:2,M=(Jt=m.panel_border_alpha)!=null?Jt:.3,S=document.createElement("div");S.style.cssText=`
|
|
23
25
|
position: absolute;
|
|
24
|
-
width: ${
|
|
26
|
+
width: ${g}px;
|
|
25
27
|
height: ${b}px;
|
|
26
|
-
background: ${
|
|
27
|
-
opacity: ${
|
|
28
|
-
border: ${
|
|
29
|
-
border-opacity: ${
|
|
30
|
-
border-radius: ${
|
|
28
|
+
background: ${w};
|
|
29
|
+
opacity: ${_};
|
|
30
|
+
border: ${v}px solid ${R};
|
|
31
|
+
border-opacity: ${M};
|
|
32
|
+
border-radius: ${x}px;
|
|
31
33
|
display: block;
|
|
32
34
|
transform: translate(-50%, -50%);
|
|
33
35
|
opacity: 0;
|
|
@@ -37,25 +39,25 @@ import{b as pt}from"../chunk-3J2MAJRK.mjs";import*as I from"three";var Ke=(s=>(s
|
|
|
37
39
|
top: 50%;
|
|
38
40
|
z-index: 1000;
|
|
39
41
|
box-sizing: border-box;
|
|
40
|
-
padding: ${
|
|
41
|
-
`,
|
|
42
|
-
font-family: ${
|
|
43
|
-
font-size: ${
|
|
42
|
+
padding: ${E}px;
|
|
43
|
+
`,i.appendChild(S);let D=Q(S);D.element=S;let k=((Kt=o==null?void 0:o.gameplay)==null?void 0:Kt.tuning)||{},q=(o==null?void 0:o.transform)||{},W=(Qt=k.logo_size)!=null?Qt:56,B=(jt=q.scale)!=null?jt:1,j=(Ot=(It=q.offset)==null?void 0:It.y)!=null?Ot:-130,at=(Ut=k.logo_alpha)!=null?Ut:1,Ie=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),z=new U.Sprite(Ie);z.position.set(0,j,0),z.material.opacity=0;let it=0,st=0;if(n&&(it=((te=n.image)==null?void 0:te.width)||100,st=((ee=n.image)==null?void 0:ee.height)||100),it>0&&st>0){let I=it/st,xt,wt;I>1?(xt=W,wt=W/I):(wt=W,xt=W*I);let Bn=xt/it*B,zn=wt/st*B;z.scale.set(Bn,zn,1)}else{let I=W/100*B;z.scale.set(I,I,1)}z.targetAlpha=at,z.baseScaleX=z.scale.x,z.baseScaleY=z.scale.y;let A=r==null?void 0:r.ui,P=((ne=r==null?void 0:r.gameplay)==null?void 0:ne.tuning)||{},Oe=(A==null?void 0:A.text)||"MISSION ACCOMPLISHED",Ht=(A==null?void 0:A.font)||"brand.heading",Rt=(A==null?void 0:A.fontSize)||24,Ue=(ae=A==null?void 0:A.letterSpacing)!=null?ae:1,ot=(ie=r==null?void 0:r.render)==null?void 0:ie.tint,tn=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#00FF88",en=g-E*2-30,nn=P.font_weight_override?P.font_weight_override:X(Ht),V=document.createElement("div");V.textContent=Oe,V.style.cssText=`
|
|
44
|
+
font-family: ${G(Ht)};
|
|
45
|
+
font-size: ${Rt}px;
|
|
44
46
|
font-weight: ${nn};
|
|
45
47
|
color: ${tn};
|
|
46
48
|
text-align: center;
|
|
47
49
|
letter-spacing: ${Ue}px;
|
|
48
|
-
-webkit-text-stroke: ${(
|
|
50
|
+
-webkit-text-stroke: ${(se=P.stroke_width)!=null?se:2}px ${P.stroke_color||"#000000"};
|
|
49
51
|
text-shadow: ${(oe=P.shadow_distance)!=null?oe:4}px ${(re=P.shadow_distance)!=null?re:4}px ${(le=P.shadow_blur)!=null?le:8}px rgba(0,0,0,${(ce=P.shadow_alpha)!=null?ce:.9});
|
|
50
52
|
opacity: 0;
|
|
51
53
|
position: absolute;
|
|
52
54
|
transform: translate(-50%, -50%);
|
|
53
55
|
white-space: nowrap;
|
|
54
56
|
max-width: ${en}px;
|
|
55
|
-
`;let
|
|
56
|
-
font-family: ${
|
|
57
|
+
`;let vt=(de=m.title_offset_y)!=null?de:b*.25,an=vt+((he=P.animation_start_y_offset)!=null?he:-20);V.style.top=`${an}px`,V.style.left="50%";let Ct=Q(V);Ct.element=V,S.appendChild(V);let F=p==null?void 0:p.ui,Mt=((pe=p==null?void 0:p.gameplay)==null?void 0:pe.tuning)||{},sn=(F==null?void 0:F.text)||"RESCUE COMPLETE",At=(F==null?void 0:F.font)||"brand.body",on=(F==null?void 0:F.fontSize)||11,rn=(me=F==null?void 0:F.letterSpacing)!=null?me:.5,rt=(ue=p==null?void 0:p.render)==null?void 0:ue.tint,ln=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=document.createElement("div");Z.textContent=sn,Z.style.cssText=`
|
|
58
|
+
font-family: ${G(At)};
|
|
57
59
|
font-size: ${on}px;
|
|
58
|
-
font-weight: ${
|
|
60
|
+
font-weight: ${X(At)};
|
|
59
61
|
color: ${ln};
|
|
60
62
|
text-align: center;
|
|
61
63
|
letter-spacing: ${rn}px;
|
|
@@ -63,54 +65,54 @@ import{b as pt}from"../chunk-3J2MAJRK.mjs";import*as I from"three";var Ke=(s=>(s
|
|
|
63
65
|
position: absolute;
|
|
64
66
|
transform: translate(-50%, -50%);
|
|
65
67
|
white-space: nowrap;
|
|
66
|
-
`;let cn=
|
|
67
|
-
font-family: ${
|
|
68
|
-
font-size: ${
|
|
69
|
-
font-weight: ${
|
|
70
|
-
color: ${
|
|
68
|
+
`;let cn=vt+Rt*2.5+((ye=Mt.animation_start_y_offset)!=null?ye:-10);Z.style.top=`${cn}px`,Z.style.left="50%";let gt=Q(Z);gt.element=Z,gt.animationStartYOffset=(ge=Mt.animation_start_y_offset)!=null?ge:-10,S.appendChild(Z);let Y=l==null?void 0:l.ui,Ft=((fe=l==null?void 0:l.gameplay)==null?void 0:fe.tuning)||{},dn=(Y==null?void 0:Y.text)||((Ee=s.ui)==null?void 0:Ee.cta_hint)||"Continue the adventure!",$t=(Y==null?void 0:Y.font)||"brand.body",hn=(Y==null?void 0:Y.fontSize)||16,lt=(be=l==null?void 0:l.render)==null?void 0:be.tint,pn=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#FFFFFF",mn=(Te=Ft.max_width)!=null?Te:g-E*2,un=(xe=Ft.line_height)!=null?xe:1.4,J=document.createElement("div");J.textContent=dn,J.style.cssText=`
|
|
69
|
+
font-family: ${G($t)};
|
|
70
|
+
font-size: ${hn}px;
|
|
71
|
+
font-weight: ${X($t)};
|
|
72
|
+
color: ${pn};
|
|
71
73
|
text-align: center;
|
|
72
74
|
opacity: 0;
|
|
73
75
|
position: absolute;
|
|
74
76
|
transform: translate(-50%, -50%);
|
|
75
|
-
max-width: ${
|
|
77
|
+
max-width: ${mn}px;
|
|
76
78
|
line-height: ${un};
|
|
77
79
|
word-wrap: break-word;
|
|
78
|
-
`;let yn=(
|
|
79
|
-
width: ${
|
|
80
|
+
`;let yn=(we=m.footer_offset_y)!=null?we:b*.5;J.style.top=`${yn}px`,J.style.left="50%";let ft=Q(J);ft.element=J;let gn=((_e=l==null?void 0:l.render)==null?void 0:_e.alpha)!==void 0&&((Se=l==null?void 0:l.render)==null?void 0:Se.alpha)!==null?l.render.alpha:1;ft.targetAlpha=gn,S.appendChild(J);let N=((He=y==null?void 0:y.gameplay)==null?void 0:He.tuning)||{},$=y==null?void 0:y.ui,fn=(Re=N.button_width)!=null?Re:260,Lt=(ve=N.button_height)!=null?ve:56,En=(Ce=N.button_radius)!=null?Ce:16,bn=N.button_bg_color||((Me=s.theme)==null?void 0:Me.cta_background)||"#ffb43b",Tn=(Ae=N.button_bg_alpha)!=null?Ae:1,xn=N.button_border_color||"#ffffff",wn=(Fe=N.button_border_width)!=null?Fe:2,na=($e=N.button_border_alpha)!=null?$e:.2,Et=(Le=m.cta_offset_y)!=null?Le:b*.75,C=document.createElement("button");C.style.cssText=`
|
|
81
|
+
width: ${fn}px;
|
|
80
82
|
height: ${Lt}px;
|
|
81
|
-
background: ${
|
|
82
|
-
opacity: ${
|
|
83
|
-
border: ${
|
|
84
|
-
border-radius: ${
|
|
83
|
+
background: ${bn};
|
|
84
|
+
opacity: ${Tn};
|
|
85
|
+
border: ${wn}px solid ${xn};
|
|
86
|
+
border-radius: ${En}px;
|
|
85
87
|
cursor: pointer;
|
|
86
88
|
opacity: 0;
|
|
87
89
|
position: absolute;
|
|
88
90
|
transform: translate(-50%, -50%);
|
|
89
91
|
box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
|
|
90
|
-
`,
|
|
91
|
-
font-family: ${
|
|
92
|
-
font-size: ${
|
|
93
|
-
font-weight: ${
|
|
92
|
+
`,C.style.top=`${Et}px`,C.style.left="50%";let Wt=Q(C);Wt.element=C,S.appendChild(C);let _n=($==null?void 0:$.text)||((We=s.ui)==null?void 0:We.cta_label_end)||"DOWNLOAD",kt=($==null?void 0:$.font)||"brand.heading",Sn=($==null?void 0:$.fontSize)||20,Hn=N.button_text_color||((ke=s.theme)==null?void 0:ke.cta_text)||"#1a0a0a";C.textContent=_n,C.style.fontFamily=G(kt),C.style.fontSize=`${Sn}px`,C.style.fontWeight=String(X(kt)),C.style.color=Hn,C.style.letterSpacing=`${(Be=$==null?void 0:$.letterSpacing)!=null?Be:1}px`;let Bt=Q(C);Bt.element=C;let L=h==null?void 0:h.ui,zt=((ze=h==null?void 0:h.gameplay)==null?void 0:ze.tuning)||{},Rn=(L==null?void 0:L.text)||"Play the full game",Dt=(L==null?void 0:L.font)||"brand.body",vn=(L==null?void 0:L.fontSize)||11,Cn=(De=L==null?void 0:L.letterSpacing)!=null?De:0,ct=(Pe=h==null?void 0:h.render)==null?void 0:Pe.tint,Mn=typeof ct=="string"?ct:ct?`#${ct.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=Rn,K.style.cssText=`
|
|
93
|
+
font-family: ${G(Dt)};
|
|
94
|
+
font-size: ${vn}px;
|
|
95
|
+
font-weight: ${X(Dt)};
|
|
94
96
|
color: ${Mn};
|
|
95
97
|
text-align: center;
|
|
96
|
-
letter-spacing: ${
|
|
98
|
+
letter-spacing: ${Cn}px;
|
|
97
99
|
opacity: 0;
|
|
98
100
|
position: absolute;
|
|
99
101
|
transform: translate(-50%, -50%);
|
|
100
102
|
white-space: nowrap;
|
|
101
|
-
`;let
|
|
102
|
-
font-family: ${
|
|
103
|
+
`;let An=Et+Lt/2+15+((Ye=zt.animation_start_y_offset)!=null?Ye:5);K.style.top=`${An}px`,K.style.left="50%";let bt=Q(K);bt.element=K,bt.animationStartYOffset=(Ne=zt.animation_start_y_offset)!=null?Ne:5,S.appendChild(K);let Tt=((Ge=u==null?void 0:u.gameplay)==null?void 0:Ge.tuning)||{},Fn=(Xe=Tt.hand_offset_x)!=null?Xe:50,$n=(qe=Tt.hand_offset_y)!=null?qe:50,Ln=(Ze=(Ve=u==null?void 0:u.transform)==null?void 0:Ve.scale)!=null?Ze:.1875,Wn=(Je=Tt.hand_scale_multiplier)!=null?Je:2.5,kn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(kn),Pt=Ln*Wn*100;return et.scale.set(Pt,Pt,1),et.position.set(Fn,Et+$n,0),et.material.opacity=0,et.visible=!1,{panel:D,logo:z,title:Ct,subtitle:gt,footer:ft,ctaButton:Wt,ctaText:Bt,ctaHint:bt,hand:et}}function Gn(e,t,n){var w,_,R,v,M,S,D,k;let i=t.objects.get("ui_endgame_1"),a=((w=i==null?void 0:i.gameplay)==null?void 0:w.tuning)||{},o=(_=a.animation_duration_ms)!=null?_:800,r=(R=a.fade_in_duration_ms)!=null?R:600,p=(v=a.scale_animation_intensity)!=null?v:.1,l=(M=a.logo_animation_delay_ms)!=null?M:100,y=(S=a.title_animation_delay_ms)!=null?S:200,h=(D=a.footer_animation_delay_ms)!=null?D:300,u=(k=a.cta_animation_delay_ms)!=null?k:400,{panel:s,logo:m,title:f,subtitle:T,footer:c,ctaButton:d,ctaText:g,ctaHint:b}=e;s.visible=!0,s.element.style.visibility="visible";let E=Date.now(),x=()=>{let q=Date.now()-E,W=Math.min(q/r,1),B=1-Math.pow(1-W,3);s.alpha=B,s.element.style.opacity=B.toString();let j=1+p*(1-B);s.element.style.transform=`translate(-50%, -50%) scale(${j})`,W<1?requestAnimationFrame(x):(setTimeout(()=>Xn(m,o,t),l),setTimeout(()=>{qn(f,o),setTimeout(()=>Vn(T,o),50)},y),setTimeout(()=>Zn(c,o),h),setTimeout(()=>{Jn(d,g,o),setTimeout(()=>Kn(b,o),50),n&&n()},u))};x()}function Xn(e,t,n){var s,m,f,T,c;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),o=(m=(((s=i==null?void 0:i.gameplay)==null?void 0:s.tuning)||{}).animation_start_scale)!=null?m:1.2,r=Date.now(),p=e.material.opacity,l=(f=e.targetAlpha)!=null?f:1,y=(T=e.baseScaleX)!=null?T:e.scale.x,h=(c=e.baseScaleY)!=null?c:e.scale.y,u=()=>{let d=Date.now()-r,g=Math.min(d/t,1),b=1-Math.pow(1-g,2);e.material.opacity=p+(l-p)*b;let E=o+(1-o)*b;e.scale.set(y*E,h*E,1),g<1&&requestAnimationFrame(u)};u()}function qn(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),o=()=>{let r=Date.now()-n,p=Math.min(r/t,1),l=1-Math.pow(1-p,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a-20*(1-l)}px`,p<1&&requestAnimationFrame(o)};o()}function Vn(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),o=a-((p=e.animationStartYOffset)!=null?p:-10),r=()=>{let l=Date.now()-n,y=Math.min(l/t,1),h=1-Math.pow(1-y,2);e.element.style.opacity=(i+(1-i)*h).toString(),e.element.style.top=`${a+(o-a)*h}px`,y<1&&requestAnimationFrame(r)};r()}function Zn(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(r=e.targetAlpha)!=null?r:1,o=()=>{let p=Date.now()-n,l=Math.min(p/t,1),y=1-Math.pow(1-l,2);e.element.style.opacity=(i+(a-i)*y).toString(),l<1&&requestAnimationFrame(o)};o()}function Jn(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),o=()=>{let r=Date.now()-i,p=Math.min(r/n,1),l=1-Math.pow(1-p,2);e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,p<1&&requestAnimationFrame(o)};o()}function Kn(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),o=a-((p=e.animationStartYOffset)!=null?p:5),r=()=>{let l=Date.now()-n,y=Math.min(l/t,1),h=1-Math.pow(1-y,2);e.element.style.opacity=(i+(1-i)*h).toString(),e.element.style.top=`${a+(o-a)*h}px`,y<1&&requestAnimationFrame(r)};r()}function Qn(e,t,n,i){var h,u,s,m;let a=n.objects.get("ui_endgame_hand_1"),o=((h=a==null?void 0:a.gameplay)==null?void 0:h.tuning)||{},r=(u=o.click_animation_duration_ms)!=null?u:600,p=(s=o.click_delay_ms)!=null?s:2e3,l=(m=o.click_repeat_delay_ms)!=null?m:3e3,y=()=>{var _,R;e.visible=!0,e.material.opacity=1;let f=e.position.x,T=e.position.y,c=(_=o.hand_offset_x)!=null?_:50,d=(R=o.hand_offset_y)!=null?R:50,g=t.element.getBoundingClientRect(),b=c,E=d,x=Date.now(),w=()=>{var B,j,at;let v=Date.now()-x,M=Math.min(v/r,1),S=M<.5?2*M*M:1-Math.pow(-2*M+2,2)/2;e.position.set(f+(b-f)*S,T+(E-T)*S,0);let D=(j=(B=a==null?void 0:a.transform)==null?void 0:B.scale)!=null?j:.1875,k=(at=o.hand_scale_multiplier)!=null?at:2.5,q=D*k*100,W=q+q*.2*Math.sin(M*Math.PI);e.scale.set(W,W,1),M<1?requestAnimationFrame(w):(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(f,T,0),y()},l)},500))};w()};setTimeout(y,p)}import*as yt from"three";function jn(e,t,n){var u,s,m,f;let i=t.objects.get("hand_tutorial_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},o=(i==null?void 0:i.render)||{},r=(i==null?void 0:i.transform)||{},p=new yt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),l=new yt.Sprite(p);l.position.set(n.x,n.y,0),l.material.opacity=0;let y=(s=a.hand_scale_multiplier)!=null?s:2.5,h=(m=r.scale)!=null?m:.1875;return l.scale.set(h*y*100,h*y*100,1),l.renderOrder=(f=o.z_index)!=null?f:99999,l}function In(e){var f,T,c,d,g,b,E,x,w;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((f=e.engine.runtime)==null?void 0:f.ui_styles)||{},o=((T=e.engine.runtime)==null?void 0:T.ui)||{},r=(n==null?void 0:n.text)||o.tutorial_label||o.label_text||"CLEAN!",p=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,y=(d=n==null?void 0:n.letterSpacing)!=null?d:(c=a.label_letter_spacing)!=null?c:-1,h=(n==null?void 0:n.align)||"center",u=i.tint,s=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",m=document.createElement("div");return m.textContent=r,m.style.cssText=`
|
|
104
|
+
font-family: ${G(p)};
|
|
103
105
|
font-size: ${l}px;
|
|
104
|
-
font-weight: ${
|
|
105
|
-
color: ${
|
|
106
|
-
text-align: ${
|
|
106
|
+
font-weight: ${X(p)};
|
|
107
|
+
color: ${s};
|
|
108
|
+
text-align: ${h};
|
|
107
109
|
letter-spacing: ${y}px;
|
|
108
|
-
text-shadow: ${(
|
|
110
|
+
text-shadow: ${(g=a.label_shadow_distance)!=null?g:2}px ${(b=a.label_shadow_distance)!=null?b:2}px ${(E=a.label_shadow_blur)!=null?E:4}px rgba(0,0,0,${(x=a.label_shadow_alpha)!=null?x:.8});
|
|
109
111
|
-webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
|
|
110
|
-
opacity: ${(
|
|
111
|
-
visibility: ${
|
|
112
|
+
opacity: ${(w=i.alpha)!=null?w:0};
|
|
113
|
+
visibility: ${i.visible!==!1?"visible":"hidden"};
|
|
112
114
|
pointer-events: none;
|
|
113
115
|
position: absolute;
|
|
114
116
|
transform: translate(-50%, -50%);
|
|
115
117
|
white-space: nowrap;
|
|
116
|
-
`,
|
|
118
|
+
`,m}function On(e,t,n,i,a){var l,y,h,u,s,m,f;let o=a.objects.get("hand_tutorial_1"),r=((l=o==null?void 0:o.gameplay)==null?void 0:l.tuning)||{},p=(o==null?void 0:o.transform)||{};if(!i){let T=(y=r.animation_duration)!=null?y:1.5,c=n%T/T,d=c<.5?2*c*c:-1+(4-2*c)*c,g=(h=r.x_offset)!=null?h:0,b=(u=r.y_offset)!=null?u:0,E=(s=r.animation_range)!=null?s:40,x=E*.7,w=E,_=t.x+g+x,R=t.y+b+w,v=_+x,M=R+w;e.position.set(_+(v-_)*d,R+(M-R)*d,0);let S=(m=p.scale)!=null?m:.1875,D=(f=r.hand_scale_multiplier)!=null?f:2.5,k=S*D*100;e.scale.set(k,k,1)}}import*as tt from"three";var Qe=new tt.TextureLoader;async function je(e,t,n=16777215,i=!1){try{let o=(globalThis.INLINE_ASSETS||{})[e];return await Qe.loadAsync(o||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let o=document.createElement("canvas");o.width=64,o.height=64;let r=o.getContext("2d");return r&&(r.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?r.fillRect(0,0,30,60):(r.beginPath(),r.arc(32,32,30,0,Math.PI*2),r.fill(),r.fillRect(27,32,10,40))),new tt.CanvasTexture(o)}}async function Un(e,t,n){var f,T,c,d;let a=(globalThis.INLINE_ASSETS||{})[e]||e,o;try{o=await Qe.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(g){let x=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");o=await je(e,t,parseInt(x,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}if(!o)return[];let r=n.gameplay.character_sheet||{},p=(f=r.cols)!=null?f:3,l=(T=r.rows)!=null?T:2,y=((c=o.image)==null?void 0:c.width)||0,h=((d=o.image)==null?void 0:d.height)||0,u=y/p,s=h/l;if(!Number.isFinite(u)||!Number.isFinite(s)||u<=0||s<=0)return[o];let m=[];for(let g=0;g<l;g++)for(let b=0;b<p;b++){let E=document.createElement("canvas");E.width=u,E.height=s;let x=E.getContext("2d");x&&o.image&&x.drawImage(o.image,b*u,g*s,u,s,0,0,u,s),m.push(new tt.CanvasTexture(E))}return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function ta(e,t){var u,s,m,f;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(u=n.radius)!=null?u:20,o=(s=n.inner_radius)!=null?s:15,r=(m=n.alpha)!=null?m:.8,p=(f=n.inner_alpha)!=null?f:.3,l=n.inner_color||"#ffffff",y=document.createElement("canvas");y.width=a*2,y.height=a*2;let h=y.getContext("2d");return h&&(h.clearRect(0,0,y.width,y.height),h.beginPath(),h.arc(a,a,a,0,Math.PI*2),h.fillStyle=i,h.globalAlpha=r,h.fill(),h.beginPath(),h.arc(a,a,o,0,Math.PI*2),h.fillStyle=l,h.globalAlpha=p,h.fill()),new tt.CanvasTexture(y)}export{Ke as AspectClass,mt as GameObject,St as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ht as Transform,Qn as animateHandClick,Gn as animatePanelEntrance,ta as createBrushTexture,Nn as createEndGamePanel,jn as createHandTutorial,Dn as createThreeBase,In as createTutorialLabel,_t as getAspectClass,Yn as getRegisteredFontIds,je as loadAsset,Un as loadCharacterFrames,Pn as registerFont,G as resolveFont,X as resolveFontWeight,On as updateHandAnimation};
|
package/package.json
CHANGED