screeps-client 0.6.0 → 0.6.1
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/embedded/_client/{CodePanel-KBQ78175.js → CodePanel-Bfbl4rrd.js} +1 -1
- package/dist/embedded/_client/MapViewer-Bv7oMh47.js +1 -0
- package/dist/embedded/_client/index-Bsvcj_u_.js +25 -0
- package/dist/embedded/index.html +1 -1
- package/dist/standalone/_client/{CodePanel-sM0UkfOw.js → CodePanel-B_hskJA-.js} +1 -1
- package/dist/standalone/_client/MapViewer-C4GLBatS.js +1 -0
- package/dist/standalone/_client/index-BlKO6rX8.js +25 -0
- package/dist/standalone/index.html +1 -1
- package/dist/xxscreeps-mod/_client/{CodePanel-Bfi6k72H.js → CodePanel-DZakAibP.js} +1 -1
- package/dist/xxscreeps-mod/_client/MapViewer-B6zrkNjN.js +1 -0
- package/dist/xxscreeps-mod/_client/index-BFLPaM4k.js +25 -0
- package/dist/xxscreeps-mod/index.html +1 -1
- package/package.json +1 -1
- package/dist/embedded/_client/MapViewer-BL7mzGWw.js +0 -1
- package/dist/embedded/_client/index-KFumkHjd.js +0 -24
- package/dist/standalone/_client/MapViewer-B-eI44Qx.js +0 -1
- package/dist/standalone/_client/index-CHCJvDO3.js +0 -24
- package/dist/xxscreeps-mod/_client/MapViewer-CKPZHZAs.js +0 -1
- package/dist/xxscreeps-mod/_client/index-04hhqfkD.js +0 -24
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
20
20
|
}
|
|
21
21
|
</style>
|
|
22
|
-
<script type="module" crossorigin src="./_client/index-
|
|
22
|
+
<script type="module" crossorigin src="./_client/index-BFLPaM4k.js"></script>
|
|
23
23
|
<link rel="modulepreload" crossorigin href="./_client/vendor-codemirror-D3PB7yT8.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="./_client/vendor-pixi-CerEzm_8.js">
|
|
25
25
|
</head>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as v,n as P,w as C,p as g,k as Q,l as r,m as G,j as p,o as L,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-KFumkHjd.js";import{l as I,h,s as co,r as T}from"./vendor-codemirror-D3PB7yT8.js";import"./vendor-pixi-CWBnI4gg.js";var mo=io("<div style=width:100%;height:100%;position:relative><canvas style=display:block>");const{log:B,error:z}=so("map");function Ro(t){let N,o=null;const[A,W]=I([]),[j,q]=I(1),D=()=>t.originRoom,[$,O]=I(D()??null);let X=null,Z=null;const R=new Map,E=new Map,k=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}},F=200,J=0;let w=[],b=null;const U=()=>{b=null;const n=v();if(!n||!o)return;const e=new Set(A());if(w=w.filter(s=>e.has(s)&&!o.hasRoom(s)),w.length===0)return;const i=w.splice(0,F);n.stores.room.terrainBulk(i,t.shard).then(s=>{for(const[a,l]of s){o==null||o.setRoomTerrain(a,l);const c=k.get(a);c!==void 0&&(o==null||o.setRoomOwned(a,c))}for(const a of i)s.has(a)||o==null||o.markRoomFetched(a)}).catch(s=>z("terrain fetch failed:",s)).finally(()=>{w.length>0&&(b=setTimeout(U,J))})};return h(()=>{v(),t.shard,E.clear(),k.clear()}),co(()=>{N&&(async()=>{var e,i;if(o=new lo({onRoomHover:s=>{var a;(a=t.onHoveredRoomChanged)==null||a.call(t,s?S(s):null)},onRoomClick:s=>{var a;$()!==s?(O(s),o==null||o.setSelectedRoom(s),(a=t.onSelectedRoomChanged)==null||a.call(t,S(s))):Y(s)&&setTimeout(()=>t.onNavigateToRoom(s),0)},onVisibleRoomsChanged:s=>{const a=s.length===0;Z!==a&&(Z=a,a||B(`zoom in — terrain loading active, ${s.length} rooms visible`)),W(s)},onZoomChanged:s=>{var a;q(s),(a=t.onZoomChanged)==null||a.call(t,s)}}),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 s=g(t.originRoom);s&&o.centerOn(s.x,s.y),o.setSelectedRoom(t.originRoom),(i=t.onSelectedRoomChanged)==null||i.call(t,S(t.originRoom))}else{const s=v();if(s)try{const a=await s.http.user.worldStartRoom(t.shard??"shard0");if(!o)return;const l=Array.isArray(a==null?void 0:a.room)?a.room[0]:a==null?void 0:a.room;if(typeof l=="string"){const c=g(l);c&&o.centerOn(c.x,c.y)}}catch(a){z("worldStartRoom failed:",a)}}})()}),T(()=>{b!==null&&(clearTimeout(b),b=null),w=[];for(const n of R.values())n.dispose();R.clear(),o==null||o.destroy(),o=null}),h(()=>{P({currentRoom:$,worldBounds:C,onMove:(i,s)=>{var l,c;const a=eo(i,s);O(a),o==null||o.setSelectedRoom(a),o==null||o.centerOn(i,s,!0),(l=t.onSelectedRoomChanged)==null||l.call(t,S(a)),(c=t.onHoveredRoomChanged)==null||c.call(t,S(a))}});const e=i=>{var l,c;const s=((l=i.target)==null?void 0:l.tagName)??"",a=((c=i.target)==null?void 0:c.isContentEditable)??!1;if(!(s==="INPUT"||s==="TEXTAREA"||a)&&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 s=new Set(e),a=e.filter(m=>!(o!=null&&o.hasRoom(m)));if(a.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;w=a.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}),b===null&&(b=setTimeout(U,0))}n.stores.mapStats.request(e,"owner0",i??void 0);const l=j()>=.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(s)}),h(()=>{o==null||o.setShowRoomNames(Q()),o&&(o.currentShard=t.shard??"shard0")}),h(()=>{o==null||o.setUnclaimableOverlayVisible(r())}),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=L())==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:s,data:a,source:l})=>{s===t.shard&&(o==null||o.setRoomMap2(i,a,l))});T(()=>e.dispose())}),h(()=>{var a;const n=v();if(!n)return;const e=(a=L())==null?void 0:a._id,i=new Set(A()),s=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=y?"own":u||d||f?"other":"none";k.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(()=>s.dispose())}),(()=>{var n=mo(),e=n.firstChild;return no(i=>N=i,e),n})()}export{Ro as MapViewer};
|