@mblinkov/whats-missing 20.0.35 → 20.0.37
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/whats-missing.cjs.js +3 -3
- package/dist/whats-missing.es.js +198 -197
- package/package.json +1 -1
- package/src/Game.tsx +42 -23
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("react"),he=window.origin+"/cloud/speakid/games/whatsmissing/",Y=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("react"),he=window.origin+"/cloud/speakid/games/whatsmissing/",Y=(l,m)=>l.map(([r,i])=>({src:`${he}${m}/${i.replace(/\s/g,"%20")}.png`,name:i})),fe=[["apple","apple"],["banana","banana"],["bread","bread"],["burger","burger"],["cake","cake"],["carrot","carrot"],["cheese","cheese"],["chicken","chicken"],["chocolate","chocolate"],["corn","corn"],["donut","donut"],["fish","fish"],["fries","fries"],["grapes","grapes"],["ice_cream","ice cream"],["milk","milk"],["orange","orange"],["pear","pear"],["pizza","pizza"],["rice","rice"],["sandwich","sandwich"],["soup","soup"],["strawberry","strawberry"],["tomato","tomato"],["watermelon","watermelon"]],pe=[["bear","bear"],["cat","cat"],["crocodile","crocodile"],["dolphin","dolphin"],["elephant","elephant"],["fox","fox"],["giraffe","giraffe"],["horse","horse"],["kangaroo","kangaroo"],["lion","lion"],["monkey","monkey"],["owl","owl"],["panda","panda"],["penguin","penguin"],["squirrel","squirrel"],["tiger","tiger"],["tortoise","tortoise"],["wolf","wolf"],["zebra","zebra"]],ye=[["ball","ball"],["balloon","balloon"],["blocks","blocks"],["car","car"],["doll","doll"],["drum","drum"],["guitar","guitar"],["jump_rope","jump rope"],["kite","kite"],["paints","paints"],["plane","plane"],["puzzle","puzzle"],["rocket","rocket"],["scooter","scooter"],["skateboard","skateboard"],["slide","slide"],["teddy_bear","teddy bear"],["yo-yo","yo-yo"],["crayons","crayons"]],P={food:Y(fe,"food"),animals:Y(pe,"animals"),toys:Y(ye,"toys")},xe=`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const
|
|
6
|
+
`;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const l=document.createElement("style");l.id="spin-keyframes",l.innerHTML=xe,document.head.appendChild(l)}const be={animation:"spin 1.4s linear infinite"},o={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center",color:"#1f2937",padding:"24px 16px",boxSizing:"border-box",transform:"translateY(20px)"},gmHeadline1:{fontWeight:700,fontSize:"clamp(28px, 4vw, 40px)",lineHeight:"110%"},gmHeadline3:{fontWeight:600,fontSize:"18px",lineHeight:"130%"},gmBodyM:{fontWeight:400,fontSize:"16px",lineHeight:"140%"},gmBodyS:{fontWeight:400,fontSize:"14px",lineHeight:"140%",color:"#6b7280"},gmButton:{fontFamily:'"Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans"',fontWeight:600,fontSize:"16px",padding:"10px 16px",borderRadius:"12px",border:"1px solid #e5e7eb",background:"#ec4c44",color:"#ffffff",cursor:"pointer",boxShadow:"0 6px 18px rgba(236, 76, 68, .18)",transition:"transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease"},gmButtonActive:{background:"#333",color:"#fff"},gmGameLayout:{position:"relative",width:"100%",maxWidth:"none",minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmGrid:{width:"100%",maxWidth:"none",margin:"0 auto",display:"grid",gridTemplateColumns:"repeat(3, 210px)",gridAutoRows:"210px",gap:"20px",justifyContent:"center"},gmCard:{border:"1px solid #e5e7eb",borderRadius:"16px",background:"#f9f9f9",aspectRatio:"1 / 1",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"transform .2s ease, box-shadow .2s ease, border-color .2s ease"},gmCorrect:{border:"2px solid #10b981",boxShadow:"0 0 18px rgba(16,185,129,.45)",background:"#ecfdf5"},gmWrong:{border:"2px solid #ec4c44",boxShadow:"0 0 18px rgba(236,76,68,.35)",background:"#fef2f2"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmTable:{marginTop:"20px",marginBottom:"32px",borderCollapse:"collapse",width:"100%",maxWidth:"520px",tableLayout:"fixed",textAlign:"center"},gmTableCell:{padding:"8px 12px",borderBottom:"1px solid #e5e7eb",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},gmLogoFixed:{position:"absolute",top:"16px",left:"24px",width:"120px",zIndex:10,pointerEvents:"none",background:"transparent",transform:"none",willChange:"auto"},gmLogoImg:{height:"clamp(28px, 5vw, 40px)",width:"auto",background:"transparent",objectFit:"contain",imageRendering:"auto",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased"},gmHourglass:{fontSize:"42px",...be}},we=()=>{const l=document.createElement("style");l.textContent=`
|
|
7
7
|
#whats-missing-root, #whats-missing-root * { box-sizing: border-box; }
|
|
8
8
|
#whats-missing-root img { max-width:100%; height:auto; display:block; user-select:none; }
|
|
9
|
-
`,document.head.appendChild(r)},je=(r,a)=>{const l=Array.from({length:r.length+1},()=>Array(a.length+1).fill(0));for(let i=0;i<=r.length;i++)l[i][0]=i;for(let i=0;i<=a.length;i++)l[0][i]=i;for(let i=1;i<=r.length;i++)for(let m=1;m<=a.length;m++)l[i][m]=r[i-1]===a[m-1]?l[i-1][m-1]:Math.min(l[i-1][m-1],l[i][m-1],l[i-1][m])+1;return l[r.length][a.length]};function Se(r,a={minDesktopWidth:1200,forceResize:!1}){const l=s.useRef(null),i=a.minDesktopWidth??1200,m=!!a.forceResize;s.useLayoutEffect(()=>{if(typeof window>"u"||!r||!r.current)return;const c=r.current,T=()=>{try{const d=document.body,j=getComputedStyle(d),b=parseFloat(d.style&&d.style.zoom||"");if(b&&!isNaN(b)&&b>0)return b;const S=parseFloat(j.zoom||"");if(S&&!isNaN(S)&&S>0)return S;const g=document.createElement("div");g.style.position="absolute",g.style.left="0",g.style.top="0",g.style.width="100px",g.style.height="1px",g.style.visibility="hidden",document.documentElement.appendChild(g);const C=g.getBoundingClientRect();if(document.documentElement.removeChild(g),C&&C.width>0){const p=C.width/100;if(!isNaN(p)&&p>0)return p}}catch{}return 1},I=()=>{if(i&&window.innerWidth<i){y();return}const d=T();if(!d||d===1){y();return}l.current||(l.current={transform:c.style.transform||null,transformOrigin:c.style.transformOrigin||null,width:c.style.width||null,height:c.style.height||null,willChange:c.style.willChange||null});const j=1/d;m&&(c.style.width=`${d*100}%`,c.style.height=`${d*100}%`),c.style.transformOrigin="50% 50%",c.style.transform=`scale(${j})`,c.style.willChange="transform"},y=()=>{if(!l.current)return;const d=l.current;c.style.transform=d.transform??"",c.style.transformOrigin=d.transformOrigin??"",c.style.width=d.width??"",c.style.height=d.height??"",c.style.willChange=d.willChange??"",l.current=null};let z=0;const x=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(I)},R=new MutationObserver(d=>{for(const j of d)if(j.type==="attributes"&&(j.attributeName==="style"||j.attributeName==="class")){x();break}});return R.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("resize",x),x(),()=>{cancelAnimationFrame(z),R.disconnect(),window.removeEventListener("resize",x),y()}},[r,i,m])}function ve({gameCubeSize:r,screenHeight:a,screenWidth:l}){const i=s.useRef(null),m=s.useRef(null),[c,T]=s.useState(null);Se(i,{minDesktopWidth:1024,forceResize:!1});const I=s.useMemo(()=>{const e=r??Math.min(l??1e3,a??1e3),o=l??(typeof window<"u"?window.innerWidth:1e3);return e<600&&o>768?600:o<=768?Math.min(e,o-20):e},[r,l,a]);s.useEffect(()=>(we(),()=>{document.body.style.overflow=""}),[]);const[y,z]=s.useState(null),[x,R]=s.useState([]),[d,j]=s.useState(4),[b,S]=s.useState(!1),[g,C]=s.useState(1),[p,ie]=s.useState(null),[w,H]=s.useState("ready"),[P,U]=s.useState(3),[L,A]=s.useState(10),[W,V]=s.useState(20),[re,F]=s.useState(0),[B,G]=s.useState(!1),[E,_]=s.useState(""),[k,$]=s.useState(!1),[N,K]=s.useState(!1),[J,M]=s.useState(null),[le,O]=s.useState([]),[ae,Q]=s.useState([]),[h,de]=s.useState(!1);s.useEffect(()=>{if(typeof window>"u")return;const e=()=>{const o=l??window.innerWidth,u=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches;de(o<=768||u)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[l]),s.useLayoutEffect(()=>{const e=m.current;if(!e||typeof window>"u")return;let o=null;try{o=new ResizeObserver(u=>{for(const f of u){const v=f.contentRect;T(Math.round(Math.min(v.width,v.height)))}}),o.observe(e),T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}catch{T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}return()=>o?.disconnect()},[h]);const X=e=>[...e].sort(()=>Math.random()-.5).slice(0,6),ee=()=>{if(!y)return;const e=X(Z[y]);R(e),S(!0),G(!1),C(1),F(0),O([]),Q([]),te(e,[],!0)},te=(e=x,o=ae,u=!1)=>{const f=X(e.length?e:Z[y]);let v=Math.floor(Math.random()*f.length),q=f[v].name,se=0;for(;o.includes(q)&&se<20;)v=Math.floor(Math.random()*f.length),q=f[v].name,se++;R(f),ie(v),Q([...o,q]),$(!1),_(""),V(20),M(null),u?(H("ready"),U(3),A(10)):(H("memorize"),A(10))};s.useEffect(()=>{if(!(!b||B||k)){if(w==="ready")if(P<=0)H("memorize");else{const e=setTimeout(()=>U(o=>o-1),1e3);return()=>clearTimeout(e)}if(w==="memorize")if(L<=0)H("guess");else{const e=setTimeout(()=>A(o=>o-1),1e3);return()=>clearTimeout(e)}if(w==="guess"){if(W<=0){$(!0),M("wrong");const o=x[p].name;O(u=>[...u,{round:g,answer:E,correct:o,result:"wrong"}]);return}const e=setTimeout(()=>V(o=>o-1),1e3);return()=>clearTimeout(e)}}},[w,P,L,W,b,B,k,x,p,g,E]);const ce=()=>{if(p===null||N)return;const e=x[p].name,o=E.toLowerCase().trim();let u="wrong";o===e?(F(f=>f+1),M("correct"),u="correct"):je(o,e)===1?(F(f=>f+.5),M("almost"),u="almost"):(M("wrong"),u="wrong"),O(f=>[...f,{round:g,answer:o,correct:e,result:u}]),K(!0),setTimeout(()=>{K(!1),$(!0)},600)},me=()=>g<d?(C(e=>e+1),te()):G(!0),ue=()=>{S(!1),G(!1),z(null)},ge=s.useMemo(()=>t.jsx("div",{style:{...n.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:t.jsxs("picture",{children:[t.jsx("source",{srcSet:window.origin+"/cloud/speakid/games/whatsmissing/logo.svg",type:"image/svg+xml"}),t.jsx("img",{src:window.origin+"/cloud/speakid/games/whatsmissing/logo.png",alt:"SPEAKID Logo",style:n.gmLogoImg,loading:"lazy"})]})}),[]),ne=1200,oe=700,D=s.useMemo(()=>{const e=l??(typeof window<"u"?window.innerWidth:ne),o=a??(typeof window<"u"?window.innerHeight:oe),u=Math.min(e/ne,o/oe);return Math.min(1.35,Math.max(1,u))},[l,a,h]);return t.jsx("div",{ref:i,style:{position:"fixed",inset:0,display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",overflow:"hidden",zIndex:1,width:"100vw",height:"100vh",transform:"none",zoom:1,scale:"1 !important"},children:t.jsx("div",{ref:m,style:{width:h?"100%":`${I}px`,height:h?"100%":`${I}px`,borderRadius:h?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",position:"relative",overflow:"hidden",boxShadow:h?"none":"0 0 40px rgba(0,0,0,0.08)",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsxs("div",{id:"whats-missing-root",style:{transform:`scale(${D})`,transformOrigin:"center center",transition:"transform 0.2s ease-out",width:`${100/D}%`,height:`${100/D}%`,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[!h&&ge,!y&&!b&&t.jsxs("div",{style:n.gmCenterScreen,children:[t.jsx("h1",{style:n.gmHeadline1,children:"WHAT'S MISSING?"}),t.jsx("p",{style:n.gmBodyM,children:"Select a theme:"}),t.jsx("div",{style:{display:"flex",gap:16},children:["animals","food","toys"].map(e=>t.jsx("button",{style:n.gmButton,onClick:()=>z(e),children:e==="animals"?"🐶 Animals":e==="food"?"🍎 Food":"🧸 Toys"},e))}),t.jsxs("div",{style:{marginTop:24},children:[t.jsx("p",{style:n.gmBodyS,children:"Choose number of rounds:"}),t.jsx("div",{style:{display:"flex",gap:12,marginTop:8},children:[3,4,5].map(e=>t.jsx("button",{style:{...n.gmButton,...d===e?n.gmButtonActive:{}},onClick:()=>j(e),children:e},e))})]})]}),y&&!b&&t.jsxs("div",{style:n.gmCenterScreen,children:[t.jsxs("h1",{style:n.gmHeadline1,children:["Theme selected: ",y]}),t.jsxs("p",{style:n.gmBodyM,children:["Rounds: ",d]}),t.jsx("button",{style:n.gmButton,onClick:ee,children:"▶ Start game"})]}),B&&t.jsxs("div",{style:n.gmCenterScreen,children:[t.jsx("h1",{style:n.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:n.gmHeadline3,children:["Your score: ",re," / ",d]}),t.jsx("p",{style:{...n.gmBodyM,color:"#10b981",marginTop:12},children:"Yahoo! You did it! 🍬✨"}),t.jsxs("table",{style:n.gmTable,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Round"}),t.jsx("th",{children:"Your Answer"}),t.jsx("th",{children:"Correct"}),t.jsx("th",{children:"Result"})]})}),t.jsx("tbody",{children:le.map((e,o)=>t.jsxs("tr",{children:[t.jsx("td",{style:n.gmTableCell,children:e.round}),t.jsx("td",{style:n.gmTableCell,children:e.answer||"—"}),t.jsx("td",{style:n.gmTableCell,children:e.correct}),t.jsx("td",{style:n.gmTableCell,children:e.result==="correct"?"✔ Correct":e.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},o))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:n.gmButton,onClick:ee,children:"🔁 Play again"}),t.jsx("button",{style:n.gmButton,onClick:ue,children:"⬅️ Choose theme"})]})]}),b&&!B&&t.jsxs("div",{style:n.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[w==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...n.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:n.gmHourglass,children:"⏳"})]}),w==="memorize"&&t.jsxs("p",{style:{...n.gmBodyM,color:"#10b981"},children:["MEMORIZE (",L,")"]}),w==="guess"&&!k&&t.jsxs("p",{style:n.gmBodyM,children:["⏳ Time left: ",W,"s"]})]}),w!=="ready"&&t.jsx("div",{style:{...n.gmGrid,display:"grid",gridTemplateColumns:`repeat(${h?2:3}, 1fr)`,gridTemplateRows:`repeat(${h?3:2}, 1fr)`,gap:h?12:20,justifyContent:"center",alignContent:"center",padding:h?8:16,width:"100%",height:"100%",maxWidth:h?"100%":600,maxHeight:h?"100%":400,boxSizing:"border-box"},children:x.map((e,o)=>{const u=p===o&&w==="guess"&&!k;return t.jsx("div",{style:{...n.gmCard,width:"100%",height:"100%",...J==="correct"&&p===o?n.gmCorrect:{},...J==="wrong"&&p===o?n.gmWrong:{}},children:!u&&t.jsx("img",{src:e.src,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},o)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[w==="guess"&&!k&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:E,onChange:e=>_(e.target.value),style:n.gmInput}),t.jsx("button",{style:{...n.gmButton,marginLeft:8},onClick:ce,disabled:N,children:N?"...":"Check"})]}),k&&t.jsx("button",{type:"button",style:n.gmButton,onClick:me,children:"Next round"})]})]})]})})})}exports.Game=ve;exports.themes=Z;
|
|
9
|
+
`,document.head.appendChild(l)},je=(l,m)=>{const r=Array.from({length:l.length+1},()=>Array(m.length+1).fill(0));for(let i=0;i<=l.length;i++)r[i][0]=i;for(let i=0;i<=m.length;i++)r[0][i]=i;for(let i=1;i<=l.length;i++)for(let g=1;g<=m.length;g++)r[i][g]=l[i-1]===m[g-1]?r[i-1][g-1]:Math.min(r[i-1][g-1],r[i][g-1],r[i-1][g])+1;return r[l.length][m.length]};function ve(l,m={minDesktopWidth:1200,forceResize:!1}){const r=s.useRef(null),i=m.minDesktopWidth??1200,g=!!m.forceResize;s.useLayoutEffect(()=>{if(typeof window>"u"||!l||!l.current)return;const c=l.current,T=()=>{try{const a=document.body,j=getComputedStyle(a),b=parseFloat(a.style&&a.style.zoom||"");if(b&&!isNaN(b)&&b>0)return b;const S=parseFloat(j.zoom||"");if(S&&!isNaN(S)&&S>0)return S;const h=document.createElement("div");h.style.position="absolute",h.style.left="0",h.style.top="0",h.style.width="100px",h.style.height="1px",h.style.visibility="hidden",document.documentElement.appendChild(h);const C=h.getBoundingClientRect();if(document.documentElement.removeChild(h),C&&C.width>0){const p=C.width/100;if(!isNaN(p)&&p>0)return p}}catch{}return 1},H=()=>{if(i&&window.innerWidth<i){y();return}const a=T();if(!a||a===1){y();return}r.current||(r.current={transform:c.style.transform||null,transformOrigin:c.style.transformOrigin||null,width:c.style.width||null,height:c.style.height||null,willChange:c.style.willChange||null});const j=1/a;g&&(c.style.width=`${a*100}%`,c.style.height=`${a*100}%`),c.style.transformOrigin="50% 50%",c.style.transform=`scale(${j})`,c.style.willChange="transform"},y=()=>{if(!r.current)return;const a=r.current;c.style.transform=a.transform??"",c.style.transformOrigin=a.transformOrigin??"",c.style.width=a.width??"",c.style.height=a.height??"",c.style.willChange=a.willChange??"",r.current=null};let z=0;const x=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(H)},R=new MutationObserver(a=>{for(const j of a)if(j.type==="attributes"&&(j.attributeName==="style"||j.attributeName==="class")){x();break}});return R.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("resize",x),x(),()=>{cancelAnimationFrame(z),R.disconnect(),window.removeEventListener("resize",x),y()}},[l,i,g])}function Se({gameCubeSize:l,screenHeight:m,screenWidth:r}){const i=s.useRef(null),g=s.useRef(null),[c,T]=s.useState(null);ve(i,{minDesktopWidth:1024,forceResize:!1}),s.useLayoutEffect(()=>{const e=i.current;e&&(e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.zIndex="100",e.style.background="linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",e.style.overflow="hidden",e.style.transform="none",e.style.zoom="1",e.style.margin="0",e.style.padding="0")},[]),s.useEffect(()=>{const e=document.body,n=document.documentElement,d=e.style.zoom,u=e.style.transform,v=n.style.zoom,I=n.style.transform;return e.style.zoom="1",e.style.transform="none",n.style.zoom="1",n.style.transform="none",()=>{e.style.zoom=d,e.style.transform=u,n.style.zoom=v,n.style.transform=I}},[]);const H=s.useMemo(()=>{const e=l??Math.min(r??1e3,m??1e3),n=r??(typeof window<"u"?window.innerWidth:1e3);return e<600&&n>768?600:n<=768?Math.min(e,n-20):e},[l,r,m]);s.useEffect(()=>(we(),()=>{document.body.style.overflow=""}),[]);const[y,z]=s.useState(null),[x,R]=s.useState([]),[a,j]=s.useState(4),[b,S]=s.useState(!1),[h,C]=s.useState(1),[p,ie]=s.useState(null),[w,B]=s.useState("ready"),[Z,U]=s.useState(3),[A,W]=s.useState(10),[F,V]=s.useState(20),[re,G]=s.useState(0),[E,$]=s.useState(!1),[L,_]=s.useState(""),[k,N]=s.useState(!1),[O,K]=s.useState(!1),[J,M]=s.useState(null),[le,D]=s.useState([]),[ae,Q]=s.useState([]),[f,de]=s.useState(!1);s.useEffect(()=>{if(typeof window>"u")return;const e=()=>{const n=r??window.innerWidth,d=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches;de(n<=768||d)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[r]),s.useLayoutEffect(()=>{const e=g.current;if(!e||typeof window>"u")return;let n=null;try{n=new ResizeObserver(d=>{for(const u of d){const v=u.contentRect;T(Math.round(Math.min(v.width,v.height)))}}),n.observe(e),T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}catch{T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}return()=>n?.disconnect()},[f]);const X=e=>[...e].sort(()=>Math.random()-.5).slice(0,6),ee=()=>{if(!y)return;const e=X(P[y]);R(e),S(!0),$(!1),C(1),G(0),D([]),Q([]),te(e,[],!0)},te=(e=x,n=ae,d=!1)=>{const u=X(e.length?e:P[y]);let v=Math.floor(Math.random()*u.length),I=u[v].name,se=0;for(;n.includes(I)&&se<20;)v=Math.floor(Math.random()*u.length),I=u[v].name,se++;R(u),ie(v),Q([...n,I]),N(!1),_(""),V(20),M(null),d?(B("ready"),U(3),W(10)):(B("memorize"),W(10))};s.useEffect(()=>{if(!(!b||E||k)){if(w==="ready")if(Z<=0)B("memorize");else{const e=setTimeout(()=>U(n=>n-1),1e3);return()=>clearTimeout(e)}if(w==="memorize")if(A<=0)B("guess");else{const e=setTimeout(()=>W(n=>n-1),1e3);return()=>clearTimeout(e)}if(w==="guess"){if(F<=0){N(!0),M("wrong");const n=x[p].name;D(d=>[...d,{round:h,answer:L,correct:n,result:"wrong"}]);return}const e=setTimeout(()=>V(n=>n-1),1e3);return()=>clearTimeout(e)}}},[w,Z,A,F,b,E,k,x,p,h,L]);const ce=()=>{if(p===null||O)return;const e=x[p].name,n=L.toLowerCase().trim();let d="wrong";n===e?(G(u=>u+1),M("correct"),d="correct"):je(n,e)===1?(G(u=>u+.5),M("almost"),d="almost"):(M("wrong"),d="wrong"),D(u=>[...u,{round:h,answer:n,correct:e,result:d}]),K(!0),setTimeout(()=>{K(!1),N(!0)},600)},me=()=>h<a?(C(e=>e+1),te()):$(!0),ue=()=>{S(!1),$(!1),z(null)},ge=s.useMemo(()=>t.jsx("div",{style:{...o.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:t.jsxs("picture",{children:[t.jsx("source",{srcSet:window.origin+"/cloud/speakid/games/whatsmissing/logo.svg",type:"image/svg+xml"}),t.jsx("img",{src:window.origin+"/cloud/speakid/games/whatsmissing/logo.png",alt:"SPEAKID Logo",style:o.gmLogoImg,loading:"lazy"})]})}),[]),ne=1200,oe=700,q=s.useMemo(()=>{const e=r??(typeof window<"u"?window.innerWidth:ne),n=m??(typeof window<"u"?window.innerHeight:oe),d=Math.min(e/ne,n/oe);return Math.min(1.35,Math.max(1,d))},[r,m,f]);return t.jsx("div",{ref:i,style:{position:"fixed",inset:0,display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",overflow:"hidden",zIndex:1,width:"100vw",height:"100vh",transform:"none",zoom:1,scale:"1 !important"},children:t.jsx("div",{ref:g,style:{width:f?"100%":`${H}px`,height:f?"100%":`${H}px`,borderRadius:f?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",position:"relative",overflow:"hidden",boxShadow:f?"none":"0 0 40px rgba(0,0,0,0.08)",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsxs("div",{id:"whats-missing-root",style:{transform:`scale(${q})`,transformOrigin:"center center",transition:"transform 0.2s ease-out",width:`${100/q}%`,height:`${100/q}%`,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[!f&&ge,!y&&!b&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"WHAT'S MISSING?"}),t.jsx("p",{style:o.gmBodyM,children:"Select a theme:"}),t.jsx("div",{style:{display:"flex",gap:16},children:["animals","food","toys"].map(e=>t.jsx("button",{style:o.gmButton,onClick:()=>z(e),children:e==="animals"?"🐶 Animals":e==="food"?"🍎 Food":"🧸 Toys"},e))}),t.jsxs("div",{style:{marginTop:24},children:[t.jsx("p",{style:o.gmBodyS,children:"Choose number of rounds:"}),t.jsx("div",{style:{display:"flex",gap:12,marginTop:8},children:[3,4,5].map(e=>t.jsx("button",{style:{...o.gmButton,...a===e?o.gmButtonActive:{}},onClick:()=>j(e),children:e},e))})]})]}),y&&!b&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsxs("h1",{style:o.gmHeadline1,children:["Theme selected: ",y]}),t.jsxs("p",{style:o.gmBodyM,children:["Rounds: ",a]}),t.jsx("button",{style:o.gmButton,onClick:ee,children:"▶ Start game"})]}),E&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",re," / ",a]}),t.jsx("p",{style:{...o.gmBodyM,color:"#10b981",marginTop:12},children:"Yahoo! You did it! 🍬✨"}),t.jsxs("table",{style:o.gmTable,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Round"}),t.jsx("th",{children:"Your Answer"}),t.jsx("th",{children:"Correct"}),t.jsx("th",{children:"Result"})]})}),t.jsx("tbody",{children:le.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:o.gmTableCell,children:e.round}),t.jsx("td",{style:o.gmTableCell,children:e.answer||"—"}),t.jsx("td",{style:o.gmTableCell,children:e.correct}),t.jsx("td",{style:o.gmTableCell,children:e.result==="correct"?"✔ Correct":e.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},n))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:o.gmButton,onClick:ee,children:"🔁 Play again"}),t.jsx("button",{style:o.gmButton,onClick:ue,children:"⬅️ Choose theme"})]})]}),b&&!E&&t.jsxs("div",{style:o.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[w==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),w==="memorize"&&t.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",A,")"]}),w==="guess"&&!k&&t.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",F,"s"]})]}),w!=="ready"&&t.jsx("div",{style:{...o.gmGrid,display:"grid",gridTemplateColumns:`repeat(${f?2:3}, 1fr)`,gridTemplateRows:`repeat(${f?3:2}, 1fr)`,gap:f?12:20,justifyContent:"center",alignContent:"center",padding:f?8:16,width:"100%",height:"100%",maxWidth:f?"100%":600,maxHeight:f?"100%":400,boxSizing:"border-box"},children:x.map((e,n)=>{const d=p===n&&w==="guess"&&!k;return t.jsx("div",{style:{...o.gmCard,width:"100%",height:"100%",...J==="correct"&&p===n?o.gmCorrect:{},...J==="wrong"&&p===n?o.gmWrong:{}},children:!d&&t.jsx("img",{src:e.src,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},n)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[w==="guess"&&!k&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:L,onChange:e=>_(e.target.value),style:o.gmInput}),t.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:ce,disabled:O,children:O?"...":"Check"})]}),k&&t.jsx("button",{type:"button",style:o.gmButton,onClick:me,children:"Next round"})]})]})]})})})}exports.Game=Se;exports.themes=P;
|
package/dist/whats-missing.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (
|
|
4
|
-
src: `${xe}${
|
|
1
|
+
import { jsx as o, jsxs as a, Fragment as be } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as V, useState as d, useLayoutEffect as _, useEffect as j, useMemo as P } from "react";
|
|
3
|
+
const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (s, u) => s.map(([r, i]) => ({
|
|
4
|
+
src: `${xe}${u}/${i.replace(/\s/g, "%20")}.png`,
|
|
5
5
|
name: i
|
|
6
6
|
})), ve = [
|
|
7
7
|
["apple", "apple"],
|
|
@@ -69,7 +69,7 @@ const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (r, l) => r
|
|
|
69
69
|
["teddy_bear", "teddy bear"],
|
|
70
70
|
["yo-yo", "yo-yo"],
|
|
71
71
|
["crayons", "crayons"]
|
|
72
|
-
],
|
|
72
|
+
], de = {
|
|
73
73
|
food: U(ve, "food"),
|
|
74
74
|
animals: U(ze, "animals"),
|
|
75
75
|
toys: U(Ce, "toys")
|
|
@@ -80,12 +80,12 @@ const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (r, l) => r
|
|
|
80
80
|
}
|
|
81
81
|
`;
|
|
82
82
|
if (typeof document < "u" && !document.getElementById("spin-keyframes")) {
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const s = document.createElement("style");
|
|
84
|
+
s.id = "spin-keyframes", s.innerHTML = ke, document.head.appendChild(s);
|
|
85
85
|
}
|
|
86
86
|
const Se = {
|
|
87
87
|
animation: "spin 1.4s linear infinite"
|
|
88
|
-
},
|
|
88
|
+
}, n = {
|
|
89
89
|
gmCenterScreen: {
|
|
90
90
|
position: "relative",
|
|
91
91
|
zIndex: 1,
|
|
@@ -241,77 +241,70 @@ const Se = {
|
|
|
241
241
|
fontSize: "42px",
|
|
242
242
|
...Se
|
|
243
243
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return r.style.zoom = "1", r.style.transform = "none", l.style.zoom = "1", l.style.transform = "none", console.log("Zoom and transform neutralized globally."), () => {
|
|
248
|
-
r.style.zoom = s, r.style.transform = i, l.style.zoom = u, l.style.transform = m;
|
|
249
|
-
};
|
|
250
|
-
}, []);
|
|
251
|
-
const Te = () => {
|
|
252
|
-
const r = document.createElement("style");
|
|
253
|
-
r.textContent = `
|
|
244
|
+
}, Te = () => {
|
|
245
|
+
const s = document.createElement("style");
|
|
246
|
+
s.textContent = `
|
|
254
247
|
#whats-missing-root, #whats-missing-root * { box-sizing: border-box; }
|
|
255
248
|
#whats-missing-root img { max-width:100%; height:auto; display:block; user-select:none; }
|
|
256
|
-
`, document.head.appendChild(
|
|
257
|
-
}, Re = (
|
|
258
|
-
const
|
|
259
|
-
for (let i = 0; i <=
|
|
260
|
-
for (let i = 0; i <=
|
|
261
|
-
for (let i = 1; i <=
|
|
262
|
-
for (let
|
|
263
|
-
|
|
264
|
-
return s
|
|
249
|
+
`, document.head.appendChild(s);
|
|
250
|
+
}, Re = (s, u) => {
|
|
251
|
+
const r = Array.from({ length: s.length + 1 }, () => Array(u.length + 1).fill(0));
|
|
252
|
+
for (let i = 0; i <= s.length; i++) r[i][0] = i;
|
|
253
|
+
for (let i = 0; i <= u.length; i++) r[0][i] = i;
|
|
254
|
+
for (let i = 1; i <= s.length; i++)
|
|
255
|
+
for (let h = 1; h <= u.length; h++)
|
|
256
|
+
r[i][h] = s[i - 1] === u[h - 1] ? r[i - 1][h - 1] : Math.min(r[i - 1][h - 1], r[i][h - 1], r[i - 1][h]) + 1;
|
|
257
|
+
return r[s.length][u.length];
|
|
265
258
|
};
|
|
266
|
-
function Me(
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
if (typeof window > "u" || !
|
|
270
|
-
const m =
|
|
259
|
+
function Me(s, u = { minDesktopWidth: 1200, forceResize: !1 }) {
|
|
260
|
+
const r = V(null), i = u.minDesktopWidth ?? 1200, h = !!u.forceResize;
|
|
261
|
+
_(() => {
|
|
262
|
+
if (typeof window > "u" || !s || !s.current) return;
|
|
263
|
+
const m = s.current, M = () => {
|
|
271
264
|
try {
|
|
272
|
-
const
|
|
265
|
+
const l = document.body, z = getComputedStyle(l), x = parseFloat(l.style && l.style.zoom || "");
|
|
273
266
|
if (x && !isNaN(x) && x > 0) return x;
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
const T =
|
|
279
|
-
if (document.documentElement.removeChild(
|
|
267
|
+
const k = parseFloat(z.zoom || "");
|
|
268
|
+
if (k && !isNaN(k) && k > 0) return k;
|
|
269
|
+
const f = document.createElement("div");
|
|
270
|
+
f.style.position = "absolute", f.style.left = "0", f.style.top = "0", f.style.width = "100px", f.style.height = "1px", f.style.visibility = "hidden", document.documentElement.appendChild(f);
|
|
271
|
+
const T = f.getBoundingClientRect();
|
|
272
|
+
if (document.documentElement.removeChild(f), T && T.width > 0) {
|
|
280
273
|
const y = T.width / 100;
|
|
281
274
|
if (!isNaN(y) && y > 0) return y;
|
|
282
275
|
}
|
|
283
276
|
} catch {
|
|
284
277
|
}
|
|
285
278
|
return 1;
|
|
286
|
-
},
|
|
279
|
+
}, L = () => {
|
|
287
280
|
if (i && window.innerWidth < i) {
|
|
288
281
|
w();
|
|
289
282
|
return;
|
|
290
283
|
}
|
|
291
|
-
const
|
|
292
|
-
if (!
|
|
284
|
+
const l = M();
|
|
285
|
+
if (!l || l === 1) {
|
|
293
286
|
w();
|
|
294
287
|
return;
|
|
295
288
|
}
|
|
296
|
-
|
|
289
|
+
r.current || (r.current = {
|
|
297
290
|
transform: m.style.transform || null,
|
|
298
291
|
transformOrigin: m.style.transformOrigin || null,
|
|
299
292
|
width: m.style.width || null,
|
|
300
293
|
height: m.style.height || null,
|
|
301
294
|
willChange: m.style.willChange || null
|
|
302
295
|
});
|
|
303
|
-
const z = 1 /
|
|
304
|
-
|
|
296
|
+
const z = 1 / l;
|
|
297
|
+
h && (m.style.width = `${l * 100}%`, m.style.height = `${l * 100}%`), m.style.transformOrigin = "50% 50%", m.style.transform = `scale(${z})`, m.style.willChange = "transform";
|
|
305
298
|
}, w = () => {
|
|
306
|
-
if (!
|
|
307
|
-
const
|
|
308
|
-
m.style.transform =
|
|
299
|
+
if (!r.current) return;
|
|
300
|
+
const l = r.current;
|
|
301
|
+
m.style.transform = l.transform ?? "", m.style.transformOrigin = l.transformOrigin ?? "", m.style.width = l.width ?? "", m.style.height = l.height ?? "", m.style.willChange = l.willChange ?? "", r.current = null;
|
|
309
302
|
};
|
|
310
303
|
let S = 0;
|
|
311
304
|
const b = () => {
|
|
312
|
-
cancelAnimationFrame(S), S = requestAnimationFrame(
|
|
313
|
-
}, I = new MutationObserver((
|
|
314
|
-
for (const z of
|
|
305
|
+
cancelAnimationFrame(S), S = requestAnimationFrame(L);
|
|
306
|
+
}, I = new MutationObserver((l) => {
|
|
307
|
+
for (const z of l)
|
|
315
308
|
if (z.type === "attributes" && (z.attributeName === "style" || z.attributeName === "class")) {
|
|
316
309
|
b();
|
|
317
310
|
break;
|
|
@@ -320,122 +313,130 @@ function Me(r, l = { minDesktopWidth: 1200, forceResize: !1 }) {
|
|
|
320
313
|
return I.observe(document.body, { attributes: !0, attributeFilter: ["style", "class"] }), window.addEventListener("resize", b), b(), () => {
|
|
321
314
|
cancelAnimationFrame(S), I.disconnect(), window.removeEventListener("resize", b), w();
|
|
322
315
|
};
|
|
323
|
-
}, [
|
|
316
|
+
}, [s, i, h]);
|
|
324
317
|
}
|
|
325
318
|
function Be({
|
|
326
|
-
gameCubeSize:
|
|
327
|
-
screenHeight:
|
|
328
|
-
screenWidth:
|
|
319
|
+
gameCubeSize: s,
|
|
320
|
+
screenHeight: u,
|
|
321
|
+
screenWidth: r
|
|
329
322
|
}) {
|
|
330
|
-
const i = V(null),
|
|
331
|
-
Me(i, { minDesktopWidth: 1024, forceResize: !1 })
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
323
|
+
const i = V(null), h = V(null), [m, M] = d(null);
|
|
324
|
+
Me(i, { minDesktopWidth: 1024, forceResize: !1 }), _(() => {
|
|
325
|
+
const e = i.current;
|
|
326
|
+
e && (e.style.position = "fixed", e.style.top = "0", e.style.left = "0", e.style.width = "100vw", e.style.height = "100vh", e.style.zIndex = "100", e.style.background = "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)", e.style.overflow = "hidden", e.style.transform = "none", e.style.zoom = "1", e.style.margin = "0", e.style.padding = "0");
|
|
327
|
+
}, []), j(() => {
|
|
328
|
+
const e = document.body, t = document.documentElement, c = e.style.zoom, g = e.style.transform, C = t.style.zoom, B = t.style.transform;
|
|
329
|
+
return e.style.zoom = "1", e.style.transform = "none", t.style.zoom = "1", t.style.transform = "none", () => {
|
|
330
|
+
e.style.zoom = c, e.style.transform = g, t.style.zoom = C, t.style.transform = B;
|
|
331
|
+
};
|
|
332
|
+
}, []);
|
|
333
|
+
const L = P(() => {
|
|
334
|
+
const e = s ?? Math.min(r ?? 1e3, u ?? 1e3), t = r ?? (typeof window < "u" ? window.innerWidth : 1e3);
|
|
335
|
+
return e < 600 && t > 768 ? 600 : t <= 768 ? Math.min(e, t - 20) : e;
|
|
336
|
+
}, [s, r, u]);
|
|
337
|
+
j(() => (Te(), () => {
|
|
337
338
|
document.body.style.overflow = "";
|
|
338
339
|
}), []);
|
|
339
|
-
const [w, S] =
|
|
340
|
-
|
|
340
|
+
const [w, S] = d(null), [b, I] = d([]), [l, z] = d(4), [x, k] = d(!1), [f, T] = d(1), [y, ce] = d(null), [v, A] = d("ready"), [K, J] = d(3), [F, $] = d(10), [G, Q] = d(20), [me, N] = d(0), [E, D] = d(!1), [W, X] = d(""), [R, O] = d(!1), [q, ee] = d(!1), [te, H] = d(null), [ue, Y] = d([]), [ge, ne] = d([]), [p, he] = d(!1);
|
|
341
|
+
j(() => {
|
|
341
342
|
if (typeof window > "u") return;
|
|
342
343
|
const e = () => {
|
|
343
|
-
const
|
|
344
|
-
he(
|
|
344
|
+
const t = r ?? window.innerWidth, c = window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
|
|
345
|
+
he(t <= 768 || c);
|
|
345
346
|
};
|
|
346
347
|
return e(), window.addEventListener("resize", e), window.addEventListener("orientationchange", e), () => {
|
|
347
348
|
window.removeEventListener("resize", e), window.removeEventListener("orientationchange", e);
|
|
348
349
|
};
|
|
349
|
-
}, [
|
|
350
|
-
const e =
|
|
350
|
+
}, [r]), _(() => {
|
|
351
|
+
const e = h.current;
|
|
351
352
|
if (!e || typeof window > "u") return;
|
|
352
|
-
let
|
|
353
|
+
let t = null;
|
|
353
354
|
try {
|
|
354
|
-
|
|
355
|
-
for (const
|
|
356
|
-
const
|
|
357
|
-
M(Math.round(Math.min(
|
|
355
|
+
t = new ResizeObserver((c) => {
|
|
356
|
+
for (const g of c) {
|
|
357
|
+
const C = g.contentRect;
|
|
358
|
+
M(Math.round(Math.min(C.width, C.height)));
|
|
358
359
|
}
|
|
359
|
-
}),
|
|
360
|
+
}), t.observe(e), M(Math.round(Math.min(e.clientWidth, e.clientHeight)));
|
|
360
361
|
} catch {
|
|
361
362
|
M(Math.round(Math.min(e.clientWidth, e.clientHeight)));
|
|
362
363
|
}
|
|
363
|
-
return () =>
|
|
364
|
-
}, [
|
|
365
|
-
const
|
|
364
|
+
return () => t?.disconnect();
|
|
365
|
+
}, [p]);
|
|
366
|
+
const oe = (e) => [...e].sort(() => Math.random() - 0.5).slice(0, 6), ie = () => {
|
|
366
367
|
if (!w) return;
|
|
367
|
-
const e =
|
|
368
|
-
I(e),
|
|
369
|
-
},
|
|
370
|
-
const
|
|
371
|
-
let
|
|
372
|
-
for (;
|
|
373
|
-
|
|
374
|
-
I(
|
|
368
|
+
const e = oe(de[w]);
|
|
369
|
+
I(e), k(!0), D(!1), T(1), N(0), Y([]), ne([]), re(e, [], !0);
|
|
370
|
+
}, re = (e = b, t = ge, c = !1) => {
|
|
371
|
+
const g = oe(e.length ? e : de[w]);
|
|
372
|
+
let C = Math.floor(Math.random() * g.length), B = g[C].name, ae = 0;
|
|
373
|
+
for (; t.includes(B) && ae < 20; )
|
|
374
|
+
C = Math.floor(Math.random() * g.length), B = g[C].name, ae++;
|
|
375
|
+
I(g), ce(C), ne([...t, B]), O(!1), X(""), Q(20), H(null), c ? (A("ready"), J(3), $(10)) : (A("memorize"), $(10));
|
|
375
376
|
};
|
|
376
|
-
|
|
377
|
-
if (!(!x ||
|
|
377
|
+
j(() => {
|
|
378
|
+
if (!(!x || E || R)) {
|
|
378
379
|
if (v === "ready")
|
|
379
|
-
if (
|
|
380
|
+
if (K <= 0) A("memorize");
|
|
380
381
|
else {
|
|
381
|
-
const e = setTimeout(() =>
|
|
382
|
+
const e = setTimeout(() => J((t) => t - 1), 1e3);
|
|
382
383
|
return () => clearTimeout(e);
|
|
383
384
|
}
|
|
384
385
|
if (v === "memorize")
|
|
385
|
-
if (
|
|
386
|
+
if (F <= 0) A("guess");
|
|
386
387
|
else {
|
|
387
|
-
const e = setTimeout(() =>
|
|
388
|
+
const e = setTimeout(() => $((t) => t - 1), 1e3);
|
|
388
389
|
return () => clearTimeout(e);
|
|
389
390
|
}
|
|
390
391
|
if (v === "guess") {
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
...
|
|
396
|
-
{ round:
|
|
392
|
+
if (G <= 0) {
|
|
393
|
+
O(!0), H("wrong");
|
|
394
|
+
const t = b[y].name;
|
|
395
|
+
Y((c) => [
|
|
396
|
+
...c,
|
|
397
|
+
{ round: f, answer: W, correct: t, result: "wrong" }
|
|
397
398
|
]);
|
|
398
399
|
return;
|
|
399
400
|
}
|
|
400
|
-
const e = setTimeout(() =>
|
|
401
|
+
const e = setTimeout(() => Q((t) => t - 1), 1e3);
|
|
401
402
|
return () => clearTimeout(e);
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
|
-
}, [v,
|
|
405
|
+
}, [v, K, F, G, x, E, R, b, y, f, W]);
|
|
405
406
|
const fe = () => {
|
|
406
|
-
if (y === null ||
|
|
407
|
-
const e = b[y].name,
|
|
408
|
-
let
|
|
409
|
-
|
|
410
|
-
|
|
407
|
+
if (y === null || q) return;
|
|
408
|
+
const e = b[y].name, t = W.toLowerCase().trim();
|
|
409
|
+
let c = "wrong";
|
|
410
|
+
t === e ? (N((g) => g + 1), H("correct"), c = "correct") : Re(t, e) === 1 ? (N((g) => g + 0.5), H("almost"), c = "almost") : (H("wrong"), c = "wrong"), Y((g) => [...g, { round: f, answer: t, correct: e, result: c }]), ee(!0), setTimeout(() => {
|
|
411
|
+
ee(!1), O(!0);
|
|
411
412
|
}, 600);
|
|
412
|
-
}, pe = () =>
|
|
413
|
-
|
|
413
|
+
}, pe = () => f < l ? (T((e) => e + 1), re()) : D(!0), ye = () => {
|
|
414
|
+
k(!1), D(!1), S(null);
|
|
414
415
|
}, we = P(
|
|
415
|
-
() => /* @__PURE__ */
|
|
416
|
-
/* @__PURE__ */
|
|
416
|
+
() => /* @__PURE__ */ o("div", { style: { ...n.gmLogoFixed, position: "absolute", top: 16, left: 16, zIndex: 30 }, children: /* @__PURE__ */ a("picture", { children: [
|
|
417
|
+
/* @__PURE__ */ o(
|
|
417
418
|
"source",
|
|
418
419
|
{
|
|
419
420
|
srcSet: window.origin + "/cloud/speakid/games/whatsmissing/logo.svg",
|
|
420
421
|
type: "image/svg+xml"
|
|
421
422
|
}
|
|
422
423
|
),
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
+
/* @__PURE__ */ o(
|
|
424
425
|
"img",
|
|
425
426
|
{
|
|
426
427
|
src: window.origin + "/cloud/speakid/games/whatsmissing/logo.png",
|
|
427
428
|
alt: "SPEAKID Logo",
|
|
428
|
-
style:
|
|
429
|
+
style: n.gmLogoImg,
|
|
429
430
|
loading: "lazy"
|
|
430
431
|
}
|
|
431
432
|
)
|
|
432
433
|
] }) }),
|
|
433
434
|
[]
|
|
434
|
-
),
|
|
435
|
-
const e =
|
|
436
|
-
return Math.min(1.35, Math.max(1,
|
|
437
|
-
}, [
|
|
438
|
-
return /* @__PURE__ */
|
|
435
|
+
), se = 1200, le = 700, Z = P(() => {
|
|
436
|
+
const e = r ?? (typeof window < "u" ? window.innerWidth : se), t = u ?? (typeof window < "u" ? window.innerHeight : le), c = Math.min(e / se, t / le);
|
|
437
|
+
return Math.min(1.35, Math.max(1, c));
|
|
438
|
+
}, [r, u, p]);
|
|
439
|
+
return /* @__PURE__ */ o(
|
|
439
440
|
"div",
|
|
440
441
|
{
|
|
441
442
|
ref: i,
|
|
@@ -456,51 +457,51 @@ function Be({
|
|
|
456
457
|
scale: "1 !important"
|
|
457
458
|
// ✅ на случай если transform тянется сверху
|
|
458
459
|
},
|
|
459
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ o(
|
|
460
461
|
"div",
|
|
461
462
|
{
|
|
462
|
-
ref:
|
|
463
|
+
ref: h,
|
|
463
464
|
style: {
|
|
464
|
-
width:
|
|
465
|
-
height:
|
|
466
|
-
borderRadius:
|
|
465
|
+
width: p ? "100%" : `${L}px`,
|
|
466
|
+
height: p ? "100%" : `${L}px`,
|
|
467
|
+
borderRadius: p ? 0 : "20px",
|
|
467
468
|
background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
|
|
468
469
|
position: "relative",
|
|
469
470
|
overflow: "hidden",
|
|
470
|
-
boxShadow:
|
|
471
|
+
boxShadow: p ? "none" : "0 0 40px rgba(0,0,0,0.08)",
|
|
471
472
|
display: "flex",
|
|
472
473
|
justifyContent: "center",
|
|
473
474
|
alignItems: "center"
|
|
474
475
|
},
|
|
475
|
-
children: /* @__PURE__ */
|
|
476
|
+
children: /* @__PURE__ */ a(
|
|
476
477
|
"div",
|
|
477
478
|
{
|
|
478
479
|
id: "whats-missing-root",
|
|
479
480
|
style: {
|
|
480
|
-
transform: `scale(${
|
|
481
|
+
transform: `scale(${Z})`,
|
|
481
482
|
transformOrigin: "center center",
|
|
482
483
|
transition: "transform 0.2s ease-out",
|
|
483
|
-
width: `${100 /
|
|
484
|
-
height: `${100 /
|
|
484
|
+
width: `${100 / Z}%`,
|
|
485
|
+
height: `${100 / Z}%`,
|
|
485
486
|
display: "flex",
|
|
486
487
|
flexDirection: "column",
|
|
487
488
|
justifyContent: "center",
|
|
488
489
|
alignItems: "center"
|
|
489
490
|
},
|
|
490
491
|
children: [
|
|
491
|
-
!
|
|
492
|
-
!w && !x && /* @__PURE__ */
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
/* @__PURE__ */
|
|
497
|
-
/* @__PURE__ */
|
|
498
|
-
/* @__PURE__ */
|
|
492
|
+
!p && we,
|
|
493
|
+
!w && !x && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
|
|
494
|
+
/* @__PURE__ */ o("h1", { style: n.gmHeadline1, children: "WHAT'S MISSING?" }),
|
|
495
|
+
/* @__PURE__ */ o("p", { style: n.gmBodyM, children: "Select a theme:" }),
|
|
496
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: 16 }, children: ["animals", "food", "toys"].map((e) => /* @__PURE__ */ o("button", { style: n.gmButton, onClick: () => S(e), children: e === "animals" ? "🐶 Animals" : e === "food" ? "🍎 Food" : "🧸 Toys" }, e)) }),
|
|
497
|
+
/* @__PURE__ */ a("div", { style: { marginTop: 24 }, children: [
|
|
498
|
+
/* @__PURE__ */ o("p", { style: n.gmBodyS, children: "Choose number of rounds:" }),
|
|
499
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: 12, marginTop: 8 }, children: [3, 4, 5].map((e) => /* @__PURE__ */ o(
|
|
499
500
|
"button",
|
|
500
501
|
{
|
|
501
502
|
style: {
|
|
502
|
-
...
|
|
503
|
-
...
|
|
503
|
+
...n.gmButton,
|
|
504
|
+
...l === e ? n.gmButtonActive : {}
|
|
504
505
|
},
|
|
505
506
|
onClick: () => z(e),
|
|
506
507
|
children: e
|
|
@@ -509,47 +510,47 @@ function Be({
|
|
|
509
510
|
)) })
|
|
510
511
|
] })
|
|
511
512
|
] }),
|
|
512
|
-
w && !x && /* @__PURE__ */
|
|
513
|
-
/* @__PURE__ */
|
|
513
|
+
w && !x && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
|
|
514
|
+
/* @__PURE__ */ a("h1", { style: n.gmHeadline1, children: [
|
|
514
515
|
"Theme selected: ",
|
|
515
516
|
w
|
|
516
517
|
] }),
|
|
517
|
-
/* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ a("p", { style: n.gmBodyM, children: [
|
|
518
519
|
"Rounds: ",
|
|
519
|
-
|
|
520
|
+
l
|
|
520
521
|
] }),
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
+
/* @__PURE__ */ o("button", { style: n.gmButton, onClick: ie, children: "▶ Start game" })
|
|
522
523
|
] }),
|
|
523
|
-
|
|
524
|
-
/* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
524
|
+
E && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
|
|
525
|
+
/* @__PURE__ */ o("h1", { style: n.gmHeadline1, children: "Results" }),
|
|
526
|
+
/* @__PURE__ */ a("h2", { style: n.gmHeadline3, children: [
|
|
526
527
|
"Your score: ",
|
|
527
528
|
me,
|
|
528
529
|
" / ",
|
|
529
|
-
|
|
530
|
+
l
|
|
530
531
|
] }),
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
536
|
-
/* @__PURE__ */
|
|
537
|
-
/* @__PURE__ */
|
|
532
|
+
/* @__PURE__ */ o("p", { style: { ...n.gmBodyM, color: "#10b981", marginTop: 12 }, children: "Yahoo! You did it! 🍬✨" }),
|
|
533
|
+
/* @__PURE__ */ a("table", { style: n.gmTable, children: [
|
|
534
|
+
/* @__PURE__ */ o("thead", { children: /* @__PURE__ */ a("tr", { children: [
|
|
535
|
+
/* @__PURE__ */ o("th", { children: "Round" }),
|
|
536
|
+
/* @__PURE__ */ o("th", { children: "Your Answer" }),
|
|
537
|
+
/* @__PURE__ */ o("th", { children: "Correct" }),
|
|
538
|
+
/* @__PURE__ */ o("th", { children: "Result" })
|
|
538
539
|
] }) }),
|
|
539
|
-
/* @__PURE__ */
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
/* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
/* @__PURE__ */
|
|
544
|
-
] },
|
|
540
|
+
/* @__PURE__ */ o("tbody", { children: ue.map((e, t) => /* @__PURE__ */ a("tr", { children: [
|
|
541
|
+
/* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.round }),
|
|
542
|
+
/* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.answer || "—" }),
|
|
543
|
+
/* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.correct }),
|
|
544
|
+
/* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.result === "correct" ? "✔ Correct" : e.result === "almost" ? "◐ Almost (0.5)" : "✘ Wrong" })
|
|
545
|
+
] }, t)) })
|
|
545
546
|
] }),
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
/* @__PURE__ */
|
|
548
|
-
/* @__PURE__ */
|
|
547
|
+
/* @__PURE__ */ a("div", { style: { display: "flex", gap: 12, marginTop: 24 }, children: [
|
|
548
|
+
/* @__PURE__ */ o("button", { style: n.gmButton, onClick: ie, children: "🔁 Play again" }),
|
|
549
|
+
/* @__PURE__ */ o("button", { style: n.gmButton, onClick: ye, children: "⬅️ Choose theme" })
|
|
549
550
|
] })
|
|
550
551
|
] }),
|
|
551
|
-
x && !
|
|
552
|
-
/* @__PURE__ */
|
|
552
|
+
x && !E && /* @__PURE__ */ a("div", { style: n.gmGameLayout, children: [
|
|
553
|
+
/* @__PURE__ */ a(
|
|
553
554
|
"div",
|
|
554
555
|
{
|
|
555
556
|
style: {
|
|
@@ -560,54 +561,54 @@ function Be({
|
|
|
560
561
|
alignItems: "center"
|
|
561
562
|
},
|
|
562
563
|
children: [
|
|
563
|
-
v === "ready" && /* @__PURE__ */
|
|
564
|
-
/* @__PURE__ */
|
|
565
|
-
/* @__PURE__ */
|
|
564
|
+
v === "ready" && /* @__PURE__ */ a(be, { children: [
|
|
565
|
+
/* @__PURE__ */ o("h1", { style: { ...n.gmHeadline1, color: "#ec4c44" }, children: "GET READY" }),
|
|
566
|
+
/* @__PURE__ */ o("div", { style: n.gmHourglass, children: "⏳" })
|
|
566
567
|
] }),
|
|
567
|
-
v === "memorize" && /* @__PURE__ */
|
|
568
|
+
v === "memorize" && /* @__PURE__ */ a("p", { style: { ...n.gmBodyM, color: "#10b981" }, children: [
|
|
568
569
|
"MEMORIZE (",
|
|
569
|
-
|
|
570
|
+
F,
|
|
570
571
|
")"
|
|
571
572
|
] }),
|
|
572
|
-
v === "guess" && !R && /* @__PURE__ */
|
|
573
|
+
v === "guess" && !R && /* @__PURE__ */ a("p", { style: n.gmBodyM, children: [
|
|
573
574
|
"⏳ Time left: ",
|
|
574
|
-
|
|
575
|
+
G,
|
|
575
576
|
"s"
|
|
576
577
|
] })
|
|
577
578
|
]
|
|
578
579
|
}
|
|
579
580
|
),
|
|
580
|
-
v !== "ready" && /* @__PURE__ */
|
|
581
|
+
v !== "ready" && /* @__PURE__ */ o(
|
|
581
582
|
"div",
|
|
582
583
|
{
|
|
583
584
|
style: {
|
|
584
|
-
...
|
|
585
|
+
...n.gmGrid,
|
|
585
586
|
display: "grid",
|
|
586
|
-
gridTemplateColumns: `repeat(${
|
|
587
|
-
gridTemplateRows: `repeat(${
|
|
588
|
-
gap:
|
|
587
|
+
gridTemplateColumns: `repeat(${p ? 2 : 3}, 1fr)`,
|
|
588
|
+
gridTemplateRows: `repeat(${p ? 3 : 2}, 1fr)`,
|
|
589
|
+
gap: p ? 12 : 20,
|
|
589
590
|
justifyContent: "center",
|
|
590
591
|
alignContent: "center",
|
|
591
|
-
padding:
|
|
592
|
+
padding: p ? 8 : 16,
|
|
592
593
|
width: "100%",
|
|
593
594
|
height: "100%",
|
|
594
|
-
maxWidth:
|
|
595
|
-
maxHeight:
|
|
595
|
+
maxWidth: p ? "100%" : 600,
|
|
596
|
+
maxHeight: p ? "100%" : 400,
|
|
596
597
|
boxSizing: "border-box"
|
|
597
598
|
},
|
|
598
|
-
children: b.map((e,
|
|
599
|
-
const
|
|
600
|
-
return /* @__PURE__ */
|
|
599
|
+
children: b.map((e, t) => {
|
|
600
|
+
const c = y === t && v === "guess" && !R;
|
|
601
|
+
return /* @__PURE__ */ o(
|
|
601
602
|
"div",
|
|
602
603
|
{
|
|
603
604
|
style: {
|
|
604
|
-
...
|
|
605
|
+
...n.gmCard,
|
|
605
606
|
width: "100%",
|
|
606
607
|
height: "100%",
|
|
607
|
-
...
|
|
608
|
-
...
|
|
608
|
+
...te === "correct" && y === t ? n.gmCorrect : {},
|
|
609
|
+
...te === "wrong" && y === t ? n.gmWrong : {}
|
|
609
610
|
},
|
|
610
|
-
children: !
|
|
611
|
+
children: !c && /* @__PURE__ */ o(
|
|
611
612
|
"img",
|
|
612
613
|
{
|
|
613
614
|
src: e.src,
|
|
@@ -621,34 +622,34 @@ function Be({
|
|
|
621
622
|
}
|
|
622
623
|
)
|
|
623
624
|
},
|
|
624
|
-
|
|
625
|
+
t
|
|
625
626
|
);
|
|
626
627
|
})
|
|
627
628
|
}
|
|
628
629
|
),
|
|
629
|
-
/* @__PURE__ */
|
|
630
|
-
v === "guess" && !R && /* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
630
|
+
/* @__PURE__ */ a("div", { style: { marginTop: 16, height: 80 }, children: [
|
|
631
|
+
v === "guess" && !R && /* @__PURE__ */ a("div", { children: [
|
|
632
|
+
/* @__PURE__ */ o(
|
|
632
633
|
"input",
|
|
633
634
|
{
|
|
634
635
|
type: "text",
|
|
635
636
|
placeholder: "Type the missing word",
|
|
636
|
-
value:
|
|
637
|
-
onChange: (e) =>
|
|
638
|
-
style:
|
|
637
|
+
value: W,
|
|
638
|
+
onChange: (e) => X(e.target.value),
|
|
639
|
+
style: n.gmInput
|
|
639
640
|
}
|
|
640
641
|
),
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
+
/* @__PURE__ */ o(
|
|
642
643
|
"button",
|
|
643
644
|
{
|
|
644
|
-
style: { ...
|
|
645
|
+
style: { ...n.gmButton, marginLeft: 8 },
|
|
645
646
|
onClick: fe,
|
|
646
|
-
disabled:
|
|
647
|
-
children:
|
|
647
|
+
disabled: q,
|
|
648
|
+
children: q ? "..." : "Check"
|
|
648
649
|
}
|
|
649
650
|
)
|
|
650
651
|
] }),
|
|
651
|
-
R && /* @__PURE__ */
|
|
652
|
+
R && /* @__PURE__ */ o("button", { type: "button", style: n.gmButton, onClick: pe, children: "Next round" })
|
|
652
653
|
] })
|
|
653
654
|
] })
|
|
654
655
|
]
|
|
@@ -661,5 +662,5 @@ function Be({
|
|
|
661
662
|
}
|
|
662
663
|
export {
|
|
663
664
|
Be as Game,
|
|
664
|
-
|
|
665
|
+
de as themes
|
|
665
666
|
};
|
package/package.json
CHANGED
package/src/Game.tsx
CHANGED
|
@@ -3,29 +3,6 @@ import { themes } from "./themes";
|
|
|
3
3
|
import { styles } from "./Game.styles";
|
|
4
4
|
import type { Theme } from "./themes";
|
|
5
5
|
|
|
6
|
-
// ✅ глобальная нейтрализация зума с безопасным откатом
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const b = document.body;
|
|
9
|
-
const h = document.documentElement;
|
|
10
|
-
|
|
11
|
-
const oldBodyZoom = b.style.zoom;
|
|
12
|
-
const oldBodyTransform = b.style.transform;
|
|
13
|
-
const oldHtmlZoom = h.style.zoom;
|
|
14
|
-
const oldHtmlTransform = h.style.transform;
|
|
15
|
-
|
|
16
|
-
b.style.zoom = "1";
|
|
17
|
-
b.style.transform = "none";
|
|
18
|
-
h.style.zoom = "1";
|
|
19
|
-
h.style.transform = "none";
|
|
20
|
-
console.log("Zoom and transform neutralized globally.");
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
b.style.zoom = oldBodyZoom;
|
|
24
|
-
b.style.transform = oldBodyTransform;
|
|
25
|
-
h.style.zoom = oldHtmlZoom;
|
|
26
|
-
h.style.transform = oldHtmlTransform;
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
6
|
|
|
30
7
|
type ImageItem = { src: string; name: string };
|
|
31
8
|
type RoundResult = {
|
|
@@ -183,6 +160,48 @@ export default function Game({
|
|
|
183
160
|
const [squareSize, setSquareSize] = useState<number | null>(null);
|
|
184
161
|
useNeutralizeBodyZoom(containerRef, { minDesktopWidth: 1024, forceResize: false });
|
|
185
162
|
|
|
163
|
+
// ✅ полная изоляция игры от внешних стилей сайта
|
|
164
|
+
useLayoutEffect(() => {
|
|
165
|
+
const container = containerRef.current;
|
|
166
|
+
if (!container) return;
|
|
167
|
+
|
|
168
|
+
// полностью изолируем игру от внешних стилей
|
|
169
|
+
container.style.position = "fixed";
|
|
170
|
+
container.style.top = "0";
|
|
171
|
+
container.style.left = "0";
|
|
172
|
+
container.style.width = "100vw";
|
|
173
|
+
container.style.height = "100vh";
|
|
174
|
+
container.style.zIndex = "100";
|
|
175
|
+
container.style.background = "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)";
|
|
176
|
+
container.style.overflow = "hidden";
|
|
177
|
+
container.style.transform = "none";
|
|
178
|
+
container.style.zoom = "1";
|
|
179
|
+
container.style.margin = "0";
|
|
180
|
+
container.style.padding = "0";
|
|
181
|
+
}, []);
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
const b = document.body;
|
|
185
|
+
const h = document.documentElement;
|
|
186
|
+
|
|
187
|
+
const oldBodyZoom = b.style.zoom;
|
|
188
|
+
const oldBodyTransform = b.style.transform;
|
|
189
|
+
const oldHtmlZoom = h.style.zoom;
|
|
190
|
+
const oldHtmlTransform = h.style.transform;
|
|
191
|
+
|
|
192
|
+
b.style.zoom = "1";
|
|
193
|
+
b.style.transform = "none";
|
|
194
|
+
h.style.zoom = "1";
|
|
195
|
+
h.style.transform = "none";
|
|
196
|
+
|
|
197
|
+
return () => {
|
|
198
|
+
b.style.zoom = oldBodyZoom;
|
|
199
|
+
b.style.transform = oldBodyTransform;
|
|
200
|
+
h.style.zoom = oldHtmlZoom;
|
|
201
|
+
h.style.transform = oldHtmlTransform;
|
|
202
|
+
};
|
|
203
|
+
}, []);
|
|
204
|
+
|
|
186
205
|
// ✅ защита от слишком маленьких размеров игры
|
|
187
206
|
const effectiveGameCubeSize = useMemo(() => {
|
|
188
207
|
const baseSize = gameCubeSize ?? Math.min(screenWidth ?? 1000, screenHeight ?? 1000);
|