@ray-js/robot-map-sdk 0.0.3-beta-5 → 0.0.3-beta-7

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.
Files changed (31) hide show
  1. package/dist/application/Interaction.js +1 -1
  2. package/dist/components/Base/Ring.js +1 -1
  3. package/dist/components/Map/Free.js +1 -1
  4. package/dist/components/Map/Obstacle.js +1 -1
  5. package/dist/index.d.ts +7 -1
  6. package/dist/index.rjs.js +1 -1
  7. package/dist/managers/MapManager.js +1 -1
  8. package/dist/managers/RoomManager.js +1 -1
  9. package/dist-app/assets/{index-Cnc23j8F.js → index-rWbtFkbX.js} +1 -1
  10. package/dist-app/index.html +1 -1
  11. package/dist-docs/404.html +2 -2
  12. package/dist-docs/assets/{app.DRu3YfJm.js → app.C8maVmzs.js} +1 -1
  13. package/dist-docs/assets/chunks/@localSearchIndexroot.BEPmfEXB.js +1 -0
  14. package/dist-docs/assets/chunks/{VPLocalSearchBox.rCdV2UMG.js → VPLocalSearchBox.dmVujmrV.js} +1 -1
  15. package/dist-docs/assets/chunks/{theme.CKuAZ0Ki.js → theme.BkasJq65.js} +2 -2
  16. package/dist-docs/assets/{guide_getting-started.md.Bn2rTf61.js → guide_getting-started.md.CSvzbjhl.js} +1 -1
  17. package/dist-docs/guide/advanced-usage.html +4 -4
  18. package/dist-docs/guide/concepts.html +3 -3
  19. package/dist-docs/guide/getting-started.html +5 -5
  20. package/dist-docs/hashmap.json +1 -1
  21. package/dist-docs/index.html +3 -3
  22. package/dist-docs/reference/callbacks.html +4 -4
  23. package/dist-docs/reference/config.html +4 -4
  24. package/dist-docs/reference/data.html +3 -3
  25. package/dist-docs/reference/methods.html +4 -4
  26. package/dist-docs/reference/runtime.html +4 -4
  27. package/dist-docs/reference/types.html +4 -4
  28. package/dist-docs/reference/utils.html +4 -4
  29. package/package.json +1 -1
  30. package/dist-docs/assets/chunks/@localSearchIndexroot.DYDlqEvf.js +0 -1
  31. /package/dist-docs/assets/{guide_getting-started.md.Bn2rTf61.lean.js → guide_getting-started.md.CSvzbjhl.lean.js} +0 -0
