floor-editor-ts 1.3.10 → 1.3.11

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.
@@ -70912,10 +70912,31 @@ var lastRejectedKey = "";
70912
70912
  * (host may load a saved floor without passing assignedCameras).
70913
70913
  */
70914
70914
  var lastSyncedSerials = /* @__PURE__ */ new Set();
70915
+ /** Skip mutate when host assignment + floor cameras/zones already match. */
70916
+ var lastAppliedFingerprint = "";
70915
70917
  /** Call when host replaces floorData so load doesn't fight a stale sync set. */
70916
70918
  function resetAssignedCamerasSyncState() {
70917
70919
  lastSyncedSerials = /* @__PURE__ */ new Set();
70918
70920
  lastRejectedKey = "";
70921
+ lastAppliedFingerprint = "";
70922
+ }
70923
+ function assignmentFingerprint(assigned, floor) {
70924
+ var _floor$zones, _floor$walls$length, _floor$walls;
70925
+ const cams = getCameraFurniture(floor).map((f) => {
70926
+ var _f$props, _f$serial, _f$name;
70927
+ const props = (_f$props = f.props) !== null && _f$props !== void 0 ? _f$props : {};
70928
+ const keys = Object.keys(props).sort();
70929
+ return `${(_f$serial = f.serial) !== null && _f$serial !== void 0 ? _f$serial : ""}:${(_f$name = f.name) !== null && _f$name !== void 0 ? _f$name : ""}:${keys.map((k) => `${k}=${props[k]}`).join(",")}`;
70930
+ }).sort().join(";");
70931
+ const zones = ((_floor$zones = floor.zones) !== null && _floor$zones !== void 0 ? _floor$zones : []).map((z) => {
70932
+ var _z$cameraSerial, _z$points$length, _z$points;
70933
+ return `${(_z$cameraSerial = z.cameraSerial) !== null && _z$cameraSerial !== void 0 ? _z$cameraSerial : ""}:${z.name}:${z.color}:${(_z$points$length = (_z$points = z.points) === null || _z$points === void 0 ? void 0 : _z$points.length) !== null && _z$points$length !== void 0 ? _z$points$length : 0}`;
70934
+ }).sort().join(";");
70935
+ const host = assigned.map((c) => Object.keys(c).sort().map((k) => {
70936
+ var _c$k;
70937
+ return `${k}=${String((_c$k = c[k]) !== null && _c$k !== void 0 ? _c$k : "")}`;
70938
+ }).join("&")).sort().join("|");
70939
+ return `${floor.id}|w${(_floor$walls$length = (_floor$walls = floor.walls) === null || _floor$walls === void 0 ? void 0 : _floor$walls.length) !== null && _floor$walls$length !== void 0 ? _floor$walls$length : 0}|${host}|${cams}|${zones}`;
70919
70940
  }
