@riddix/hamh 2.1.0-alpha.404 → 2.1.0-alpha.405
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/backend/cli.js
CHANGED
|
@@ -172142,6 +172142,7 @@ function parseRoomData(roomsData) {
|
|
|
172142
172142
|
const nestedRooms = parseRoomData(value);
|
|
172143
172143
|
const floorIndex = floorCounter++;
|
|
172144
172144
|
for (const room of nestedRooms) {
|
|
172145
|
+
room.mapName = key;
|
|
172145
172146
|
if (typeof room.id === "number") {
|
|
172146
172147
|
room.originalId = room.id;
|
|
172147
172148
|
room.id = floorIndex * 1e4 + room.id;
|
|
@@ -172329,6 +172330,63 @@ function ServiceAreaServer2(initialState) {
|
|
|
172329
172330
|
currentArea: initialState.currentArea ?? null
|
|
172330
172331
|
});
|
|
172331
172332
|
}
|
|
172333
|
+
var ServiceAreaWithMaps = ServiceAreaBehavior.with(ServiceArea3.Feature.Maps);
|
|
172334
|
+
var ServiceAreaServerWithMapsBase = class extends ServiceAreaWithMaps {
|
|
172335
|
+
selectAreas(request) {
|
|
172336
|
+
const { newAreas } = request;
|
|
172337
|
+
logger179.info(
|
|
172338
|
+
`ServiceArea selectAreas called with: ${JSON.stringify(newAreas)}`
|
|
172339
|
+
);
|
|
172340
|
+
const uniqueAreas = [...new Set(newAreas)];
|
|
172341
|
+
const supportedAreaIds = this.state.supportedAreas.map((a) => a.areaId);
|
|
172342
|
+
const invalidAreas = uniqueAreas.filter(
|
|
172343
|
+
(id) => !supportedAreaIds.includes(id)
|
|
172344
|
+
);
|
|
172345
|
+
if (invalidAreas.length > 0) {
|
|
172346
|
+
logger179.warn(`Invalid area IDs requested: ${invalidAreas.join(", ")}`);
|
|
172347
|
+
return {
|
|
172348
|
+
status: ServiceArea3.SelectAreasStatus.UnsupportedArea,
|
|
172349
|
+
statusText: `Invalid area IDs: ${invalidAreas.join(", ")}`
|
|
172350
|
+
};
|
|
172351
|
+
}
|
|
172352
|
+
this.state.selectedAreas = uniqueAreas;
|
|
172353
|
+
logger179.info(
|
|
172354
|
+
`ServiceArea: Stored ${uniqueAreas.length} areas for cleaning: ${uniqueAreas.join(", ")}`
|
|
172355
|
+
);
|
|
172356
|
+
return {
|
|
172357
|
+
status: ServiceArea3.SelectAreasStatus.Success,
|
|
172358
|
+
statusText: "Areas selected for cleaning"
|
|
172359
|
+
};
|
|
172360
|
+
}
|
|
172361
|
+
skipArea(_request) {
|
|
172362
|
+
return {
|
|
172363
|
+
status: ServiceArea3.SkipAreaStatus.InvalidInMode,
|
|
172364
|
+
statusText: "Skip area not supported"
|
|
172365
|
+
};
|
|
172366
|
+
}
|
|
172367
|
+
};
|
|
172368
|
+
((ServiceAreaServerWithMapsBase2) => {
|
|
172369
|
+
class State extends ServiceAreaWithMaps.State {
|
|
172370
|
+
}
|
|
172371
|
+
ServiceAreaServerWithMapsBase2.State = State;
|
|
172372
|
+
})(ServiceAreaServerWithMapsBase || (ServiceAreaServerWithMapsBase = {}));
|
|
172373
|
+
function ServiceAreaServerWithMaps(initialState) {
|
|
172374
|
+
logger179.info(
|
|
172375
|
+
`Creating ServiceAreaServer with Maps: ${initialState.supportedAreas.length} areas, ${initialState.supportedMaps.length} maps`
|
|
172376
|
+
);
|
|
172377
|
+
for (const map of initialState.supportedMaps) {
|
|
172378
|
+
const areaCount = initialState.supportedAreas.filter(
|
|
172379
|
+
(a) => a.mapId === map.mapId
|
|
172380
|
+
).length;
|
|
172381
|
+
logger179.info(` Map ${map.mapId}: "${map.name}" (${areaCount} areas)`);
|
|
172382
|
+
}
|
|
172383
|
+
return ServiceAreaServerWithMapsBase.set({
|
|
172384
|
+
supportedAreas: initialState.supportedAreas,
|
|
172385
|
+
supportedMaps: initialState.supportedMaps,
|
|
172386
|
+
selectedAreas: initialState.selectedAreas ?? [],
|
|
172387
|
+
currentArea: initialState.currentArea ?? null
|
|
172388
|
+
});
|
|
172389
|
+
}
|
|
172332
172390
|
|
|
172333
172391
|
// src/matter/endpoints/legacy/vacuum/behaviors/vacuum-service-area-server.ts
|
|
172334
172392
|
var logger180 = Logger.get("VacuumServiceAreaServer");
|
|
@@ -172344,10 +172402,23 @@ function toAreaId(roomId) {
|
|
|
172344
172402
|
}
|
|
172345
172403
|
return Math.abs(hash2);
|
|
172346
172404
|
}
|
|
172347
|
-
function
|
|
172405
|
+
function extractMaps(rooms) {
|
|
172406
|
+
const seen = /* @__PURE__ */ new Map();
|
|
172407
|
+
for (const room of rooms) {
|
|
172408
|
+
if (room.mapName && !seen.has(room.mapName)) {
|
|
172409
|
+
seen.set(room.mapName, seen.size + 1);
|
|
172410
|
+
}
|
|
172411
|
+
}
|
|
172412
|
+
return Array.from(seen.entries()).map(([name, mapId]) => ({ mapId, name }));
|
|
172413
|
+
}
|
|
172414
|
+
function roomsToAreas(rooms, maps = []) {
|
|
172415
|
+
const mapLookup = /* @__PURE__ */ new Map();
|
|
172416
|
+
for (const m of maps) {
|
|
172417
|
+
mapLookup.set(m.name, m.mapId);
|
|
172418
|
+
}
|
|
172348
172419
|
return rooms.map((room) => ({
|
|
172349
172420
|
areaId: toAreaId(room.id),
|
|
172350
|
-
mapId: null,
|
|
172421
|
+
mapId: room.mapName ? mapLookup.get(room.mapName) ?? null : null,
|
|
172351
172422
|
areaInfo: {
|
|
172352
172423
|
locationInfo: {
|
|
172353
172424
|
locationName: room.name,
|
|
@@ -172408,7 +172479,16 @@ function createVacuumServiceAreaServer(attributes7, roomEntities, includeUnnamed
|
|
|
172408
172479
|
);
|
|
172409
172480
|
}
|
|
172410
172481
|
}
|
|
172411
|
-
const
|
|
172482
|
+
const maps = extractMaps(rooms);
|
|
172483
|
+
const supportedAreas = roomsToAreas(rooms, maps);
|
|
172484
|
+
if (maps.length > 0) {
|
|
172485
|
+
return ServiceAreaServerWithMaps({
|
|
172486
|
+
supportedAreas,
|
|
172487
|
+
supportedMaps: maps,
|
|
172488
|
+
selectedAreas: [],
|
|
172489
|
+
currentArea: null
|
|
172490
|
+
});
|
|
172491
|
+
}
|
|
172412
172492
|
return ServiceAreaServer2({
|
|
172413
172493
|
supportedAreas,
|
|
172414
172494
|
selectedAreas: [],
|