@@ -1 +1 @@
1
- import{isEqual as t}from"lodash-es";import{Logger as o}from"../utils/logger.js";import{Rectangle as e}from"pixi.js";import{calculateRasterMapBounds as s,generateOutlineData as a,calculateRoomCenterPoint as r,mergeBounds as i,calculateRasterRoomCenter as n}from"../utils/algorithm.js";import{Obstacle as m}from"../components/Map/Obstacle.js";import{Free as h}from"../components/Map/Free.js";import{RoomFill as c}from"../components/Map/RoomFill.js";import{Carpet as p}from"../components/Map/Carpet.js";import{ChargingStation as l}from"../components/ChargingStation/index.js";import{subscribeKey as u}from"valtio/vanilla/utils";import{SPECIAL_ROOM_IDS as d}from"@ray-js/robot-protocol";import{useAppService as g}from"../application/AppService.js";class f{obstacle=new m;free=new h;roomFill=new c;carpet=new p;chargingStation=new l;mapBounds={minX:0,minY:0,maxX:0,maxY:0};hasAutoFitted=!1;roomGeometryMap=new Map;carpetData=null;unsubscribeFns=[];constructor(){const t=g(),e=u(t.runtime,"enableRoomSelection",e=>{if(o.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const o=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(o)}else this.roomFill.setAllRoomsState(!0)}),s=u(t.runtime,"selectRoomIds",t=>{o.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),a=u(t.runtime,"showChargingStation",t=>{o.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),r=u(t.runtime,"showCarpet",t=>{o.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,s,a,r)}async drawMap(e){const s=g(),{obstacles:a,free:r,rooms:i,charger:n,carpet:m}=e;this.clearComponents(),this.resetGeometryData();const h=this.processRoomsGeometry(i);this.roomFill.draw(h),this.free.draw(r),this.obstacle.draw(a),this.carpetData={type:"structured",carpetData:m},this.createCarpet();const c=this.mergeLayerBounds();t(c,this.mapBounds)||(o.debug("[Map] Map bounds updated:",c),this.mapBounds=c,this.hasAutoFitted||(s.getApp().fitMapToView(this.mapBounds),this.hasAutoFitted=!0));const p=((e.charger.angle??0)+s.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:n.coordinate[0],y:n.coordinate[1],rotation:p}),s.roomsManager.refresh(),!0}async drawRasterMap(e,a){const r=g();this.clearComponents();const{width:i,height:n,charger:m,chargerDirection:h}=a;o.debug("[Map] Parsed Raster Map Data",e),this.obstacle.drawRaster(e.obstacles,i),this.carpetData={type:"raster",carpetPixels:e.carpet,mapWidth:i},this.createCarpet();const c=this.processRasterData(e);this.roomFill.drawRaster(c);const p=s(e,i,n);t(p,this.mapBounds)||(o.debug("[Map] Raster map bounds updated:",p),this.mapBounds=p,this.hasAutoFitted||(r.getApp().fitMapToView(this.mapBounds),this.hasAutoFitted=!0));const l=(h+r.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:m.x,y:m.y,rotation:l}),this.generateRoomGeometryFromRaster(e),r.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async createCarpet(){if(g().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:o}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,o)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const o=g(),{active:s}=o.roomConfig.colors,i=o.roomConfig.colors[d.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((t,o)=>Number(t)-Number(o)),m=n.filter(t=>Number(t)<255),h=n.filter(t=>Number(t)>=255),c=[];return m.forEach((o,i)=>{const{coordinates:n}=t[o];if(n.length<4)return;const m=Number(o),h=i%s.length,p=s[h];let l=1/0,u=1/0,d=-1/0,g=-1/0;const f=[];for(let t=0;t<n.length;t+=2){const o=n[t],e=n[t+1];l=Math.min(l,o),u=Math.min(u,e),d=Math.max(d,o),g=Math.max(g,e),f.push({x:o,y:e})}const y=new e(l,u,d-l+1,g-u+1),b=a(f),M=b.flatMap(t=>[t.x+.5,t.y+.5]),x={id:m,color:p,boundingBox:y,points:f,outlinePoints:b,polyPoints:M,centerPoint:r(b,l,u,d,g)};this.roomGeometryMap.set(m,x),c.push(x),this.mapBounds.minX=Math.min(this.mapBounds.minX,l),this.mapBounds.minY=Math.min(this.mapBounds.minY,u),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,d),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,g)}),h.forEach(o=>{const{coordinates:s}=t[o];if(s.length<4)return;const n=Number(o);let m=1/0,h=1/0,p=-1/0,l=-1/0;const u=[];for(let t=0;t<s.length;t+=2){const o=s[t],e=s[t+1];m=Math.min(m,o),h=Math.min(h,e),p=Math.max(p,o),l=Math.max(l,e),u.push({x:o,y:e})}const d=new e(m,h,p-m+1,l-h+1),g=a(u),f=g.flatMap(t=>[t.x+.5,t.y+.5]),y=r(g,m,h,p,l),b={id:n,color:i,boundingBox:d,points:u,outlinePoints:g,polyPoints:f,centerPoint:y};c.push(b),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,h),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,p),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),c}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=i(t,this.obstacle.bounds)),this.roomFill.children.length>0){const o=this.roomFill.getLocalBounds();o.width>0&&o.height>0&&(t=i(t,{minX:o.x,minY:o.y,maxX:o.x+o.width,maxY:o.y+o.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new m,this.free.clear(),this.free.destroy(),this.free=new h,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new c}processRasterData(t){const o=g().roomConfig,e=[],s=[];t.rooms.forEach((t,o)=>{"number"==typeof o?e.push([o,t]):s.push([o,t])}),e.sort(([t],[o])=>t-o);const a=[...e.map(([t,e],s)=>{const a=s%o.colors.active.length,r=s%o.colors.inactive.length;return{roomId:t,pixelIndices:e,activeColor:o.colors.active[a],inactiveColor:o.colors.inactive[r]}}),...s.map(([t,e])=>{const s=o.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:e,activeColor:s,inactiveColor:s}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:a,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const o=g();this.roomGeometryMap.clear();const{active:s}=o.roomConfig.colors,a=[];t.rooms.forEach((t,o)=>{"number"==typeof o&&a.push(o)}),a.sort((t,o)=>t-o),a.forEach((o,a)=>{const r=t.rooms.get(o);let i=1/0,m=1/0,h=-1/0,c=-1/0;for(let o=0;o<r.length;o++){const e=r[o],s=e%t.width,a=Math.floor(e/t.width);i=Math.min(i,s),m=Math.min(m,a),h=Math.max(h,s),c=Math.max(c,a)}const p=n(r,t.width,i,m,h,c),l=a%s.length,u={id:o,color:s[l],boundingBox:new e(i,m,h-i+1,c-m+1),points:[],outlinePoints:[],polyPoints:[],centerPoint:p};this.roomGeometryMap.set(o,u)})}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}export{f as MapManager};
1
+ import{isEqual as t}from"lodash-es";import{Logger as o}from"../utils/logger.js";import{Rectangle as e}from"pixi.js";import{calculateRasterMapBounds as s,generateOutlineData as a,calculateRoomCenterPoint as r,mergeBounds as i,calculateRasterRoomCenter as n}from"../utils/algorithm.js";import{Obstacle as m}from"../components/Map/Obstacle.js";import{Free as h}from"../components/Map/Free.js";import{RoomFill as c}from"../components/Map/RoomFill.js";import{Carpet as p}from"../components/Map/Carpet.js";import{ChargingStation as l}from"../components/ChargingStation/index.js";import{subscribeKey as d}from"valtio/vanilla/utils";import{SPECIAL_ROOM_IDS as u}from"@ray-js/robot-protocol";import{useAppService as g}from"../application/AppService.js";class f{obstacle=new m;free=new h;roomFill=new c;carpet=new p;chargingStation=new l;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;roomGeometryMap=new Map;carpetData=null;unsubscribeFns=[];constructor(){const t=g(),e=d(t.runtime,"enableRoomSelection",e=>{if(o.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const o=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(o)}else this.roomFill.setAllRoomsState(!0)}),s=d(t.runtime,"selectRoomIds",t=>{o.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),a=d(t.runtime,"showChargingStation",t=>{o.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),r=d(t.runtime,"showCarpet",t=>{o.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,s,a,r)}async drawMap(e){const s=g(),{id:a,obstacles:r,free:i,rooms:n,charger:m,carpet:h}=e;this.clearComponents(),this.resetGeometryData();const c=this.processRoomsGeometry(n);this.roomFill.draw(c),this.free.draw(i),this.obstacle.draw(r),this.carpetData={type:"structured",carpetData:h},this.createCarpet();const p=this.mergeLayerBounds();t(p,this.mapBounds)||(o.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.lastMapId!==a&&(s.getApp().fitMapToView(this.mapBounds),this.lastMapId=a));const l=((e.charger.angle??0)+s.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:m.coordinate[0],y:m.coordinate[1],rotation:l}),s.roomsManager.refresh(),!0}async drawRasterMap(e,a){const r=g();this.clearComponents();const{id:i,width:n,height:m,charger:h,chargerDirection:c}=a;o.debug("[Map] Parsed Raster Map Data",e),this.obstacle.drawRaster(e.obstacles,n),this.carpetData={type:"raster",carpetPixels:e.carpet,mapWidth:n},this.createCarpet();const p=this.processRasterData(e);this.roomFill.drawRaster(p);const l=s(e,n,m);t(l,this.mapBounds)||(o.debug("[Map] Raster map bounds updated:",l),this.mapBounds=l,this.lastMapId!==i&&(r.getApp().fitMapToView(this.mapBounds),this.lastMapId=i));const d=(c+r.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:h.x,y:h.y,rotation:d}),this.generateRoomGeometryFromRaster(e),r.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async createCarpet(){if(g().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:o}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,o)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const o=g(),{active:s}=o.roomConfig.colors,i=o.roomConfig.colors[u.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((t,o)=>Number(t)-Number(o)),m=n.filter(t=>Number(t)<255),h=n.filter(t=>Number(t)>=255),c=[];return m.forEach((o,i)=>{const{coordinates:n}=t[o];if(n.length<4)return;const m=Number(o),h=i%s.length,p=s[h];let l=1/0,d=1/0,u=-1/0,g=-1/0;const f=[];for(let t=0;t<n.length;t+=2){const o=n[t],e=n[t+1];l=Math.min(l,o),d=Math.min(d,e),u=Math.max(u,o),g=Math.max(g,e),f.push({x:o,y:e})}const M=new e(l,d,u-l+1,g-d+1),y=a(f),b=y.flatMap(t=>[t.x+.5,t.y+.5]),x={id:m,color:p,boundingBox:M,points:f,outlinePoints:y,polyPoints:b,centerPoint:r(y,l,d,u,g)};this.roomGeometryMap.set(m,x),c.push(x),this.mapBounds.minX=Math.min(this.mapBounds.minX,l),this.mapBounds.minY=Math.min(this.mapBounds.minY,d),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,u),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,g)}),h.forEach(o=>{const{coordinates:s}=t[o];if(s.length<4)return;const n=Number(o);let m=1/0,h=1/0,p=-1/0,l=-1/0;const d=[];for(let t=0;t<s.length;t+=2){const o=s[t],e=s[t+1];m=Math.min(m,o),h=Math.min(h,e),p=Math.max(p,o),l=Math.max(l,e),d.push({x:o,y:e})}const u=new e(m,h,p-m+1,l-h+1),g=a(d),f=g.flatMap(t=>[t.x+.5,t.y+.5]),M=r(g,m,h,p,l),y={id:n,color:i,boundingBox:u,points:d,outlinePoints:g,polyPoints:f,centerPoint:M};c.push(y),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,h),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,p),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),c}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=i(t,this.obstacle.bounds)),this.roomFill.children.length>0){const o=this.roomFill.getLocalBounds();o.width>0&&o.height>0&&(t=i(t,{minX:o.x,minY:o.y,maxX:o.x+o.width,maxY:o.y+o.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new m,this.free.clear(),this.free.destroy(),this.free=new h,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new c}processRasterData(t){const o=g().roomConfig,e=[],s=[];t.rooms.forEach((t,o)=>{"number"==typeof o?e.push([o,t]):s.push([o,t])}),e.sort(([t],[o])=>t-o);const a=[...e.map(([t,e],s)=>{const a=s%o.colors.active.length,r=s%o.colors.inactive.length;return{roomId:t,pixelIndices:e,activeColor:o.colors.active[a],inactiveColor:o.colors.inactive[r]}}),...s.map(([t,e])=>{const s=o.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:e,activeColor:s,inactiveColor:s}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:a,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const o=g();this.roomGeometryMap.clear();const{active:s}=o.roomConfig.colors,a=[];t.rooms.forEach((t,o)=>{"number"==typeof o&&a.push(o)}),a.sort((t,o)=>t-o),a.forEach((o,a)=>{const r=t.rooms.get(o);let i=1/0,m=1/0,h=-1/0,c=-1/0;for(let o=0;o<r.length;o++){const e=r[o],s=e%t.width,a=Math.floor(e/t.width);i=Math.min(i,s),m=Math.min(m,a),h=Math.max(h,s),c=Math.max(c,a)}const p=n(r,t.width,i,m,h,c),l=a%s.length,d={id:o,color:s[l],boundingBox:new e(i,m,h-i+1,c-m+1),points:[],outlinePoints:[],polyPoints:[],centerPoint:p};this.roomGeometryMap.set(o,d)})}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}export{f as MapManager};
@@ -1 +1 @@
1
- import{Container as o}from"pixi.js";import{LAYER_ROOM_INFO as t}from"../application/AppContainer.js";import{RoomInfo as i}from"../components/RoomInfo/index.js";import{RoomFloorType as e}from"../components/RoomFloorType/index.js";import{subscribeKey as r}from"valtio/vanilla/utils";import{Logger as s}from"../utils/logger.js";import{useAppService as n}from"../application/AppService.js";class a{unsubscribeFns=[];roomInfoContainer=new o;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new e;constructor(){const o=n();o.appContainer.addToLayer(t,this.roomInfoContainer);const i=r(o.runtime,"showRoomFloorType",o=>{s.log(`[runtime] showRoomFloorType: ${o}`),o?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),e=r(o.runtime,"showRoomProperty",o=>{s.log(`[runtime] showRoomProperty: ${o}`),this.updateAllRoomPropertyVisibility()}),a=r(o.runtime,"showRoomOrder",o=>{s.log(`[runtime] showRoomOrder: ${o}`),this.updateAllRoomPropertyVisibility()}),m=r(o.runtime,"roomPropertyFoldIds",o=>{s.log(`[runtime] roomPropertyFoldIds: ${o}`),this.updateAllRoomPropertyVisibility()}),l=r(o.runtime,"showRoomName",o=>{s.log(`[runtime] showRoomName: ${o}`),this.updateAllRoomNameVisibility(o)}),p=r(o.runtime,"enableRoomSelection",o=>{s.log(`[runtime] enableRoomSelection: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),c=r(o.runtime,"selectRoomIds",o=>{s.log(`[runtime] selectRoomIds: ${o}`),this.updateAllRoomSelectionIndicatorVisibility()}),h=r(o.runtime,"roomSelectionMode",o=>{s.log(`[runtime] roomSelectionMode: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(i,e,a,m,l,p,c,h)}drawRoomProperty(o){const t=n();return this.roomDisplayMap.clear(),o.forEach((o,i)=>{const e=t.mapManager.getRoomById(o.id),r={...o,centerPoint:e?.centerPoint||null,index:i};this.roomDisplayMap.set(o.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const o=Array.from(this.roomDisplayMap.values()).filter(o=>null!==o.centerPoint);this.clearRoomInfos(),o.forEach(o=>{this.createRoomInfo(o)})}createRoomInfo(o){const t=new i(o);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(o.id,t)}updateRoomName(o,t){const i=this.roomInfoMap.get(o);i&&i.updateName(t)}updateRoomPosition(o,t){const i=this.roomDisplayMap.get(o);i&&(i.centerPoint=t);const e=this.roomInfoMap.get(o);e&&e.updatePosition(t)}clearRoomInfos(){this.roomInfoMap.forEach(o=>{o.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(o){return this.roomDisplayMap.get(o)}refresh(){const o=n();this.roomDisplayMap.forEach((t,i)=>{const e=o.mapManager.getRoomById(i),r=e?.centerPoint||null;if(t.centerPoint!==r){t.centerPoint=r;const o=this.roomInfoMap.get(i);o&&r&&o.updatePosition(r)}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(o){this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(o)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const o=n(),t=o.mapManager.roomFill.getRoomGraphicsMap();t.size>0&&(await this.roomFloorType.createFloorTypes(t),o.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(o=>o()),this.unsubscribeFns=[]}}export{a as RoomManager};
1
+ import{Container as o}from"pixi.js";import{LAYER_ROOM_INFO as t}from"../application/AppContainer.js";import{RoomInfo as i}from"../components/RoomInfo/index.js";import{RoomFloorType as e}from"../components/RoomFloorType/index.js";import{subscribeKey as r}from"valtio/vanilla/utils";import{Logger as s}from"../utils/logger.js";import{useAppService as n}from"../application/AppService.js";class a{unsubscribeFns=[];roomInfoContainer=new o;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new e;constructor(){const o=n();o.appContainer.addToLayer(t,this.roomInfoContainer);const i=r(o.runtime,"showRoomFloorType",o=>{s.log(`[runtime] showRoomFloorType: ${o}`),o?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),e=r(o.runtime,"showRoomProperty",o=>{s.log(`[runtime] showRoomProperty: ${o}`),this.updateAllRoomPropertyVisibility()}),a=r(o.runtime,"showRoomOrder",o=>{s.log(`[runtime] showRoomOrder: ${o}`),this.updateAllRoomPropertyVisibility()}),m=r(o.runtime,"roomPropertyFoldIds",o=>{s.log(`[runtime] roomPropertyFoldIds: ${o}`),this.updateAllRoomPropertyVisibility()}),l=r(o.runtime,"showRoomName",o=>{s.log(`[runtime] showRoomName: ${o}`),this.updateAllRoomNameVisibility(o)}),p=r(o.runtime,"enableRoomSelection",o=>{s.log(`[runtime] enableRoomSelection: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),c=r(o.runtime,"selectRoomIds",o=>{s.log(`[runtime] selectRoomIds: ${o}`),this.updateAllRoomSelectionIndicatorVisibility()}),h=r(o.runtime,"roomSelectionMode",o=>{s.log(`[runtime] roomSelectionMode: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(i,e,a,m,l,p,c,h)}drawRoomProperty(o){const t=n();return this.roomDisplayMap.clear(),o.forEach((o,i)=>{const e=t.mapManager.getRoomById(o.id),r={...o,centerPoint:e?.centerPoint||null,index:i};this.roomDisplayMap.set(o.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const o=Array.from(this.roomDisplayMap.values()).filter(o=>null!==o.centerPoint);this.clearRoomInfos(),o.forEach(o=>{this.createRoomInfo(o)})}createRoomInfo(o){const t=new i(o);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(o.id,t)}updateRoomName(o,t){const i=this.roomInfoMap.get(o);i&&i.updateName(t)}updateRoomPosition(o,t){const i=this.roomDisplayMap.get(o);i&&(i.centerPoint=t);const e=this.roomInfoMap.get(o);e&&e.updatePosition(t)}clearRoomInfos(){this.roomInfoMap.forEach(o=>{o.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(o){return this.roomDisplayMap.get(o)}refresh(){const o=n();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((t,i)=>{const e=o.mapManager.getRoomById(i),r=e?.centerPoint||null;if(t.centerPoint!==r){t.centerPoint=r;const o=this.roomInfoMap.get(i);o&&r&&o.updatePosition(r)}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(o){this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(o)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const o=n(),t=o.mapManager.roomFill.getRoomGraphicsMap();t.size>0&&(await this.roomFloorType.createFloorTypes(t),o.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(o=>o()),this.unsubscribeFns=[]}}export{a as RoomManager};