70920
70941
  function getCameraFurniture(floor) {
70921
70942
  return floor.furniture.filter((f) => f.catalogId === "camera");
@@ -70980,17 +71001,18 @@ function applyCameraProps(id, cam) {
70980
71001
  * - If floor has no walls, rejects adds and emits camerasRejected
70981
71002
  */
70982
71003
  function syncAssignedCameras(assigned) {
70983
- var _floor$walls$length, _floor$walls;
71004
+ var _floor$walls$length2, _floor$walls2;
70984
71005
  const floor = get$1(activeFloor);
70985
71006
  const project = get$1(currentProject);
70986
71007
  if (!floor || !project) return;
70987
71008
  const normalized = assigned.filter((c) => c && typeof c.serial === "string" && String(c.serial).trim());
71009
+ if (assignmentFingerprint(normalized, floor) === lastAppliedFingerprint) return;
70988
71010
  const assignedBySerial = new Map(normalized.map((c) => [String(c.serial).trim(), c]));
70989
71011
  const existing = getCameraFurniture(floor);
70990
71012
  const existingBySerial = /* @__PURE__ */ new Map();
70991
71013
  for (const item of existing) if (item.serial) existingBySerial.set(item.serial, item);
70992
71014
  const toAdd = normalized.filter((c) => !existingBySerial.has(String(c.serial).trim()));
70993
- const hasFloorLayout = ((_floor$walls$length = (_floor$walls = floor.walls) === null || _floor$walls === void 0 ? void 0 : _floor$walls.length) !== null && _floor$walls$length !== void 0 ? _floor$walls$length : 0) > 0;
71015
+ const hasFloorLayout = ((_floor$walls$length2 = (_floor$walls2 = floor.walls) === null || _floor$walls2 === void 0 ? void 0 : _floor$walls2.length) !== null && _floor$walls$length2 !== void 0 ? _floor$walls$length2 : 0) > 0;
70994
71016
  function rejectNoFloor(cameras) {
70995
71017
  if (cameras.length === 0) return;
70996
71018
  const key = cameras.map((c) => String(c.serial).trim()).sort().join(",");
@@ -71023,6 +71045,8 @@ function syncAssignedCameras(assigned) {
71023
71045
  if (!hasFloorLayout) {
71024
71046
  syncZonesFromAssigned(assignedBySerial, hostDrivesAssignment);
71025
71047
  if (hostDrivesAssignment || newSerials.size > 0) lastSyncedSerials = newSerials;
71048
+ const f = get$1(activeFloor);
71049
+ if (f) lastAppliedFingerprint = assignmentFingerprint(normalized, f);
71026
71050
  return;
71027
71051
  }
71028
71052
  const center = getFloorCenter(floorAfterRemove);
@@ -71030,6 +71054,8 @@ function syncAssignedCameras(assigned) {
71030
71054
  rejectNoFloor(toAdd);
71031
71055
  syncZonesFromAssigned(assignedBySerial, hostDrivesAssignment);
71032
71056
  if (hostDrivesAssignment || newSerials.size > 0) lastSyncedSerials = newSerials;
71057
+ const f = get$1(activeFloor);
71058
+ if (f) lastAppliedFingerprint = assignmentFingerprint(normalized, f);
71033
71059
  return;
71034
71060
  }
71035
71061
  lastRejectedKey = "";
@@ -71042,16 +71068,18 @@ function syncAssignedCameras(assigned) {
71042
71068
  }
71043
71069
  syncZonesFromAssigned(assignedBySerial, hostDrivesAssignment);
71044
71070
  lastSyncedSerials = newSerials;
71071
+ const floorDone = get$1(activeFloor);
71072
+ if (floorDone) lastAppliedFingerprint = assignmentFingerprint(normalized, floorDone);
71045
71073
  } finally {
71046
71074
  setAssignedCamerasSyncing(false);
71047
71075
  }
71048
71076
  }
71049
71077
  /** Push area / areaColor onto linked zones; remove areas whose camera was unassigned. */
71050
71078
  function syncZonesFromAssigned(assignedBySerial, hostDrivesAssignment) {
71051
- var _floor$zones, _floor2$zones;
71079
+ var _floor$zones2, _floor2$zones;
71052
71080
  const floor = get$1(activeFloor);
71053
71081
  if (!floor) return;
71054
- if (hostDrivesAssignment && ((_floor$zones = floor.zones) === null || _floor$zones === void 0 ? void 0 : _floor$zones.length)) for (const z of [...floor.zones]) {
71082
+ if (hostDrivesAssignment && ((_floor$zones2 = floor.zones) === null || _floor$zones2 === void 0 ? void 0 : _floor$zones2.length)) for (const z of [...floor.zones]) {
71055
71083
  if (!z.cameraSerial) continue;
71056
71084
  if (!assignedBySerial.has(z.cameraSerial)) removeZone(z.id);
71057
71085
  }
@@ -71090,8 +71118,10 @@ function App($$anchor, $$props) {
71090
71118
  (_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => set(config, normalizeConfig(v), true));
71091
71119
  activeFloor.subscribe((f) => {
71092
71120
  var _f$id, _f$walls$length, _f$walls;
71093
- set(activeFloorId, (_f$id = f === null || f === void 0 ? void 0 : f.id) !== null && _f$id !== void 0 ? _f$id : null, true);
71094
- set(activeFloorWallCount, (_f$walls$length = f === null || f === void 0 || (_f$walls = f.walls) === null || _f$walls === void 0 ? void 0 : _f$walls.length) !== null && _f$walls$length !== void 0 ? _f$walls$length : 0, true);
71121
+ const id = (_f$id = f === null || f === void 0 ? void 0 : f.id) !== null && _f$id !== void 0 ? _f$id : null;
71122
+ const walls = (_f$walls$length = f === null || f === void 0 || (_f$walls = f.walls) === null || _f$walls === void 0 ? void 0 : _f$walls.length) !== null && _f$walls$length !== void 0 ? _f$walls$length : 0;
71123
+ if (id !== get(activeFloorId)) set(activeFloorId, id, true);
71124
+ if (walls !== get(activeFloorWallCount)) set(activeFloorWallCount, walls, true);
71095
71125
  });
71096
71126
  user_effect(() => {
71097
71127
  setFloorCallbackDispatcher($$props.onDispatch ? (eventName, detail) => $$props.onDispatch(eventName, detail) : null);
@@ -71103,9 +71133,18 @@ function App($$anchor, $$props) {
71103
71133
  user_effect(() => {
71104
71134
  var _$$get$assignedCamera;
71105
71135
  const assigned = (_$$get$assignedCamera = get(config).assignedCameras) !== null && _$$get$assignedCamera !== void 0 ? _$$get$assignedCamera : [];
71136
+ assigned.map((c) => {
71137
+ if (!(c === null || c === void 0 ? void 0 : c.serial)) return "";
71138
+ return Object.keys(c).sort().map((k) => {
71139
+ var _c$k;
71140
+ return `${k}=${String((_c$k = c[k]) !== null && _c$k !== void 0 ? _c$k : "")}`;
71141
+ }).join("&");
71142
+ }).filter(Boolean).sort().join("|");
71106
71143
  get(activeFloorId);
71107
71144
  get(activeFloorWallCount);
71108
- syncAssignedCameras(assigned);
71145
+ untrack(() => {
71146
+ syncAssignedCameras(assigned);
71147
+ });
71109
71148
  });
71110
71149
  let commandPaletteOpen = /* @__PURE__ */ state(false);
71111
71150
  let printOpen = /* @__PURE__ */ state(false);