3 lines
2.9 KiB
JavaScript
3 lines
2.9 KiB
JavaScript
import{_ as C,r as v,ah as q,u as E,o as z,a as g,b as w,p as n,i as L,O as _}from"./framework.BcrMLAmg.js";const S=["disabled"],X={__name:"BasaltDemo",setup(Y){const a=v(!1),l=v(null),o=q({x:100,y:100});let d={x:0,y:0},c=!1;const u=E();let p="";z(()=>{var t;typeof window>"u"||(p=(((t=u.default)==null?void 0:t.call(u))||[]).map(e=>typeof e.children=="string"?e.children:"").join(`
|
|
`))});async function D(){if(typeof window>"u"||typeof document>"u")return;a.value=!0;const t=await fetch("https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua").then(s=>s.text()),e=document.createElement("script");e.src="https://copy-cat.squiddev.cc/require.js",e.onload=()=>{window.require.config({paths:{copycat:"https://copy-cat.squiddev.cc/"}}),window.require(["copycat/embed"],s=>{s(l.value,{hdFont:"https://copy-cat.squiddev.cc/term_font_hd-0506b6efe5f7feae.png",files:{"startup.lua":p,"basalt.lua":t},label:"Basalt Demo"}).run()})},document.body.appendChild(e)}function k(){a.value=!1}function B(t){typeof document>"u"||(c=!0,d.x=t.clientX-o.x,d.y=t.clientY-o.y,document.addEventListener("mousemove",f),document.addEventListener("mouseup",m))}function f(t){var b;if(!c||typeof window>"u")return;const e=(b=l.value)==null?void 0:b.parentElement,s=(e==null?void 0:e.offsetWidth)||0,x=(e==null?void 0:e.offsetHeight)||0,y=window.innerWidth-s,h=window.innerHeight-x;let i=t.clientX-d.x,r=t.clientY-d.y;i<0&&(i=0),r<0&&(r=0),i>y&&(i=y),r>h&&(r=h),o.x=i,o.y=r}function m(){typeof document>"u"||(c=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m))}return(t,e)=>(w(),g("div",null,[n("button",{onClick:D,disabled:a.value,style:_({pointerEvents:a.value?"none":"auto"})}," ▶ Run ",12,S),a.value?(w(),g("div",{key:0,style:_({position:"fixed",top:o.y+"px",left:o.x+"px",width:"625px",height:"425px",background:"#1a1a1a",borderRadius:"8px",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",zIndex:9999,border:"1px solid #333"})},[n("div",{onMousedown:B,style:{display:"flex","justify-content":"space-between","align-items":"center",padding:"0.5rem 1rem",background:"linear-gradient(180deg, #2a2a2a 0%, #222 100%)","border-bottom":"1px solid #111",cursor:"move","user-select":"none","border-radius":"8px 8px 0 0"}},[e[0]||(e[0]=n("div",{style:{display:"flex","align-items":"center",gap:"0.5rem",color:"#fff","font-size":"0.875rem","font-weight":"500"}},[n("span",null,"💻"),n("span",null,"Basalt Demo")],-1)),n("div",{style:{display:"flex",gap:"0.5rem"}},[n("button",{onClick:k,style:{width:"24px",height:"24px","border-radius":"50%",border:"none",cursor:"pointer",background:"#ef4444",color:"white","font-size":"12px",transition:"all 0.2s ease"},title:"Close (ESC)"}," ✕ ")])],32),n("div",{ref_key:"container",ref:l,style:{flex:"1",background:"#000","border-radius":"0 0 8px 8px",overflow:"hidden",position:"relative"}},null,512)],4)):L("",!0)]))}},H=C(X,[["__scopeId","data-v-080bd216"]]);export{H as default};
|