screeps-client 0.7.0 → 0.7.2
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-CVrM6x4v.js → CodePanel-DQ-gtCIA.js} +1 -1
- package/dist/embedded/_client/MapViewer-CBzlhSR4.js +1 -0
- package/dist/embedded/_client/index-B_26EkhX.js +19 -0
- package/dist/{standalone/_client/terrain.worker-BgNTQAMk.js → embedded/_client/terrain.worker-CiQZPqa4.js} +1 -1
- package/dist/embedded/_client/{vendor-pixi-DseA5gVO.js → vendor-pixi-Df5Nob1b.js} +1 -1
- package/dist/embedded/index.html +2 -2
- package/dist/embedded/themes/default/test.json +83 -11
- package/dist/embedded/themes/default/test.png +0 -0
- package/dist/standalone/_client/{CodePanel-CwVNxrB0.js → CodePanel-DDVe4v82.js} +1 -1
- package/dist/standalone/_client/MapViewer-ChA27vix.js +1 -0
- package/dist/standalone/_client/index-D3lZ5ALP.js +19 -0
- package/dist/{xxscreeps-mod/_client/terrain.worker-BgNTQAMk.js → standalone/_client/terrain.worker-CiQZPqa4.js} +1 -1
- package/dist/standalone/_client/{vendor-pixi-_F6CfCZH.js → vendor-pixi-NbxvK8iu.js} +1 -1
- package/dist/standalone/index.html +2 -2
- package/dist/standalone/themes/default/test.json +83 -11
- package/dist/standalone/themes/default/test.png +0 -0
- package/dist/xxscreeps-mod/_client/{CodePanel-D6kl0sq1.js → CodePanel-4SfZ7lcX.js} +1 -1
- package/dist/xxscreeps-mod/_client/MapViewer-CRlkqmaa.js +1 -0
- package/dist/xxscreeps-mod/_client/index-DheecpH5.js +19 -0
- package/dist/{embedded/_client/terrain.worker-BgNTQAMk.js → xxscreeps-mod/_client/terrain.worker-CiQZPqa4.js} +1 -1
- package/dist/xxscreeps-mod/_client/{vendor-pixi-DoK_ycfH.js → vendor-pixi-DCKL8Yf2.js} +1 -1
- package/dist/xxscreeps-mod/index.html +2 -2
- package/dist/xxscreeps-mod/themes/default/test.json +83 -11
- package/dist/xxscreeps-mod/themes/default/test.png +0 -0
- package/package.json +1 -1
- package/dist/embedded/_client/MapViewer-COMbpdgT.js +0 -1
- package/dist/embedded/_client/index-DDx5QnXZ.js +0 -19
- package/dist/standalone/_client/MapViewer-B3Ow_Bmv.js +0 -1
- package/dist/standalone/_client/index-q2IQJ_hs.js +0 -19
- package/dist/xxscreeps-mod/_client/MapViewer-B2pRqyZI.js +0 -1
- package/dist/xxscreeps-mod/_client/index-DGByyYWv.js +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){let e=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({});function t(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function n(e,n,r){let i=(1-Math.abs(2*r-1))*n,a=e/60,o=i*(1-Math.abs(a%2-1)),s=0,c=0,l=0;!Number.isNaN(e)&&e!=null&&(a>=0&&a<1?(s=i,c=o,l=0):a>=1&&a<2?(s=o,c=i,l=0):a>=2&&a<3?(s=0,c=i,l=o):a>=3&&a<4?(s=0,c=o,l=i):a>=4&&a<5?(s=o,c=0,l=i):a>=5&&a<6&&(s=i,c=0,l=o));let u=r-i/2,d=(s+u)*255,f=(c+u)*255,p=(l+u)*255;return`#`+t(d)+t(f)+t(p)}function r(){let e=[],t=0;e.push({index:t++,rgb:n(0,0,.8)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.6,.8)});e.push({index:t++,rgb:n(0,0,.5)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.7,.5)});e.push({index:t++,rgb:n(0,0,.3)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.4,.3)});e.push({index:t++,rgb:n(0,0,.1)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.5,.1)});return e}r();let i=856343,a=4020797,o=[128,512];function s(e){return`rgb(${e>>16&255},${e>>8&255},${e&255})`}function c(e,t,n,r){for(let i=0;i<2500;i++)if(t[i]===n){let t=i%50,n=Math.floor(i/50),a=Math.round(t*r),o=Math.round(n*r);e.fillRect(a,o,Math.round((t+1)*r)-a,Math.round((n+1)*r)-o)}}function l(e,t,n,r){let i=r/2,a=Math.PI;e.beginPath();for(let o=0;o<50;o++)for(let s=0;s<50;s++){let c=t[o*50+s]===n,l=o>0&&t[(o-1)*50+s]===n,u=o<49&&t[(o+1)*50+s]===n,d=s>0&&t[o*50+(s-1)]===n,f=s<49&&t[o*50+(s+1)]===n,p=s*r+i,m=o*r+i;c?!l&&!d&&o>0&&s>0?(e.moveTo(p,o*r),e.arc(p,m,i,-a/2,a,!0),e.lineTo(p,m)):e.rect(s*r,o*r,i,i):l&&d&&t[(o-1)*50+(s-1)]===n&&(e.moveTo(p,o*r),e.lineTo(s*r,o*r),e.lineTo(s*r,m),e.arc(p,m,i,a,-a/2,!1)),c?!l&&!f&&o>0&&s<49?(e.moveTo(p,o*r),e.arc(p,m,i,-a/2,0,!1),e.lineTo(p,m)):e.rect(p,o*r,i,i):l&&f&&t[(o-1)*50+(s+1)]===n&&(e.moveTo(p,o*r),e.lineTo(s*r+r,o*r),e.lineTo(s*r+r,m),e.arc(p,m,i,0,-a/2,!0)),c?!u&&!d&&o<49&&s>0?(e.moveTo(s*r,m),e.arc(p,m,i,a,a/2,!0),e.lineTo(p,m)):e.rect(s*r,m,i,i):u&&d&&t[(o+1)*50+(s-1)]===n&&(e.moveTo(s*r,m),e.lineTo(s*r,o*r+r),e.lineTo(p,o*r+r),e.arc(p,m,i,a/2,a,!1)),c?!u&&!f&&o<49&&s<49?(e.moveTo(p,o*r+r),e.arc(p,m,i,a/2,0,!0),e.lineTo(p,m)):e.rect(p,m,i,i):u&&f&&t[(o+1)*50+(s+1)]===n&&(e.moveTo(p,o*r+r),e.lineTo(s*r+r,o*r+r),e.lineTo(s*r+r,m),e.arc(p,m,i,0,a/2,!1))}e.fill()}self.onmessage=t=>{let{id:n,roomName:r,lod:u,raw:d}=t.data,
|
|
1
|
+
(function(){let e=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({});function t(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function n(e,n,r){let i=(1-Math.abs(2*r-1))*n,a=e/60,o=i*(1-Math.abs(a%2-1)),s=0,c=0,l=0;!Number.isNaN(e)&&e!=null&&(a>=0&&a<1?(s=i,c=o,l=0):a>=1&&a<2?(s=o,c=i,l=0):a>=2&&a<3?(s=0,c=i,l=o):a>=3&&a<4?(s=0,c=o,l=i):a>=4&&a<5?(s=o,c=0,l=i):a>=5&&a<6&&(s=i,c=0,l=o));let u=r-i/2,d=(s+u)*255,f=(c+u)*255,p=(l+u)*255;return`#`+t(d)+t(f)+t(p)}function r(){let e=[],t=0;e.push({index:t++,rgb:n(0,0,.8)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.6,.8)});e.push({index:t++,rgb:n(0,0,.5)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.7,.5)});e.push({index:t++,rgb:n(0,0,.3)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.4,.3)});e.push({index:t++,rgb:n(0,0,.1)});for(let r=0;r<19;r++)e.push({index:t++,rgb:n(r*360/19,.5,.1)});return e}r();let i=856343,a=4020797,o=[128,512];function s(e){return`rgb(${e>>16&255},${e>>8&255},${e&255})`}function c(e,t,n,r){for(let i=0;i<2500;i++)if(t[i]===n){let t=i%50,n=Math.floor(i/50),a=Math.round(t*r),o=Math.round(n*r);e.fillRect(a,o,Math.round((t+1)*r)-a,Math.round((n+1)*r)-o)}}function l(e,t,n,r){let i=r/2,a=Math.PI;e.beginPath();for(let o=0;o<50;o++)for(let s=0;s<50;s++){let c=t[o*50+s]===n,l=o>0&&t[(o-1)*50+s]===n,u=o<49&&t[(o+1)*50+s]===n,d=s>0&&t[o*50+(s-1)]===n,f=s<49&&t[o*50+(s+1)]===n,p=s*r+i,m=o*r+i;c?!l&&!d&&o>0&&s>0?(e.moveTo(p,o*r),e.arc(p,m,i,-a/2,a,!0),e.lineTo(p,m)):e.rect(s*r,o*r,i,i):l&&d&&t[(o-1)*50+(s-1)]===n&&(e.moveTo(p,o*r),e.lineTo(s*r,o*r),e.lineTo(s*r,m),e.arc(p,m,i,a,-a/2,!1)),c?!l&&!f&&o>0&&s<49?(e.moveTo(p,o*r),e.arc(p,m,i,-a/2,0,!1),e.lineTo(p,m)):e.rect(p,o*r,i,i):l&&f&&t[(o-1)*50+(s+1)]===n&&(e.moveTo(p,o*r),e.lineTo(s*r+r,o*r),e.lineTo(s*r+r,m),e.arc(p,m,i,0,-a/2,!0)),c?!u&&!d&&o<49&&s>0?(e.moveTo(s*r,m),e.arc(p,m,i,a,a/2,!0),e.lineTo(p,m)):e.rect(s*r,m,i,i):u&&d&&t[(o+1)*50+(s-1)]===n&&(e.moveTo(s*r,m),e.lineTo(s*r,o*r+r),e.lineTo(p,o*r+r),e.arc(p,m,i,a/2,a,!1)),c?!u&&!f&&o<49&&s<49?(e.moveTo(p,o*r+r),e.arc(p,m,i,a/2,0,!0),e.lineTo(p,m)):e.rect(p,m,i,i):u&&f&&t[(o+1)*50+(s+1)]===n&&(e.moveTo(p,o*r+r),e.lineTo(s*r+r,o*r+r),e.lineTo(s*r+r,m),e.arc(p,m,i,0,a/2,!1))}e.fill()}self.onmessage=async t=>{let{id:n,roomName:r,lod:u,raw:d,shard:f}=t.data,p=o[u]||128,m=p/50,h=new OffscreenCanvas(p,p),g=h.getContext(`2d`,{alpha:!1});if(!g)return;g.fillStyle=s(2962235),g.fillRect(0,0,p,p),u>=1?(g.fillStyle=s(a),l(g,d,e.Swamp,m),g.fillStyle=s(i),l(g,d,e.Wall,m)):(g.fillStyle=s(a),c(g,d,e.Swamp,m),g.fillStyle=s(i),c(g,d,e.Wall,m));let _=await createImageBitmap(h);self.postMessage({kind:`bitmap`,id:n,roomName:r,lod:u,bitmap:_},{transfer:[_]});try{let e=await h.convertToBlob({type:`image/webp`}),t=await e.arrayBuffer();self.postMessage({kind:`cache`,shard:f,roomName:r,lod:u,cacheBytes:t,cacheType:e.type},{transfer:[t]})}catch{}}})();
|
|
@@ -1271,4 +1271,4 @@ fn mainFragment(
|
|
|
1271
1271
|
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
1272
1272
|
return textureSample(img, imgSampler, texCoord);
|
|
1273
1273
|
}
|
|
1274
|
-
`}),t=this.device.createRenderPipeline({layout:`auto`,vertex:{module:this.mipmapShaderModule,entryPoint:`vertexMain`},fragment:{module:this.mipmapShaderModule,entryPoint:`fragmentMain`,targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if(e.dimension===`3d`||e.dimension===`1d`)throw Error(`Generating mipmaps for non-2d textures is currently unsupported!`);let n=e,r=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(t)}let a=this.device.createCommandEncoder({}),o=t.getBindGroupLayout(0);for(let s=0;s<r;++s){let r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),c=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=n.createView({baseMipLevel:c++,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),i=a.beginRenderPass({colorAttachments:[{view:e,storeOp:`store`,loadOp:`clear`,clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:r}]});i.setPipeline(t),i.setBindGroup(0,l),i.draw(3,1,0,0),i.end(),r=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let r=1;r<e.mipLevelCount;++r)a.copyTextureToTexture({texture:n,mipLevel:r-1},{texture:e,mipLevel:r},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),i||n.destroy(),e}},qg=class{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}},Jg=class{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,`_bindGroupHash`,`hash`),this._managedTextures=new hs({renderer:e,type:`resource`,onUnload:this.onSourceUnload.bind(this),name:`gpuTextureSource`});let t={image:Wg,buffer:Rg,video:Gg,compressed:Vg};this._uploads={...t,cube:Ug(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){return e._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!==`compressed`&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let n=zg[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,a={label:e.label,size:{width:r,height:i,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(a);return e._gpuData[this._renderer.uid]=new qg(o),this._managedTextures.add(e)&&(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceResize,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this)),this.onSourceUpdate(e),o}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){this._mipmapGenerator||=new Kg(this._gpu.device);let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off(`update`,this.onSourceUpdate,this),e.off(`resize`,this.onSourceResize,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;let t=e._gpuData[this._renderer.uid],n=t?.gpuTexture;n?(n.width!==e.pixelWidth||n.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new Ur({0:t,1:t.style,2:new Hr({uTextureMatrix:{type:`mat3x3<f32>`,value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){let t=e.source;t._gcLastUsed=this._renderer.gc.now;let n=t._gpuData[this._renderer.uid];return n||=(this.initSource(t),t._gpuData[this._renderer.uid]),n.textureView||=n.gpuTexture.createView({dimension:t.viewDimension}),n.textureView}generateCanvas(e){let t=this._renderer,n=t.gpu.device.createCommandEncoder(),r=G.get().createCanvas();r.width=e.source.pixelWidth,r.height=e.source.pixelHeight;let i=r.getContext(`webgpu`);return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:G.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:`premultiplied`}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:r.width,height:r.height}),t.gpu.device.queue.submit([n.finish()]),r}getPixels(e){let t=this.generateCanvas(e),n=tu.getOptimalCanvasAndContext(t.width,t.height),r=n.context;r.drawImage(t,0,0);let{width:i,height:a}=t,o=r.getImageData(0,0,i,a),s=new Uint8ClampedArray(o.data.buffer);return tu.returnCanvasAndContext(n),{pixels:s,width:i,height:a}}destroy(){this._managedTextures.destroy();for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};Jg.extension={type:[s.WebGPUSystem],name:`texture`};var Yg=class{constructor(){this._maxTextures=0}contextChange(e){let t=new Hr({uTransformMatrix:{value:new b,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}});this._maxTextures=e.limits.maxBatchableTextures;let n=Xo({name:`graphics`,bits:[Qo,rs(this._maxTextures),ed,ss]});this.shader=new Gr({gpuProgram:n,resources:{localUniforms:t}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{batcher:a,instructions:o}=i.graphicsContext.getContextRenderData(n),s=i.encoder;s.setGeometry(a.geometry,r.gpuProgram);let c=i.globalUniforms.bindGroup;s.setBindGroup(0,c,r.gpuProgram);let l=i.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);s.setBindGroup(2,l,r.gpuProgram);let u=o.instructions,d=null;for(let t=0;t<o.instructionSize;t++){let n=u[t];if(n.topology!==d&&(d=n.topology,s.setPipelineFromGeometryProgramAndState(a.geometry,r.gpuProgram,e.state,n.topology)),r.groups[1]=n.bindGroup,!n.gpuBindGroup){let e=n.textures;n.bindGroup=Za(e.textures,e.count,this._maxTextures),n.gpuBindGroup=i.bindGroup.getBindGroup(n.bindGroup,r.gpuProgram,1)}s.setBindGroup(1,n.bindGroup,r.gpuProgram),s.renderPassEncoder.drawIndexed(n.size,1,n.start)}}destroy(){this.shader.destroy(!0),this.shader=null}};Yg.extension={type:[s.WebGPUPipesAdaptor],name:`graphics`};var Xg=class{init(){let e=Xo({name:`mesh`,bits:[$u,Rf,ss]});this._shader=new Gr({gpuProgram:e,resources:{uTexture:R.EMPTY._source,uSampler:R.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new b}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){H(`Mesh shader has no gpuProgram`,t.shader);return}let i=r.gpuProgram;if(i.autoAssignGlobalUniforms&&(r.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;r.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};Xg.extension={type:[s.WebGPUPipesAdaptor],name:`mesh`};var Zg=e({WebGPURenderer:()=>i_}),Qg=[...im,Tg,vg,_g,yg,mg,Jg,Pg,Fg,Lg,jg,gg,bg,fg],$g=[...am,Dg],e_=[Ff,Xg,Yg],t_=[],n_=[],r_=[];u.handleByNamedList(s.WebGPUSystem,t_),u.handleByNamedList(s.WebGPUPipes,n_),u.handleByNamedList(s.WebGPUPipesAdaptor,r_),u.add(...Qg,...$g,...e_);var i_=class extends Wi{constructor(){let e={name:`webgpu`,type:Wr.WEBGPU,systems:t_,renderPipes:n_,renderPipeAdaptors:r_};super(e)}},a_=e({BitmapFont:()=>o_}),o_=class extends bf{constructor(e,t){super();let{textures:n,data:r}=e;Object.keys(r.pages).forEach(e=>{let t=n[r.pages[parseInt(e,10)].id];this.pages.push({texture:t})}),Object.keys(r.chars).forEach(e=>{let t=r.chars[e],{frame:i,source:a,rotate:o}=n[t.page],s=new R({frame:j.transformRectCoords(t,i,o,new M),orig:new M(0,0,t.width,t.height),source:a,rotate:o});this.chars[e]={id:e.codePointAt(0),xOffset:t.xOffset,yOffset:t.yOffset,xAdvance:t.xAdvance,kerning:t.kerning??{},texture:s}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:`none`,range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){kf.install(e)}static uninstall(e){kf.uninstall(e)}};u.add(d,f),u.add(ir),u.mixin(It,ar),u.add(Rl),u.add(Xl),u.mixin(It,Zl),u.add(ju,cu),u.add(Ou);var s_=e({}),c_=e({});export{
|
|
1274
|
+
`}),t=this.device.createRenderPipeline({layout:`auto`,vertex:{module:this.mipmapShaderModule,entryPoint:`vertexMain`},fragment:{module:this.mipmapShaderModule,entryPoint:`fragmentMain`,targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if(e.dimension===`3d`||e.dimension===`1d`)throw Error(`Generating mipmaps for non-2d textures is currently unsupported!`);let n=e,r=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(t)}let a=this.device.createCommandEncoder({}),o=t.getBindGroupLayout(0);for(let s=0;s<r;++s){let r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),c=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=n.createView({baseMipLevel:c++,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),i=a.beginRenderPass({colorAttachments:[{view:e,storeOp:`store`,loadOp:`clear`,clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:r}]});i.setPipeline(t),i.setBindGroup(0,l),i.draw(3,1,0,0),i.end(),r=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let r=1;r<e.mipLevelCount;++r)a.copyTextureToTexture({texture:n,mipLevel:r-1},{texture:e,mipLevel:r},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),i||n.destroy(),e}},qg=class{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}},Jg=class{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,`_bindGroupHash`,`hash`),this._managedTextures=new hs({renderer:e,type:`resource`,onUnload:this.onSourceUnload.bind(this),name:`gpuTextureSource`});let t={image:Wg,buffer:Rg,video:Gg,compressed:Vg};this._uploads={...t,cube:Ug(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){return e._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!==`compressed`&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let n=zg[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,a={label:e.label,size:{width:r,height:i,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(a);return e._gpuData[this._renderer.uid]=new qg(o),this._managedTextures.add(e)&&(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceResize,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this)),this.onSourceUpdate(e),o}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){this._mipmapGenerator||=new Kg(this._gpu.device);let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off(`update`,this.onSourceUpdate,this),e.off(`resize`,this.onSourceResize,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;let t=e._gpuData[this._renderer.uid],n=t?.gpuTexture;n?(n.width!==e.pixelWidth||n.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new Ur({0:t,1:t.style,2:new Hr({uTextureMatrix:{type:`mat3x3<f32>`,value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){let t=e.source;t._gcLastUsed=this._renderer.gc.now;let n=t._gpuData[this._renderer.uid];return n||=(this.initSource(t),t._gpuData[this._renderer.uid]),n.textureView||=n.gpuTexture.createView({dimension:t.viewDimension}),n.textureView}generateCanvas(e){let t=this._renderer,n=t.gpu.device.createCommandEncoder(),r=G.get().createCanvas();r.width=e.source.pixelWidth,r.height=e.source.pixelHeight;let i=r.getContext(`webgpu`);return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:G.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:`premultiplied`}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:r.width,height:r.height}),t.gpu.device.queue.submit([n.finish()]),r}getPixels(e){let t=this.generateCanvas(e),n=tu.getOptimalCanvasAndContext(t.width,t.height),r=n.context;r.drawImage(t,0,0);let{width:i,height:a}=t,o=r.getImageData(0,0,i,a),s=new Uint8ClampedArray(o.data.buffer);return tu.returnCanvasAndContext(n),{pixels:s,width:i,height:a}}destroy(){this._managedTextures.destroy();for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};Jg.extension={type:[s.WebGPUSystem],name:`texture`};var Yg=class{constructor(){this._maxTextures=0}contextChange(e){let t=new Hr({uTransformMatrix:{value:new b,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}});this._maxTextures=e.limits.maxBatchableTextures;let n=Xo({name:`graphics`,bits:[Qo,rs(this._maxTextures),ed,ss]});this.shader=new Gr({gpuProgram:n,resources:{localUniforms:t}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{batcher:a,instructions:o}=i.graphicsContext.getContextRenderData(n),s=i.encoder;s.setGeometry(a.geometry,r.gpuProgram);let c=i.globalUniforms.bindGroup;s.setBindGroup(0,c,r.gpuProgram);let l=i.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);s.setBindGroup(2,l,r.gpuProgram);let u=o.instructions,d=null;for(let t=0;t<o.instructionSize;t++){let n=u[t];if(n.topology!==d&&(d=n.topology,s.setPipelineFromGeometryProgramAndState(a.geometry,r.gpuProgram,e.state,n.topology)),r.groups[1]=n.bindGroup,!n.gpuBindGroup){let e=n.textures;n.bindGroup=Za(e.textures,e.count,this._maxTextures),n.gpuBindGroup=i.bindGroup.getBindGroup(n.bindGroup,r.gpuProgram,1)}s.setBindGroup(1,n.bindGroup,r.gpuProgram),s.renderPassEncoder.drawIndexed(n.size,1,n.start)}}destroy(){this.shader.destroy(!0),this.shader=null}};Yg.extension={type:[s.WebGPUPipesAdaptor],name:`graphics`};var Xg=class{init(){let e=Xo({name:`mesh`,bits:[$u,Rf,ss]});this._shader=new Gr({gpuProgram:e,resources:{uTexture:R.EMPTY._source,uSampler:R.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new b}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){H(`Mesh shader has no gpuProgram`,t.shader);return}let i=r.gpuProgram;if(i.autoAssignGlobalUniforms&&(r.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;r.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};Xg.extension={type:[s.WebGPUPipesAdaptor],name:`mesh`};var Zg=e({WebGPURenderer:()=>i_}),Qg=[...im,Tg,vg,_g,yg,mg,Jg,Pg,Fg,Lg,jg,gg,bg,fg],$g=[...am,Dg],e_=[Ff,Xg,Yg],t_=[],n_=[],r_=[];u.handleByNamedList(s.WebGPUSystem,t_),u.handleByNamedList(s.WebGPUPipes,n_),u.handleByNamedList(s.WebGPUPipesAdaptor,r_),u.add(...Qg,...$g,...e_);var i_=class extends Wi{constructor(){let e={name:`webgpu`,type:Wr.WEBGPU,systems:t_,renderPipes:n_,renderPipeAdaptors:r_};super(e)}},a_=e({BitmapFont:()=>o_}),o_=class extends bf{constructor(e,t){super();let{textures:n,data:r}=e;Object.keys(r.pages).forEach(e=>{let t=n[r.pages[parseInt(e,10)].id];this.pages.push({texture:t})}),Object.keys(r.chars).forEach(e=>{let t=r.chars[e],{frame:i,source:a,rotate:o}=n[t.page],s=new R({frame:j.transformRectCoords(t,i,o,new M),orig:new M(0,0,t.width,t.height),source:a,rotate:o});this.chars[e]={id:e.codePointAt(0),xOffset:t.xOffset,yOffset:t.yOffset,xAdvance:t.xAdvance,kerning:t.kerning??{},texture:s}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:`none`,range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){kf.install(e)}static uninstall(e){kf.uninstall(e)}};u.add(d,f),u.add(ir),u.mixin(It,ar),u.add(Rl),u.add(Xl),u.mixin(It,Zl),u.add(ju,cu),u.add(Ou);var s_=e({}),c_=e({});export{Wu as a,Il as c,It as d,R as f,o as h,hd as i,ra as l,v as m,yf as n,wu as o,M as p,uf as r,bu as s,Pp as t,Rt as u};
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
to { opacity: 1; transform: translate(-50%, -50%); }
|
|
27
27
|
}
|
|
28
28
|
</style>
|
|
29
|
-
<script type="module" crossorigin src="./_client/index-
|
|
29
|
+
<script type="module" crossorigin src="./_client/index-DheecpH5.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="./_client/rolldown-runtime-QTnfLwEv.js">
|
|
31
|
-
<link rel="modulepreload" crossorigin href="./_client/vendor-pixi-
|
|
31
|
+
<link rel="modulepreload" crossorigin href="./_client/vendor-pixi-DCKL8Yf2.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="./_client/vendor-codemirror-B_kaIH0M.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="./_client/decompress-DIM550rx.js">
|
|
34
34
|
</head>
|
|
@@ -11,25 +11,97 @@
|
|
|
11
11
|
},
|
|
12
12
|
"controller/segment":
|
|
13
13
|
{
|
|
14
|
-
"frame": {"x":
|
|
15
|
-
"rotated":
|
|
14
|
+
"frame": {"x":335,"y":391,"w":158,"h":74},
|
|
15
|
+
"rotated": false,
|
|
16
16
|
"trimmed": true,
|
|
17
17
|
"spriteSourceSize": {"x":221,"y":86,"w":158,"h":74},
|
|
18
18
|
"sourceSize": {"w":600,"h":600},
|
|
19
19
|
"anchor": {"x":0.5,"y":0.5}
|
|
20
20
|
},
|
|
21
|
-
"
|
|
21
|
+
"deposit/biomass/fill":
|
|
22
|
+
{
|
|
23
|
+
"frame": {"x":433,"y":131,"w":122,"h":111},
|
|
24
|
+
"rotated": true,
|
|
25
|
+
"trimmed": true,
|
|
26
|
+
"spriteSourceSize": {"x":3,"y":12,"w":122,"h":111},
|
|
27
|
+
"sourceSize": {"w":128,"h":128},
|
|
28
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
29
|
+
},
|
|
30
|
+
"deposit/biomass/shape":
|
|
31
|
+
{
|
|
32
|
+
"frame": {"x":303,"y":1,"w":128,"h":128},
|
|
33
|
+
"rotated": false,
|
|
34
|
+
"trimmed": false,
|
|
35
|
+
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
|
|
36
|
+
"sourceSize": {"w":128,"h":128},
|
|
37
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
38
|
+
},
|
|
39
|
+
"deposit/metal/fill":
|
|
40
|
+
{
|
|
41
|
+
"frame": {"x":546,"y":131,"w":105,"h":118},
|
|
42
|
+
"rotated": false,
|
|
43
|
+
"trimmed": true,
|
|
44
|
+
"spriteSourceSize": {"x":9,"y":7,"w":105,"h":118},
|
|
45
|
+
"sourceSize": {"w":128,"h":128},
|
|
46
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
47
|
+
},
|
|
48
|
+
"deposit/metal/shape":
|
|
49
|
+
{
|
|
50
|
+
"frame": {"x":303,"y":131,"w":128,"h":128},
|
|
51
|
+
"rotated": false,
|
|
52
|
+
"trimmed": false,
|
|
53
|
+
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
|
|
54
|
+
"sourceSize": {"w":128,"h":128},
|
|
55
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
56
|
+
},
|
|
57
|
+
"deposit/mist/fill":
|
|
22
58
|
{
|
|
23
|
-
"frame": {"x":
|
|
59
|
+
"frame": {"x":465,"y":255,"w":124,"h":106},
|
|
60
|
+
"rotated": true,
|
|
61
|
+
"trimmed": true,
|
|
62
|
+
"spriteSourceSize": {"x":2,"y":2,"w":124,"h":106},
|
|
63
|
+
"sourceSize": {"w":128,"h":128},
|
|
64
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
65
|
+
},
|
|
66
|
+
"deposit/mist/shape":
|
|
67
|
+
{
|
|
68
|
+
"frame": {"x":335,"y":261,"w":128,"h":128},
|
|
69
|
+
"rotated": false,
|
|
70
|
+
"trimmed": false,
|
|
71
|
+
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
|
|
72
|
+
"sourceSize": {"w":128,"h":128},
|
|
73
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
74
|
+
},
|
|
75
|
+
"deposit/silicon/fill":
|
|
76
|
+
{
|
|
77
|
+
"frame": {"x":563,"y":1,"w":94,"h":94},
|
|
24
78
|
"rotated": false,
|
|
25
79
|
"trimmed": true,
|
|
80
|
+
"spriteSourceSize": {"x":17,"y":17,"w":94,"h":94},
|
|
81
|
+
"sourceSize": {"w":128,"h":128},
|
|
82
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
83
|
+
},
|
|
84
|
+
"deposit/silicon/shape":
|
|
85
|
+
{
|
|
86
|
+
"frame": {"x":433,"y":1,"w":128,"h":128},
|
|
87
|
+
"rotated": false,
|
|
88
|
+
"trimmed": false,
|
|
89
|
+
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
|
|
90
|
+
"sourceSize": {"w":128,"h":128},
|
|
91
|
+
"anchor": {"x":0.5,"y":0.5}
|
|
92
|
+
},
|
|
93
|
+
"flag/main":
|
|
94
|
+
{
|
|
95
|
+
"frame": {"x":495,"y":381,"w":73,"h":68},
|
|
96
|
+
"rotated": true,
|
|
97
|
+
"trimmed": true,
|
|
26
98
|
"spriteSourceSize": {"x":78,"y":36,"w":73,"h":68},
|
|
27
99
|
"sourceSize": {"w":200,"h":200},
|
|
28
100
|
"anchor": {"x":0.5,"y":0.5}
|
|
29
101
|
},
|
|
30
102
|
"flag/second":
|
|
31
103
|
{
|
|
32
|
-
"frame": {"x":
|
|
104
|
+
"frame": {"x":303,"y":261,"w":34,"h":28},
|
|
33
105
|
"rotated": true,
|
|
34
106
|
"trimmed": true,
|
|
35
107
|
"spriteSourceSize": {"x":114,"y":48,"w":34,"h":28},
|
|
@@ -38,8 +110,8 @@
|
|
|
38
110
|
},
|
|
39
111
|
"grave/cross":
|
|
40
112
|
{
|
|
41
|
-
"frame": {"x":
|
|
42
|
-
"rotated":
|
|
113
|
+
"frame": {"x":573,"y":251,"w":59,"h":58},
|
|
114
|
+
"rotated": false,
|
|
43
115
|
"trimmed": true,
|
|
44
116
|
"spriteSourceSize": {"x":72,"y":76,"w":59,"h":58},
|
|
45
117
|
"sourceSize": {"w":200,"h":200},
|
|
@@ -56,7 +128,7 @@
|
|
|
56
128
|
},
|
|
57
129
|
"storage/fill":
|
|
58
130
|
{
|
|
59
|
-
"frame": {"x":
|
|
131
|
+
"frame": {"x":565,"y":381,"w":60,"h":70},
|
|
60
132
|
"rotated": false,
|
|
61
133
|
"trimmed": true,
|
|
62
134
|
"spriteSourceSize": {"x":20,"y":15,"w":60,"h":70},
|
|
@@ -75,10 +147,10 @@
|
|
|
75
147
|
"meta": {
|
|
76
148
|
"app": "https://www.codeandweb.com/texturepacker",
|
|
77
149
|
"version": "1.1",
|
|
78
|
-
"image": "test.png?v=
|
|
150
|
+
"image": "test.png?v=cd1588b54550",
|
|
79
151
|
"format": "RGBA8888",
|
|
80
|
-
"size": {"w":
|
|
152
|
+
"size": {"w":658,"h":470},
|
|
81
153
|
"scale": "1",
|
|
82
|
-
"smartupdate": "$TexturePacker:SmartUpdate:
|
|
154
|
+
"smartupdate": "$TexturePacker:SmartUpdate:5ca3b888cb2bec40dde14ac167ebcbe8:4aa9c9364074cd1d708dcccced50ab92:02ab132358d6d8b512e80119463a8329$"
|
|
83
155
|
}
|
|
84
156
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as e,h as t,w as n,y as r}from"./vendor-codemirror-B_kaIH0M.js";import{S as i,a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,x}from"./index-DDx5QnXZ.js";var S=x(`<div style=width:100%;height:100%;position:relative><canvas style=display:block>`),{log:C,error:w}=l(`map`);function T(l){let x,T=null,[E,D]=r([]),[O,k]=r(1),[A,j]=r(l.originRoom??null),M=null,N=null,P=new Map,F=new Map,I=new Map,L=new Map,R=e=>{let t=u();if(!t)return!0;let n=o(e);return!!n&&v(n.x,n.y,t)},z=e=>{let t=F.get(e);return{room:e,owner:t?.username??(t?.own?.user?`user:${t.own.user}`:null),mineral:t?.mineral??null,density:t?.density??null}},B=[],V=null,H=()=>{V=null;let e=c();if(!e||!T)return;let t=new Set(E());if(B=B.filter(e=>t.has(e)&&!T.hasRoom(e)),B.length===0)return;let n=B.splice(0,200);e.stores.room.terrainBulk(n,l.shard).then(e=>{for(let[t,n]of e){T?.setRoomTerrain(t,n);let e=I.get(t);e!==void 0&&T?.setRoomOwned(t,e)}for(let t of n)e.has(t)||T?.markRoomFetched(t)}).catch(e=>w(`terrain fetch failed:`,e)).finally(()=>{B.length>0&&(V=setTimeout(H,0))})};return t(()=>{c(),l.shard,F.clear(),I.clear()}),e(()=>{x&&(async()=>{if(T=new y({onRoomHover:e=>{l.onHoveredRoomChanged?.(e?z(e):null)},onRoomClick:e=>{A()===e?R(e)&&setTimeout(()=>l.onNavigateToRoom(e),0):(j(e),T?.setSelectedRoom(e),l.onSelectedRoomChanged?.(z(e)))},onVisibleRoomsChanged:e=>{let t=e.length===0;N!==t&&(N=t,C(t?`zoom out — too many rooms visible, terrain loading paused`:`zoom in — terrain loading active, ${e.length} rooms visible`)),D(e)},onZoomChanged:e=>{k(e),l.onZoomChanged?.(e)}}),await T.init(x),!T)return;l.initialZoom!==void 0&&l.initialZoom>0&&T.setZoom(l.initialZoom),l.onZoomChanged?.(T.zoom);let e=u();if(e&&T.setBounds(e.minX,e.maxX,e.minY,e.maxY),l.originRoom){let e=o(l.originRoom);e&&T.centerOn(e.x,e.y),T.setSelectedRoom(l.originRoom),l.onSelectedRoomChanged?.(z(l.originRoom))}else{let e=c();if(e)try{let t=await e.http.user.worldStartRoom(l.shard??`shard0`);if(!T)return;let n=Array.isArray(t?.room)?t.room[0]:t?.room;if(typeof n==`string`){let e=o(n);e&&T.centerOn(e.x,e.y)}}catch(e){w(`worldStartRoom failed:`,e)}}})()}),n(()=>{V!==null&&(clearTimeout(V),V=null),B=[];for(let e of P.values())e.dispose();P.clear(),T?.destroy(),T=null}),t(()=>{_({currentRoom:A,worldBounds:u,onMove:(e,t)=>{let n=d(e,t);j(n),T?.setSelectedRoom(n),T?.centerOn(e,t,!0),l.onSelectedRoomChanged?.(z(n)),l.onHoveredRoomChanged?.(z(n))}});let e=e=>{let t=e.target?.tagName??``,n=e.target?.isContentEditable??!1;if(!(t===`INPUT`||t===`TEXTAREA`||n)&&e.key===`m`){let e=A();e&&R(e)&&l.onNavigateToRoom(e)}};window.addEventListener(`keydown`,e),n(()=>window.removeEventListener(`keydown`,e))}),t(()=>{let e=c(),t=E(),n=l.shard;if(!e||t.length===0)return;let r=new Set(t),i=t.filter(e=>!T?.hasRoom(e));if(i.length>0){let e=t.reduce((e,t)=>e+(o(t)?.x??0),0)/t.length,n=t.reduce((e,t)=>e+(o(t)?.y??0),0)/t.length;B=i.slice().sort((t,r)=>{let i=o(t),a=o(r);return(i?Math.abs(i.x-e)+Math.abs(i.y-n):999)-(a?Math.abs(a.x-e)+Math.abs(a.y-n):999)}),V===null&&(V=setTimeout(H,0))}e.stores.mapStats.request(t,`owner0`,n??void 0);let a=O()>=.4;if(a!==M&&(M=a,l.onSubscriptionStateChanged?.(a),a||T?.clearAllMap2()),a){let r=new Set(t.map(e=>`${e}/${n}`));for(let[e,t]of P)r.has(e)||(t.dispose(),P.delete(e),T?.clearRoomMap2(e.split(`/`)[0]));for(let r of t){let t=`${r}/${n}`;P.has(t)||P.set(t,e.stores.map.subscribeMap2(r,n))}}else{for(let[,e]of P)e.dispose();P.clear()}T?.clearInvisibleRooms(r)}),t(()=>{T?.setShowRoomNames(f()),T&&(T.currentShard=l.shard??`shard0`)}),t(()=>{T?.setUnclaimableOverlayVisible(s())}),t(()=>{T?.setMapVisualVisible(b())}),t(()=>{T?.setOverlayMode(m())}),t(()=>{let e=c(),t=l.shard;e&&e.stores.server.worldInfo(t??void 0).then(e=>{C(`worldInfo(shard=${t??`none`}) — x: [${e.minX}, ${e.maxX}] y: [${e.minY}, ${e.maxY}]`),g(e)}).catch(e=>{C(`worldInfo(shard=${t??`none`}) failed:`,e)})}),t(()=>{T?.setCurrentUser(p()?._id??null)}),t(()=>{let e=u();e?(T?.setBounds(e.minX,e.maxX,e.minY,e.maxY),C(`worldBounds applied — shard: ${l.shard??`none`} x: [${e.minX}, ${e.maxX}] y: [${e.minY}, ${e.maxY}] (fetched for shard: ${e.shard??`none`})`)):(T?.clearBounds(),C(`worldBounds — none (shard: ${l.shard??`none`})`))}),t(()=>{let e=c();if(!e)return;let t=e.stores.user.subscribeMapVisual(l.shard),r=e.stores.user.on(`user:mapVisual`,({shard:e,data:t})=>{e===l.shard&&(t?T?.setMapVisual(t):T?.clearMapVisual())});n(()=>{t.dispose(),r.dispose()})}),t(()=>{let e=c();if(!e)return;let t=e.stores.map.on(`room:map2update`,({room:e,shard:t,data:n,source:r})=>{t===l.shard&&T?.setRoomMap2(e,n,r)});n(()=>t.dispose())}),t(()=>{let e=c();if(!e)return;let t=p()?._id,r=new Set(E()),i=e.stores.mapStats.on(`mapStats:room`,({room:e,stat:n})=>{F.set(e,n);let i=o(e),s=i?a(i.x,i.y)||h(i.x,i.y):!1,c=n.status===`out of borders`,u=!!(n.own&&n.own.user===t),d=!!(n.own&&n.own.user!==t),f=u?`own`:s||c||d?`other`:`none`;I.set(e,f),r.has(e)&&(T?.setRoomOwned(e,f),T?.setRoomSafeMode(e,!!n.safeMode)),T?.setRoomMineral(e,n.mineral,n.density);let p=n.badge?JSON.stringify(n.badge):``;L.get(e)!==p&&(L.set(e,p),T?.setRoomBadge(e,n.badge,n.own?.level)),A()===e&&l.onSelectedRoomChanged?.(z(e))});n(()=>i.dispose())}),(()=>{var e=S(),t=e.firstChild;return i(e=>x=e,t),e})()}export{T as MapViewer};
|