screeps-client 0.2.1 → 0.3.0

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.
@@ -1 +1 @@
1
- import{f as E,e as w,j as r,s as c,u as ee,g as te,t as u,h as oe}from"./index-Dy8WKdu-.js";import{l as f,e as ie,g as ne,c as re,r as le,h as P,f as b,j as $,F as R,S as j,n as se,E as de}from"./vendor-codemirror-BbK0dVBs.js";import"./vendor-pixi-c1qrZX58.js";var ae=u("<span style=font-size:11px;color:#e3b341>Unsaved changes"),ce=u('<div style="padding:12px 10px;font-size:12px;color:#484f58;font-style:italic">Loading…'),fe=u("<div style=flex:1;display:flex;align-items:center;justify-content:center;color:#484f58;font-size:13px;font-style:italic>"),ue=u('<div style=position:absolute;inset:0px;background:#0d1117;z-index:100;display:flex;flex-direction:column;overflow:hidden><div style="display:flex;align-items:center;gap:12px;padding:10px 16px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Code</span><select style="background:#010409;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 8px;font-size:12px;cursor:pointer"></select><div style=flex:1></div><button style="padding:5px 14px;border-radius:4px;border:1px solid #238636;font-size:12px;font-weight:600"></button><button style="background:transparent;border:none;color:#8b949e;font-size:18px;cursor:pointer;line-height:1;padding:2px 6px">✕</button></div><div style=flex:1;display:flex;overflow:hidden><div style="width:180px;flex-shrink:0;border-right:1px solid #21262d;display:flex;flex-direction:column;overflow:hidden"><div style="padding:6px 10px;font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;border-bottom:1px solid #21262d;flex-shrink:0">Modules</div><div style=flex:1;overflow:auto></div></div><div style=flex:1;display:flex;flex-direction:column;overflow:hidden><div style="padding:5px 14px;font-size:12px;color:#8b949e;border-bottom:1px solid #21262d;flex-shrink:0;font-family:monospace;background:#0d1117">.js</div><div style=flex:1;overflow:hidden;flex-direction:column>'),pe=u("<option>"),xe=u('<div style="padding:7px 12px;font-size:12px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">');const{error:L}=te("code"),ve=de.theme({"&":{height:"100%"},".cm-scroller":{"font-family":"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace","font-size":"13px","line-height":"1.6",overflow:"auto"},".cm-gutters":{background:"#0d1117","border-right":"1px solid #21262d"},".cm-lineNumbers .cm-gutterElement":{color:"#484f58","min-width":"3em"},".cm-activeLineGutter":{background:"#161b22"},".cm-activeLine":{background:"#161b22"}}),he=[re,se(),le,ve];function ye(W){const[A,G]=f([]),[k,F]=f(""),[m,S]=f({}),[s,C]=f(""),[_,M]=f(!1),[p,B]=f(!1),[x,z]=f(!1),J=()=>Object.keys(m()),{editorView:U,ref:q,createExtension:H}=ie({onValueChange:o=>{const t=s();!t||m()[t]===o||(S(n=>({...n,[t]:o})),z(!0))}});ne(U,()=>m()[s()]??""),H(he),P(()=>{const o=E();o&&o.http.user.branches().then(t=>{G(t.list);const n=t.list.find(d=>d.activeWorld)??t.list[0];n&&F(n.branch)}).catch(t=>{L("branches failed:",t),w("Failed to load branches","error")})}),P(()=>{const o=k(),t=E();!o||!t||(M(!0),S({}),C(""),z(!1),t.http.user.code.get(o).then(n=>{const d=n.modules??{};S(d),C(Object.keys(d)[0]??"")}).catch(n=>{L("get failed:",n),w("Failed to load code","error")}).finally(()=>M(!1)))});const I=()=>{const o=E(),t=k();!o||!t||(B(!0),o.http.user.code.set(t,m()).then(()=>{w("Code saved","success"),z(!1)}).catch(n=>{L("set failed:",n),w("Failed to save code","error")}).finally(()=>B(!1)))};return(()=>{var o=ue(),t=o.firstChild,n=t.firstChild,d=n.nextSibling,K=d.nextSibling,a=K.nextSibling,Q=a.nextSibling,X=t.nextSibling,V=X.firstChild,Y=V.firstChild,T=Y.nextSibling,D=V.nextSibling,y=D.firstChild,Z=y.firstChild,N=y.nextSibling;return d.addEventListener("change",e=>F(e.currentTarget.value)),r(d,b(R,{get each(){return A()},children:e=>(()=>{var i=pe();return r(i,()=>e.branch,null),r(i,()=>e.activeWorld?" ★":"",null),$(()=>i.value=e.branch),i})()})),r(t,b(j,{get when(){return x()},get children(){return ae()}}),a),a.$$click=I,r(a,()=>p()?"Saving…":"Save"),Q.$$click=()=>W.onClose(),r(T,b(j,{get when(){return _()},get children(){return ce()}}),null),r(T,b(R,{get each(){return J()},children:e=>(()=>{var i=xe();return i.$$click=()=>C(e),r(i,e),$(l=>{var v=s()===e?"#1f3158":"transparent",h=s()===e?"#58a6ff":"#c9d1d9",g=`2px solid ${s()===e?"#388bfd":"transparent"}`;return v!==l.e&&c(i,"background",l.e=v),h!==l.t&&c(i,"color",l.t=h),g!==l.a&&c(i,"border-left",l.a=g),l},{e:void 0,t:void 0,a:void 0}),i})()}),null),r(y,s,Z),ee(q,N),r(D,b(j,{get when(){return!s()},get children(){var e=fe();return r(e,()=>_()?"Loading code…":"Select a module"),e}}),null),$(e=>{var i=p()||_()||!x(),l=p()||!x()?"#161b22":"#1a3a2a",v=p()||!x()?"#484f58":"#3fb950",h=p()||!x()?"default":"pointer",g=s()?"block":"none",O=s()?"flex":"none";return i!==e.e&&(a.disabled=e.e=i),l!==e.t&&c(a,"background",e.t=l),v!==e.a&&c(a,"color",e.a=v),h!==e.o&&c(a,"cursor",e.o=h),g!==e.i&&c(y,"display",e.i=g),O!==e.n&&c(N,"display",e.n=O),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),$(()=>d.value=k()),o})()}oe(["click"]);export{ye as CodePanel};
1
+ import{c as E,a as w,i as r,s as c,u as ee,b as te,t as u,d as oe}from"./index-Y34ajerm.js";import{l as f,e as ie,g as ne,c as re,r as le,h as P,f as b,j as $,F as R,S as L,n as de,E as se}from"./vendor-codemirror-BbK0dVBs.js";import"./vendor-pixi-c1qrZX58.js";var ae=u("<span style=font-size:11px;color:#e3b341>Unsaved changes"),ce=u('<div style="padding:12px 10px;font-size:12px;color:#484f58;font-style:italic">Loading…'),fe=u("<div style=flex:1;display:flex;align-items:center;justify-content:center;color:#484f58;font-size:13px;font-style:italic>"),ue=u('<div style=position:absolute;inset:0px;background:#0d1117;z-index:100;display:flex;flex-direction:column;overflow:hidden><div style="display:flex;align-items:center;gap:12px;padding:10px 16px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Code</span><select style="background:#010409;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 8px;font-size:12px;cursor:pointer"></select><div style=flex:1></div><button style="padding:5px 14px;border-radius:4px;border:1px solid #238636;font-size:12px;font-weight:600"></button><button style="background:transparent;border:none;color:#8b949e;font-size:18px;cursor:pointer;line-height:1;padding:2px 6px">✕</button></div><div style=flex:1;display:flex;overflow:hidden><div style="width:180px;flex-shrink:0;border-right:1px solid #21262d;display:flex;flex-direction:column;overflow:hidden"><div style="padding:6px 10px;font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;border-bottom:1px solid #21262d;flex-shrink:0">Modules</div><div style=flex:1;overflow:auto></div></div><div style=flex:1;display:flex;flex-direction:column;overflow:hidden><div style="padding:5px 14px;font-size:12px;color:#8b949e;border-bottom:1px solid #21262d;flex-shrink:0;font-family:monospace;background:#0d1117">.js</div><div style=flex:1;overflow:hidden;flex-direction:column>'),pe=u("<option>"),xe=u('<div style="padding:7px 12px;font-size:12px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">');const{error:j}=te("code"),ve=se.theme({"&":{height:"100%"},".cm-scroller":{"font-family":"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace","font-size":"13px","line-height":"1.6",overflow:"auto"},".cm-gutters":{background:"#0d1117","border-right":"1px solid #21262d"},".cm-lineNumbers .cm-gutterElement":{color:"#484f58","min-width":"3em"},".cm-activeLineGutter":{background:"#161b22"},".cm-activeLine":{background:"#161b22"}}),he=[re,de(),le,ve];function ye(W){const[A,G]=f([]),[k,F]=f(""),[m,S]=f({}),[d,C]=f(""),[_,M]=f(!1),[p,B]=f(!1),[x,z]=f(!1),J=()=>Object.keys(m()),{editorView:U,ref:q,createExtension:H}=ie({onValueChange:o=>{const t=d();!t||m()[t]===o||(S(n=>({...n,[t]:o})),z(!0))}});ne(U,()=>m()[d()]??""),H(he),P(()=>{const o=E();o&&o.http.user.branches().then(t=>{G(t.list);const n=t.list.find(s=>s.activeWorld)??t.list[0];n&&F(n.branch)}).catch(t=>{j("branches failed:",t),w("Failed to load branches","error")})}),P(()=>{const o=k(),t=E();!o||!t||(M(!0),S({}),C(""),z(!1),t.http.user.code.get(o).then(n=>{const s=n.modules??{};S(s),C(Object.keys(s)[0]??"")}).catch(n=>{j("get failed:",n),w("Failed to load code","error")}).finally(()=>M(!1)))});const I=()=>{const o=E(),t=k();!o||!t||(B(!0),o.http.user.code.set(t,m()).then(()=>{w("Code saved","success"),z(!1)}).catch(n=>{j("set failed:",n),w("Failed to save code","error")}).finally(()=>B(!1)))};return(()=>{var o=ue(),t=o.firstChild,n=t.firstChild,s=n.nextSibling,K=s.nextSibling,a=K.nextSibling,Q=a.nextSibling,X=t.nextSibling,V=X.firstChild,Y=V.firstChild,T=Y.nextSibling,D=V.nextSibling,y=D.firstChild,Z=y.firstChild,N=y.nextSibling;return s.addEventListener("change",e=>F(e.currentTarget.value)),r(s,b(R,{get each(){return A()},children:e=>(()=>{var i=pe();return r(i,()=>e.branch,null),r(i,()=>e.activeWorld?" ★":"",null),$(()=>i.value=e.branch),i})()})),r(t,b(L,{get when(){return x()},get children(){return ae()}}),a),a.$$click=I,r(a,()=>p()?"Saving…":"Save"),Q.$$click=()=>W.onClose(),r(T,b(L,{get when(){return _()},get children(){return ce()}}),null),r(T,b(R,{get each(){return J()},children:e=>(()=>{var i=xe();return i.$$click=()=>C(e),r(i,e),$(l=>{var v=d()===e?"#1f3158":"transparent",h=d()===e?"#58a6ff":"#c9d1d9",g=`2px solid ${d()===e?"#388bfd":"transparent"}`;return v!==l.e&&c(i,"background",l.e=v),h!==l.t&&c(i,"color",l.t=h),g!==l.a&&c(i,"border-left",l.a=g),l},{e:void 0,t:void 0,a:void 0}),i})()}),null),r(y,d,Z),ee(q,N),r(D,b(L,{get when(){return!d()},get children(){var e=fe();return r(e,()=>_()?"Loading code…":"Select a module"),e}}),null),$(e=>{var i=p()||_()||!x(),l=p()||!x()?"#161b22":"#1a3a2a",v=p()||!x()?"#484f58":"#3fb950",h=p()||!x()?"default":"pointer",g=d()?"block":"none",O=d()?"flex":"none";return i!==e.e&&(a.disabled=e.e=i),l!==e.t&&c(a,"background",e.t=l),v!==e.a&&c(a,"color",e.a=v),h!==e.o&&c(a,"cursor",e.o=h),g!==e.i&&c(y,"display",e.i=g),O!==e.n&&c(N,"display",e.n=O),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),$(()=>s.value=k()),o})()}oe(["click"]);export{ye as CodePanel};
@@ -0,0 +1 @@
1
+ import{c as v,n as P,w as C,p as g,k as Q,l as F,m as G,j as p,o as r,e as oo,g as to,u as no,f as eo,h as ao,b as so,t as io,M as lo}from"./index-Y34ajerm.js";import{l as O,h,q as co,p as T}from"./vendor-codemirror-BbK0dVBs.js";import"./vendor-pixi-c1qrZX58.js";var mo=io("<div style=width:100%;height:100%;position:relative><canvas style=display:block>");const{log:B,error:L}=so("map");function Ro(t){let N,o=null;const[A,q]=O([]),[z,W]=O(1),j=()=>t.originRoom,[$,k]=O(j()??null);let X=null,Z=null;const R=new Map,E=new Map,I=new Map,_=new Map,Y=n=>{const e=C();if(!e)return!0;const i=g(n);return!!i&&ao(i.x,i.y,e)},S=n=>{var i;const e=E.get(n);return{room:n,owner:(e==null?void 0:e.username)??((i=e==null?void 0:e.own)!=null&&i.user?`user:${e.own.user}`:null),mineral:(e==null?void 0:e.mineral)??null,density:(e==null?void 0:e.density)??null}},D=200,J=0;let b=[],w=null;const U=()=>{w=null;const n=v();if(!n||!o)return;const e=new Set(A());if(b=b.filter(a=>e.has(a)&&!o.hasRoom(a)),b.length===0)return;const i=b.splice(0,D);n.stores.room.terrainBulk(i,t.shard).then(a=>{for(const[s,l]of a){o==null||o.setRoomTerrain(s,l);const c=I.get(s);c!==void 0&&(o==null||o.setRoomOwned(s,c))}}).catch(a=>L("terrain fetch failed:",a)).finally(()=>{b.length>0&&(w=setTimeout(U,J))})};return h(()=>{v(),t.shard,E.clear(),I.clear()}),co(()=>{N&&(async()=>{var e,i;if(o=new lo({onRoomHover:a=>{var s;(s=t.onHoveredRoomChanged)==null||s.call(t,a?S(a):null)},onRoomClick:a=>{var s;$()!==a?(k(a),o==null||o.setSelectedRoom(a),(s=t.onSelectedRoomChanged)==null||s.call(t,S(a))):Y(a)&&setTimeout(()=>t.onNavigateToRoom(a),0)},onVisibleRoomsChanged:a=>{const s=a.length===0;Z!==s&&(Z=s,s||B(`zoom in — terrain loading active, ${a.length} rooms visible`)),q(a)},onZoomChanged:a=>{var s;W(a),(s=t.onZoomChanged)==null||s.call(t,a)}}),await o.init(N),!o)return;t.initialZoom!==void 0&&t.initialZoom>0&&o.setZoom(t.initialZoom),(e=t.onZoomChanged)==null||e.call(t,o.zoom);const n=C();if(n&&o.setBounds(n.minX,n.maxX,n.minY,n.maxY),t.originRoom){const a=g(t.originRoom);a&&o.centerOn(a.x,a.y),o.setSelectedRoom(t.originRoom),(i=t.onSelectedRoomChanged)==null||i.call(t,S(t.originRoom))}else{const a=v();if(a)try{const s=await a.http.user.worldStartRoom(t.shard??"shard0");if(!o)return;const l=Array.isArray(s==null?void 0:s.room)?s.room[0]:s==null?void 0:s.room;if(typeof l=="string"){const c=g(l);c&&o.centerOn(c.x,c.y)}}catch(s){L("worldStartRoom failed:",s)}}})()}),T(()=>{w!==null&&(clearTimeout(w),w=null),b=[];for(const n of R.values())n.dispose();R.clear(),o==null||o.destroy(),o=null}),h(()=>{P({currentRoom:$,worldBounds:C,onMove:(i,a)=>{var l,c;const s=eo(i,a);k(s),o==null||o.setSelectedRoom(s),o==null||o.centerOn(i,a,!0),(l=t.onSelectedRoomChanged)==null||l.call(t,S(s)),(c=t.onHoveredRoomChanged)==null||c.call(t,S(s))}});const e=i=>{var l,c;const a=((l=i.target)==null?void 0:l.tagName)??"",s=((c=i.target)==null?void 0:c.isContentEditable)??!1;if(!(a==="INPUT"||a==="TEXTAREA"||s)&&i.key==="m"){const m=$();m&&Y(m)&&t.onNavigateToRoom(m)}};window.addEventListener("keydown",e),T(()=>window.removeEventListener("keydown",e))}),h(()=>{var c;const n=v(),e=A(),i=t.shard;if(!n||e.length===0)return;const a=new Set(e),s=e.filter(m=>!(o!=null&&o.hasRoom(m)));if(s.length>0){const m=e.reduce((d,y)=>{var f;return d+(((f=g(y))==null?void 0:f.x)??0)},0)/e.length,u=e.reduce((d,y)=>{var f;return d+(((f=g(y))==null?void 0:f.y)??0)},0)/e.length;b=s.slice().sort((d,y)=>{const f=g(d),M=g(y),x=f?Math.abs(f.x-m)+Math.abs(f.y-u):999,H=M?Math.abs(M.x-m)+Math.abs(M.y-u):999;return x-H}),w===null&&(w=setTimeout(U,0))}n.stores.mapStats.request(e,"owner0",i??void 0);const l=z()>=.4;if(l!==X&&(X=l,(c=t.onSubscriptionStateChanged)==null||c.call(t,l),l||o==null||o.clearAllMap2()),l){const m=new Set(e.map(u=>`${u}/${i}`));for(const[u,d]of R)m.has(u)||(d.dispose(),R.delete(u),o==null||o.clearRoomMap2(u.split("/")[0]));for(const u of e){const d=`${u}/${i}`;R.has(d)||R.set(d,n.stores.map.subscribeMap2(u,i))}}else{for(const[,m]of R)m.dispose();R.clear()}o==null||o.clearInvisibleRooms(a)}),h(()=>{o==null||o.setShowRoomNames(Q()),o&&(o.currentShard=t.shard??"shard0")}),h(()=>{o==null||o.setUnclaimableOverlayVisible(F())}),h(()=>{o==null||o.setOverlayMode(G())}),h(()=>{const n=v(),e=t.shard;n&&n.stores.server.worldInfo(e??void 0).then(i=>{B(`worldInfo(shard=${e??"none"}) — x: [${i.minX}, ${i.maxX}] y: [${i.minY}, ${i.maxY}]`),p(i)}).catch(i=>{})}),h(()=>{var n;o==null||o.setCurrentUser(((n=r())==null?void 0:n._id)??null)}),h(()=>{const n=C();n?(o==null||o.setBounds(n.minX,n.maxX,n.minY,n.maxY),B(`worldBounds applied — shard: ${t.shard??"none"} x: [${n.minX}, ${n.maxX}] y: [${n.minY}, ${n.maxY}] (fetched for shard: ${n.shard??"none"})`)):(o==null||o.clearBounds(),B(`worldBounds — none (shard: ${t.shard??"none"})`))}),h(()=>{const n=v();if(!n)return;const e=n.stores.map.on("room:map2update",({room:i,shard:a,data:s,source:l})=>{a===t.shard&&(o==null||o.setRoomMap2(i,s,l))});T(()=>e.dispose())}),h(()=>{var s;const n=v();if(!n)return;const e=(s=r())==null?void 0:s._id,i=new Set(A()),a=n.stores.mapStats.on("mapStats:room",({room:l,stat:c})=>{var K,V;E.set(l,c);const m=g(l),u=m?oo(m.x,m.y)||to(m.x,m.y):!1,d=c.status==="out of borders",y=!!(c.own&&c.own.user===e),f=!!(c.own&&c.own.user!==e),M=u||d||y||f;I.set(l,M),i.has(l)&&(o==null||o.setRoomOwned(l,M),o==null||o.setRoomSafeMode(l,!!c.safeMode)),o==null||o.setRoomMineral(l,c.mineral,c.density);const x=c.badge?JSON.stringify(c.badge):"";_.get(l)!==x&&(_.set(l,x),o==null||o.setRoomBadge(l,c.badge,(K=c.own)==null?void 0:K.level)),$()===l&&((V=t.onSelectedRoomChanged)==null||V.call(t,S(l)))});T(()=>a.dispose())}),(()=>{var n=mo(),e=n.firstChild;return no(i=>N=i,e),n})()}export{Ro as MapViewer};