handler-playable-sdk 0.1.8 → 0.1.10
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-LQX44TET.mjs +17 -0
- 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.d.mts +81 -5
- package/dist/three/index.d.ts +81 -5
- package/dist/three/index.js +81 -55
- package/dist/three/index.mjs +79 -53
- package/package.json +1 -1
- package/dist/chunk-5XZYWKIQ.mjs +0 -17
package/dist/three/index.mjs
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as lt}from"../chunk-LQX44TET.mjs";import*as I from"three";var qe=(s=>(s[s.PHONE_TALL=0]="PHONE_TALL",s[s.TABLET=1]="TABLET",s[s.LANDSCAPE=2]="LANDSCAPE",s))(qe||{});function Et(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=Et(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 Et(t.width,t.height)}};async function Dn(e,t={}){let n=()=>{let d=e.style.width||"",g=e.style.height||"",h=320,f=480,E=window.getComputedStyle(e),w=d||E.width,S=g||E.height;if(w&&w!=="auto"&&!w.includes("%")){let T=parseFloat(w);!isNaN(T)&&T>0&&isFinite(T)&&(h=T)}if(S&&S!=="auto"&&!S.includes("%")){let T=parseFloat(S);!isNaN(T)&&T>0&&isFinite(T)&&(f=T)}let H=e.clientWidth,_=e.clientHeight;if((h===320||h<=0||!isFinite(h))&&H&&H>0&&(h=H),(f===480||f<=0||!isFinite(f))&&_&&_>0&&(f=_),h<=0||f<=0||!isFinite(h)||!isFinite(f)){let T=e.getBoundingClientRect();T.width>0&&isFinite(T.width)&&(h=T.width),T.height>0&&isFinite(T.height)&&(f=T.height)}return(h<=0||!isFinite(h))&&(h=e.clientWidth||window.innerWidth||320),(f<=0||!isFinite(f))&&(f=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:h,height:f,styleWidth:d,styleHeight:g,effectiveWidth:w,effectiveHeight:S,computedWidth:E.width,computedHeight:E.height,clientWidth:H,clientHeight:_,boundingRect:e.getBoundingClientRect()}),{width:h,height:f}},s=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 i=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",i,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let o=document.createElement("div");o.style.cssText=`
|
|
2
|
+
position: absolute !important;
|
|
3
|
+
top: 0 !important;
|
|
4
|
+
left: 0 !important;
|
|
5
|
+
right: 0 !important;
|
|
6
|
+
bottom: 0 !important;
|
|
7
|
+
width: 100% !important;
|
|
8
|
+
height: 100% !important;
|
|
9
|
+
min-width: 100% !important;
|
|
10
|
+
min-height: 100% !important;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
background: ${i} !important;
|
|
15
|
+
background-size: cover !important;
|
|
16
|
+
background-position: center !important;
|
|
17
|
+
background-repeat: no-repeat !important;
|
|
18
|
+
color: var(--h-text, #f4f6ff);
|
|
19
|
+
font-family: var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif);
|
|
20
|
+
box-sizing: border-box !important;
|
|
21
|
+
margin: 0 !important;
|
|
22
|
+
padding: 0 !important;
|
|
23
|
+
border: none !important;
|
|
24
|
+
`,e.appendChild(o);let p=document.createElement("div");p.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),o.appendChild(p);let r=new I.Scene,{width:y,height:c}=n(),u=new I.PerspectiveCamera(55,y/c,.1,100);u.position.set(0,0,3.2),u.lookAt(0,0,0),u.updateMatrixWorld();let l=new I.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});l.setPixelRatio(window.devicePixelRatio||1),l.setSize(y,c),l.setClearColor(0,0),l.domElement.style.position="absolute",l.domElement.style.top="0",l.domElement.style.left="0",l.domElement.style.width="100%",l.domElement.style.height="100%",l.domElement.style.display="block",l.domElement.style.pointerEvents="auto",p.appendChild(l.domElement);let m=d=>{let g,h;if(typeof(d==null?void 0:d.width)=="number"&&d.width>0?g=d.width:g=n().width,typeof(d==null?void 0:d.height)=="number"&&d.height>0?h=d.height:h=n().height,g<=0||h<=0||!isFinite(g)||!isFinite(h)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:g,newHeight:h,size:d});let f=n();g=f.width,h=f.height}console.log("[THREE-BASE] applySize:",{newWidth:g,newHeight:h,providedSize:d,containerSize:n()}),l.setSize(g,h),l.setPixelRatio(window.devicePixelRatio||1),u.aspect=g/h,u.updateProjectionMatrix()};requestAnimationFrame(()=>m());let b=!1;lt.on("pause",()=>{b=!0,document.querySelectorAll("audio").forEach(g=>g.pause())}),lt.on("resume",()=>{b=!1,document.querySelectorAll("audio").forEach(g=>{g.currentTime>0&&!g.ended&&g.play().catch(()=>{})})});let x=new nt(e,o);return lt.on("resize",({payload:d})=>{m({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),x.updateLayout()}),window.addEventListener("resize",()=>{m(),x.updateLayout()}),{scene:r,camera:u,renderer:l,uiSystem:x,applySize:m}}import*as v from"three";var ct=class{constructor(t){var n,s;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=(s=t==null?void 0:t.rotation)!=null?s: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,s=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,s),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,s,a,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(s=t==null?void 0:t.alpha)!=null?s:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i: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 v.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof v.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof v.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof v.Mesh&&t.material){let n=typeof this.tint=="string"?new v.Color(this.tint):new v.Color(this.tint);Array.isArray(t.material)?t.material.forEach(s=>{(s instanceof v.MeshBasicMaterial||s instanceof v.MeshStandardMaterial)&&s.color.copy(n)}):(t.material instanceof v.MeshBasicMaterial||t.material instanceof v.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,s,a){this.instanceId=t,this.objectConfig=n,this.threeObject=s,this._config=a,this.transform=new ct(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)}},_t=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let s=this.config.objects.get(t);if(!s)throw new Error(`Object config not found: ${t}`);let a=new mt(t,s.object_config||t,n,s);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,s]of this.objects.entries()){let a=t.objects.get(n);a&&s.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var dt={"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=dt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function N(e){var n;let t=dt[e];return t&&(n=t.weight)!=null?n:"400"}function kn(e,t){dt[e]=t}function zn(){return Object.keys(dt)}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 Bn(e,t,n,s){var kt,zt,Bt,Pt,Yt,Nt,Gt,Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,pe,me,de,ue,he,ye,fe,ge,be,Te,xe,Ee,_e,we,Se,He,Ce,ve,Re,Fe,Me,Ae,$e,Le,We,De,ke,ze,Be,Pe,Ye,Ne,Ge,Xe;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),o=e.objects.get("ui_endgame_title_1"),p=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),y=e.objects.get("ui_endgame_cta_1"),c=e.objects.get("ui_endgame_cta_hint_1"),u=e.objects.get("ui_endgame_hand_1"),l=e.engine.runtime||{},m=((kt=a==null?void 0:a.gameplay)==null?void 0:kt.tuning)||{},b=(a==null?void 0:a.render)||{},x=(zt=m.panel_width)!=null?zt:320,d=(Bt=m.panel_height)!=null?Bt:400,g=(Pt=m.panel_padding)!=null?Pt:32,h=(Yt=m.panel_radius)!=null?Yt:24,f=b.background_color||m.panel_bg_color||"#1a0a0a",E=b.background_alpha!==void 0&&b.background_alpha!==null?b.background_alpha:(Nt=m.panel_bg_alpha)!=null?Nt:.98,w=b.border_color||m.panel_border_color||"#ffffff",S=(Gt=m.panel_border_width)!=null?Gt:2,H=(Xt=m.panel_border_alpha)!=null?Xt:.3,_=document.createElement("div");_.style.cssText=`
|
|
2
25
|
position: absolute;
|
|
3
|
-
width: ${
|
|
4
|
-
height: ${
|
|
26
|
+
width: ${x}px;
|
|
27
|
+
height: ${d}px;
|
|
5
28
|
background: ${f};
|
|
6
|
-
opacity: ${
|
|
7
|
-
border: ${
|
|
8
|
-
border-opacity: ${
|
|
9
|
-
border-radius: ${
|
|
29
|
+
opacity: ${E};
|
|
30
|
+
border: ${S}px solid ${w};
|
|
31
|
+
border-opacity: ${H};
|
|
32
|
+
border-radius: ${h}px;
|
|
10
33
|
display: flex;
|
|
11
34
|
flex-direction: column;
|
|
12
35
|
align-items: center;
|
|
@@ -15,79 +38,82 @@ import{b as ot}from"../chunk-5XZYWKIQ.mjs";import*as I from"three";async functio
|
|
|
15
38
|
opacity: 0;
|
|
16
39
|
visibility: hidden;
|
|
17
40
|
pointer-events: auto;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
left: 50%;
|
|
42
|
+
top: 50%;
|
|
43
|
+
z-index: 1000;
|
|
44
|
+
`,s.appendChild(_);let T=Q(_);T.element=_;let R=((qt=i==null?void 0:i.gameplay)==null?void 0:qt.tuning)||{},k=(i==null?void 0:i.transform)||{},M=(Vt=R.logo_size)!=null?Vt:56,D=(Zt=k.scale)!=null?Zt:1,j=(Kt=(Jt=k.offset)==null?void 0:Jt.y)!=null?Kt:-130,X=(Qt=R.logo_alpha)!=null?Qt:1,G=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),C=new U.Sprite(G);C.position.set(0,j,0),C.material.opacity=0;let q=0,at=0;if(n&&(q=((jt=n.image)==null?void 0:jt.width)||100,at=((Ot=n.image)==null?void 0:Ot.height)||100),q>0&&at>0){let O=q/at,Tt,xt;O>1?(Tt=M,xt=M/O):(xt=M,Tt=M*O);let Ln=Tt/q*D,Wn=xt/at*D;C.scale.set(Ln,Wn,1)}else{let O=M/100*D;C.scale.set(O,O,1)}C.targetAlpha=X,C.baseScaleX=C.scale.x,C.baseScaleY=C.scale.y;let A=o==null?void 0:o.ui,z=((It=o==null?void 0:o.gameplay)==null?void 0:It.tuning)||{},Je=(A==null?void 0:A.text)||"MISSION ACCOMPLISHED",wt=(A==null?void 0:A.font)||"brand.heading",Ke=(A==null?void 0:A.fontSize)||24,Qe=(Ut=A==null?void 0:A.letterSpacing)!=null?Ut:1,st=(te=o==null?void 0:o.render)==null?void 0:te.tint,je=typeof st=="string"?st:st?`#${st.toString(16).padStart(6,"0")}`:"#00FF88",Oe=x-g*2-30,Ie=z.font_weight_override?z.font_weight_override:N(wt),V=document.createElement("div");V.textContent=Je,V.style.cssText=`
|
|
45
|
+
font-family: ${Y(wt)};
|
|
46
|
+
font-size: ${Ke}px;
|
|
47
|
+
font-weight: ${Ie};
|
|
48
|
+
color: ${je};
|
|
23
49
|
text-align: center;
|
|
24
|
-
letter-spacing: ${
|
|
25
|
-
-webkit-text-stroke: ${(
|
|
26
|
-
text-shadow: ${(
|
|
50
|
+
letter-spacing: ${Qe}px;
|
|
51
|
+
-webkit-text-stroke: ${(ee=z.stroke_width)!=null?ee:2}px ${z.stroke_color||"#000000"};
|
|
52
|
+
text-shadow: ${(ne=z.shadow_distance)!=null?ne:4}px ${(ae=z.shadow_distance)!=null?ae:4}px ${(se=z.shadow_blur)!=null?se:8}px rgba(0,0,0,${(ie=z.shadow_alpha)!=null?ie:.9});
|
|
27
53
|
opacity: 0;
|
|
28
54
|
position: absolute;
|
|
29
55
|
transform: translate(-50%, -50%);
|
|
30
56
|
white-space: nowrap;
|
|
31
|
-
max-width: ${
|
|
32
|
-
`;let
|
|
33
|
-
font-family: ${
|
|
34
|
-
font-size: ${
|
|
35
|
-
font-weight: ${
|
|
36
|
-
color: ${
|
|
57
|
+
max-width: ${Oe}px;
|
|
58
|
+
`;let St=(oe=m.title_offset_y)!=null?oe:30,Ue=St+((re=z.animation_start_y_offset)!=null?re:-20);V.style.top=`${Ue}px`,V.style.left="50%";let Ht=Q(V);Ht.element=V,_.appendChild(V);let $=p==null?void 0:p.ui,Ct=((le=p==null?void 0:p.gameplay)==null?void 0:le.tuning)||{},tn=($==null?void 0:$.text)||"RESCUE COMPLETE",vt=($==null?void 0:$.font)||"brand.body",en=($==null?void 0:$.fontSize)||11,nn=(ce=$==null?void 0:$.letterSpacing)!=null?ce:.5,it=(pe=p==null?void 0:p.render)==null?void 0:pe.tint,an=typeof it=="string"?it:it?`#${it.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=document.createElement("div");Z.textContent=tn,Z.style.cssText=`
|
|
59
|
+
font-family: ${Y(vt)};
|
|
60
|
+
font-size: ${en}px;
|
|
61
|
+
font-weight: ${N(vt)};
|
|
62
|
+
color: ${an};
|
|
37
63
|
text-align: center;
|
|
38
|
-
letter-spacing: ${
|
|
64
|
+
letter-spacing: ${nn}px;
|
|
39
65
|
opacity: 0;
|
|
40
66
|
position: absolute;
|
|
41
67
|
transform: translate(-50%, -50%);
|
|
42
68
|
white-space: nowrap;
|
|
43
|
-
`;let
|
|
44
|
-
font-family: ${
|
|
45
|
-
font-size: ${
|
|
46
|
-
font-weight: ${
|
|
47
|
-
color: ${
|
|
69
|
+
`;let sn=St+20+((me=Ct.animation_start_y_offset)!=null?me:-10);Z.style.top=`${sn}px`,Z.style.left="50%";let ht=Q(Z);ht.element=Z,ht.animationStartYOffset=(de=Ct.animation_start_y_offset)!=null?de:-10,_.appendChild(Z);let B=r==null?void 0:r.ui,Rt=((ue=r==null?void 0:r.gameplay)==null?void 0:ue.tuning)||{},on=(B==null?void 0:B.text)||((he=l.ui)==null?void 0:he.cta_hint)||"Continue the adventure!",Ft=(B==null?void 0:B.font)||"brand.body",rn=(B==null?void 0:B.fontSize)||16,ot=(ye=r==null?void 0:r.render)==null?void 0:ye.tint,ln=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#FFFFFF",cn=(fe=Rt.max_width)!=null?fe:x-g*2,pn=(ge=Rt.line_height)!=null?ge:1.4,J=document.createElement("div");J.textContent=on,J.style.cssText=`
|
|
70
|
+
font-family: ${Y(Ft)};
|
|
71
|
+
font-size: ${rn}px;
|
|
72
|
+
font-weight: ${N(Ft)};
|
|
73
|
+
color: ${ln};
|
|
48
74
|
text-align: center;
|
|
49
75
|
opacity: 0;
|
|
50
76
|
position: absolute;
|
|
51
77
|
transform: translate(-50%, -50%);
|
|
52
|
-
max-width: ${
|
|
53
|
-
line-height: ${
|
|
78
|
+
max-width: ${cn}px;
|
|
79
|
+
line-height: ${pn};
|
|
54
80
|
word-wrap: break-word;
|
|
55
|
-
`;let
|
|
56
|
-
width: ${
|
|
57
|
-
height: ${
|
|
58
|
-
background: ${
|
|
59
|
-
opacity: ${
|
|
60
|
-
border: ${
|
|
61
|
-
border-radius: ${
|
|
81
|
+
`;let mn=(be=m.footer_offset_y)!=null?be:120;J.style.top=`${mn}px`,J.style.left="50%";let yt=Q(J);yt.element=J;let dn=((Te=r==null?void 0:r.render)==null?void 0:Te.alpha)!==void 0&&((xe=r==null?void 0:r.render)==null?void 0:xe.alpha)!==null?r.render.alpha:1;yt.targetAlpha=dn,_.appendChild(J);let P=((Ee=y==null?void 0:y.gameplay)==null?void 0:Ee.tuning)||{},L=y==null?void 0:y.ui,un=(_e=P.button_width)!=null?_e:260,hn=(we=P.button_height)!=null?we:56,yn=(Se=P.button_radius)!=null?Se:16,fn=P.button_bg_color||((He=l.theme)==null?void 0:He.cta_background)||"#ffb43b",gn=(Ce=P.button_bg_alpha)!=null?Ce:1,bn=P.button_border_color||"#ffffff",Tn=(ve=P.button_border_width)!=null?ve:2,Un=(Re=P.button_border_alpha)!=null?Re:.2,ft=(Fe=m.cta_offset_y)!=null?Fe:160,F=document.createElement("button");F.style.cssText=`
|
|
82
|
+
width: ${un}px;
|
|
83
|
+
height: ${hn}px;
|
|
84
|
+
background: ${fn};
|
|
85
|
+
opacity: ${gn};
|
|
86
|
+
border: ${Tn}px solid ${bn};
|
|
87
|
+
border-radius: ${yn}px;
|
|
62
88
|
cursor: pointer;
|
|
63
89
|
opacity: 0;
|
|
64
90
|
position: absolute;
|
|
65
91
|
transform: translate(-50%, -50%);
|
|
66
92
|
box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
|
|
67
|
-
`,
|
|
68
|
-
font-family: ${
|
|
69
|
-
font-size: ${
|
|
70
|
-
font-weight: ${
|
|
71
|
-
color: ${
|
|
93
|
+
`,F.style.top=`${ft}px`,F.style.left="50%";let Mt=Q(F);Mt.element=F,_.appendChild(F);let xn=(L==null?void 0:L.text)||((Me=l.ui)==null?void 0:Me.cta_label_end)||"DOWNLOAD",At=(L==null?void 0:L.font)||"brand.heading",En=(L==null?void 0:L.fontSize)||20,_n=P.button_text_color||((Ae=l.theme)==null?void 0:Ae.cta_text)||"#1a0a0a";F.textContent=xn,F.style.fontFamily=Y(At),F.style.fontSize=`${En}px`,F.style.fontWeight=String(N(At)),F.style.color=_n,F.style.letterSpacing=`${($e=L==null?void 0:L.letterSpacing)!=null?$e:1}px`;let $t=Q(F);$t.element=F;let W=c==null?void 0:c.ui,Lt=((Le=c==null?void 0:c.gameplay)==null?void 0:Le.tuning)||{},wn=(W==null?void 0:W.text)||"Play the full game",Wt=(W==null?void 0:W.font)||"brand.body",Sn=(W==null?void 0:W.fontSize)||11,Hn=(We=W==null?void 0:W.letterSpacing)!=null?We:0,rt=(De=c==null?void 0:c.render)==null?void 0:De.tint,Cn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=wn,K.style.cssText=`
|
|
94
|
+
font-family: ${Y(Wt)};
|
|
95
|
+
font-size: ${Sn}px;
|
|
96
|
+
font-weight: ${N(Wt)};
|
|
97
|
+
color: ${Cn};
|
|
72
98
|
text-align: center;
|
|
73
|
-
letter-spacing: ${
|
|
99
|
+
letter-spacing: ${Hn}px;
|
|
74
100
|
opacity: 0;
|
|
75
101
|
position: absolute;
|
|
76
102
|
transform: translate(-50%, -50%);
|
|
77
103
|
white-space: nowrap;
|
|
78
|
-
`;let
|
|
79
|
-
font-family: ${
|
|
80
|
-
font-size: ${
|
|
81
|
-
font-weight: ${
|
|
82
|
-
color: ${
|
|
83
|
-
text-align: ${
|
|
84
|
-
letter-spacing: ${
|
|
85
|
-
text-shadow: ${(
|
|
104
|
+
`;let vn=ft+35+((ke=Lt.animation_start_y_offset)!=null?ke:5);K.style.top=`${vn}px`,K.style.left="50%";let gt=Q(K);gt.element=K,gt.animationStartYOffset=(ze=Lt.animation_start_y_offset)!=null?ze:5,_.appendChild(K);let bt=((Be=u==null?void 0:u.gameplay)==null?void 0:Be.tuning)||{},Rn=(Pe=bt.hand_offset_x)!=null?Pe:50,Fn=(Ye=bt.hand_offset_y)!=null?Ye:50,Mn=(Ge=(Ne=u==null?void 0:u.transform)==null?void 0:Ne.scale)!=null?Ge:.1875,An=(Xe=bt.hand_scale_multiplier)!=null?Xe:2.5,$n=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite($n),Dt=Mn*An*100;return et.scale.set(Dt,Dt,1),et.position.set(Rn,ft+Fn,0),et.material.opacity=0,et.visible=!1,{panel:T,logo:C,title:Ht,subtitle:ht,footer:yt,ctaButton:Mt,ctaText:$t,ctaHint:gt,hand:et}}function Pn(e,t,n){var S,H,_,T,R,k,M,D;let s=t.objects.get("ui_endgame_1"),a=((S=s==null?void 0:s.gameplay)==null?void 0:S.tuning)||{},i=(H=a.animation_duration_ms)!=null?H:800,o=(_=a.fade_in_duration_ms)!=null?_:600,p=(T=a.scale_animation_intensity)!=null?T:.1,r=(R=a.logo_animation_delay_ms)!=null?R:100,y=(k=a.title_animation_delay_ms)!=null?k:200,c=(M=a.footer_animation_delay_ms)!=null?M:300,u=(D=a.cta_animation_delay_ms)!=null?D:400,{panel:l,logo:m,title:b,subtitle:x,footer:d,ctaButton:g,ctaText:h,ctaHint:f}=e;l.visible=!0,l.element.style.visibility="visible";let E=Date.now(),w=()=>{let j=Date.now()-E,X=Math.min(j/o,1),G=1-Math.pow(1-X,3);l.alpha=G,l.element.style.opacity=G.toString();let C=1+p*(1-G);l.element.style.transform=`translate(-50%, -50%) scale(${C})`,X<1?requestAnimationFrame(w):(setTimeout(()=>Yn(m,i,t),r),setTimeout(()=>{Nn(b,i),setTimeout(()=>Gn(x,i),50)},y),setTimeout(()=>Xn(d,i),c),setTimeout(()=>{qn(g,h,i),setTimeout(()=>Vn(f,i),50),n&&n()},u))};w()}function Yn(e,t,n){var l,m,b,x,d;let s=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(m=(((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{}).animation_start_scale)!=null?m:1.2,o=Date.now(),p=e.material.opacity,r=(b=e.targetAlpha)!=null?b:1,y=(x=e.baseScaleX)!=null?x:e.scale.x,c=(d=e.baseScaleY)!=null?d:e.scale.y,u=()=>{let g=Date.now()-o,h=Math.min(g/t,1),f=1-Math.pow(1-h,2);e.material.opacity=p+(r-p)*f;let E=i+(1-i)*f;e.scale.set(y*E,c*E,1),h<1&&requestAnimationFrame(u)};u()}function Nn(e,t){let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=()=>{let o=Date.now()-n,p=Math.min(o/t,1),r=1-Math.pow(1-p,2);e.element.style.opacity=(s+(1-s)*r).toString(),e.element.style.top=`${a-20*(1-r)}px`,p<1&&requestAnimationFrame(i)};i()}function Gn(e,t){var p;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((p=e.animationStartYOffset)!=null?p:-10),o=()=>{let r=Date.now()-n,y=Math.min(r/t,1),c=1-Math.pow(1-y,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a+(i-a)*c}px`,y<1&&requestAnimationFrame(o)};o()}function Xn(e,t){var o;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=(o=e.targetAlpha)!=null?o:1,i=()=>{let p=Date.now()-n,r=Math.min(p/t,1),y=1-Math.pow(1-r,2);e.element.style.opacity=(s+(a-s)*y).toString(),r<1&&requestAnimationFrame(i)};i()}function qn(e,t,n){let s=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=()=>{let o=Date.now()-s,p=Math.min(o/n,1),r=1-Math.pow(1-p,2);e.element.style.opacity=(a+(1-a)*r).toString(),t.element.style.opacity=(a+(1-a)*r).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-r)})`,p<1&&requestAnimationFrame(i)};i()}function Vn(e,t){var p;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((p=e.animationStartYOffset)!=null?p:5),o=()=>{let r=Date.now()-n,y=Math.min(r/t,1),c=1-Math.pow(1-y,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a+(i-a)*c}px`,y<1&&requestAnimationFrame(o)};o()}function Zn(e,t,n,s){var c,u,l,m;let a=n.objects.get("ui_endgame_hand_1"),i=((c=a==null?void 0:a.gameplay)==null?void 0:c.tuning)||{},o=(u=i.click_animation_duration_ms)!=null?u:600,p=(l=i.click_delay_ms)!=null?l:2e3,r=(m=i.click_repeat_delay_ms)!=null?m:3e3,y=()=>{var H,_;e.visible=!0,e.material.opacity=1;let b=e.position.x,x=e.position.y,d=(H=i.hand_offset_x)!=null?H:50,g=(_=i.hand_offset_y)!=null?_:50,h=t.element.getBoundingClientRect(),f=d,E=g,w=Date.now(),S=()=>{var G,C,q;let T=Date.now()-w,R=Math.min(T/o,1),k=R<.5?2*R*R:1-Math.pow(-2*R+2,2)/2;e.position.set(b+(f-b)*k,x+(E-x)*k,0);let M=(C=(G=a==null?void 0:a.transform)==null?void 0:G.scale)!=null?C:.1875,D=(q=i.hand_scale_multiplier)!=null?q:2.5,j=M*D*100,X=j+j*.2*Math.sin(R*Math.PI);e.scale.set(X,X,1),R<1?requestAnimationFrame(S):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",s()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(b,x,0),y()},r)},500))};S()};setTimeout(y,p)}import*as ut from"three";function Jn(e,t,n){var u,l,m,b;let s=t.objects.get("hand_tutorial_1"),a=((u=s==null?void 0:s.gameplay)==null?void 0:u.tuning)||{},i=(s==null?void 0:s.render)||{},o=(s==null?void 0:s.transform)||{},p=new ut.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),r=new ut.Sprite(p);r.position.set(n.x,n.y,0),r.material.opacity=0;let y=(l=a.hand_scale_multiplier)!=null?l:2.5,c=(m=o.scale)!=null?m:.1875;return r.scale.set(c*y*100,c*y*100,1),r.renderOrder=(b=i.z_index)!=null?b:99999,r}function Kn(e){var b,x,d,g,h,f,E,w,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,s=(t==null?void 0:t.render)||{},a=((b=e.engine.runtime)==null?void 0:b.ui_styles)||{},i=((x=e.engine.runtime)==null?void 0:x.ui)||{},o=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",p=(n==null?void 0:n.font)||"brand.warning",r=(n==null?void 0:n.fontSize)||a.label_font_size||52,y=(g=n==null?void 0:n.letterSpacing)!=null?g:(d=a.label_letter_spacing)!=null?d:-1,c=(n==null?void 0:n.align)||"center",u=s.tint,l=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",m=document.createElement("div");return m.textContent=o,m.style.cssText=`
|
|
105
|
+
font-family: ${Y(p)};
|
|
106
|
+
font-size: ${r}px;
|
|
107
|
+
font-weight: ${N(p)};
|
|
108
|
+
color: ${l};
|
|
109
|
+
text-align: ${c};
|
|
110
|
+
letter-spacing: ${y}px;
|
|
111
|
+
text-shadow: ${(h=a.label_shadow_distance)!=null?h:2}px ${(f=a.label_shadow_distance)!=null?f:2}px ${(E=a.label_shadow_blur)!=null?E:4}px rgba(0,0,0,${(w=a.label_shadow_alpha)!=null?w:.8});
|
|
86
112
|
-webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
|
|
87
|
-
opacity: ${(S=
|
|
88
|
-
visibility: ${
|
|
113
|
+
opacity: ${(S=s.alpha)!=null?S:0};
|
|
114
|
+
visibility: ${s.visible!==!1?"visible":"hidden"};
|
|
89
115
|
pointer-events: none;
|
|
90
116
|
position: absolute;
|
|
91
117
|
transform: translate(-50%, -50%);
|
|
92
118
|
white-space: nowrap;
|
|
93
|
-
`,
|
|
119
|
+
`,m}function Qn(e,t,n,s,a){var r,y,c,u,l,m,b;let i=a.objects.get("hand_tutorial_1"),o=((r=i==null?void 0:i.gameplay)==null?void 0:r.tuning)||{},p=(i==null?void 0:i.transform)||{};if(!s){let x=(y=o.animation_duration)!=null?y:1.5,d=n%x/x,g=d<.5?2*d*d:-1+(4-2*d)*d,h=(c=o.x_offset)!=null?c:0,f=(u=o.y_offset)!=null?u:0,E=(l=o.animation_range)!=null?l:40,w=E*.7,S=E,H=t.x+h+w,_=t.y+f+S,T=H+w,R=_+S;e.position.set(H+(T-H)*g,_+(R-_)*g,0);let k=(m=p.scale)!=null?m:.1875,M=(b=o.hand_scale_multiplier)!=null?b:2.5,D=k*M*100;e.scale.set(D,D,1)}}import*as tt from"three";var Ve=new tt.TextureLoader;async function Ze(e,t,n=16777215,s=!1){try{let i=(globalThis.INLINE_ASSETS||{})[e];return await Ve.loadAsync(i||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=document.createElement("canvas");i.width=64,i.height=64;let o=i.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,s?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new tt.CanvasTexture(i)}}async function jn(e,t,n){var b,x,d,g;let a=(globalThis.INLINE_ASSETS||{})[e]||e,i;try{i=await Ve.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(h){let w=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");i=await Ze(e,t,parseInt(w,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:h})}if(!i)return[];let o=n.gameplay.character_sheet||{},p=(b=o.cols)!=null?b:3,r=(x=o.rows)!=null?x:2,y=((d=i.image)==null?void 0:d.width)||0,c=((g=i.image)==null?void 0:g.height)||0,u=y/p,l=c/r;if(!Number.isFinite(u)||!Number.isFinite(l)||u<=0||l<=0)return[i];let m=[];for(let h=0;h<r;h++)for(let f=0;f<p;f++){let E=document.createElement("canvas");E.width=u,E.height=l;let w=E.getContext("2d");w&&i.image&&w.drawImage(i.image,f*u,h*l,u,l,0,0,u,l),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 On(e,t){var u,l,m,b;let n=t.gameplay.brush||{},s=t.theme.brush_color||"#ffffff",a=(u=n.radius)!=null?u:20,i=(l=n.inner_radius)!=null?l:15,o=(m=n.alpha)!=null?m:.8,p=(b=n.inner_alpha)!=null?b:.3,r=n.inner_color||"#ffffff",y=document.createElement("canvas");y.width=a*2,y.height=a*2;let c=y.getContext("2d");return c&&(c.clearRect(0,0,y.width,y.height),c.beginPath(),c.arc(a,a,a,0,Math.PI*2),c.fillStyle=s,c.globalAlpha=o,c.fill(),c.beginPath(),c.arc(a,a,i,0,Math.PI*2),c.fillStyle=r,c.globalAlpha=p,c.fill()),new tt.CanvasTexture(y)}export{qe as AspectClass,mt as GameObject,_t as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ct as Transform,Zn as animateHandClick,Pn as animatePanelEntrance,On as createBrushTexture,Bn as createEndGamePanel,Jn as createHandTutorial,Dn as createThreeBase,Kn as createTutorialLabel,Et as getAspectClass,zn as getRegisteredFontIds,Ze as loadAsset,jn as loadCharacterFrames,kn as registerFont,Y as resolveFont,N as resolveFontWeight,Qn as updateHandAnimation};
|
package/package.json
CHANGED
package/dist/chunk-5XZYWKIQ.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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.8",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
|
-
(function(){
|
|
3
|
-
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
|
-
function unlock(){
|
|
5
|
-
if(window.AudioContext && AudioContext.prototype.resume){
|
|
6
|
-
if(!window.__handler_audio_ctx){
|
|
7
|
-
window.__handler_audio_ctx = new AudioContext();
|
|
8
|
-
}
|
|
9
|
-
if(window.__handler_audio_ctx.state === 'suspended'){
|
|
10
|
-
window.__handler_audio_ctx.resume();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
events.forEach(function(e){ document.removeEventListener(e, unlock); });
|
|
14
|
-
}
|
|
15
|
-
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
16
|
-
})();
|
|
17
|
-
`,e.appendChild(t)}export{f as a,Be as b};
|