floor-editor-ts 1.3.1 → 1.3.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.
@@ -6995,21 +6995,33 @@ var DEFAULT_CONFIG = {
6995
6995
  cameraHeatmapMatrix: [],
6996
6996
  siteCameras: [],
6997
6997
  cameraThumbnail: "",
6998
- cameraThumbnailOpacity: .65
6998
+ cameraThumbnailOpacity: .65,
6999
+ canvasBackground: "#f8f9fa",
7000
+ floorPlateBackground: "#f8f9fa"
6999
7001
  };
7000
7002
  function normalizeConfig(value) {
7001
7003
  if (!value || typeof value !== "object") return { ...DEFAULT_CONFIG };
7002
7004
  const siteCameras = Array.isArray(value.siteCameras) ? value.siteCameras.filter((c) => !!c && typeof c === "object" && typeof c.serial === "string" && typeof c.name === "string") : DEFAULT_CONFIG.siteCameras;
7003
7005
  const image = typeof value.cameraThumbnail === "string" ? value.cameraThumbnail ? value.cameraThumbnail : DEFAULT_CONFIG.cameraThumbnail : DEFAULT_CONFIG.cameraThumbnail;
7004
7006
  const opacity = typeof value.cameraThumbnailOpacity === "number" && value.cameraThumbnailOpacity >= 0 && value.cameraThumbnailOpacity <= 1 ? value.cameraThumbnailOpacity : DEFAULT_CONFIG.cameraThumbnailOpacity;
7007
+ const canvasBackground = normalizeColor$1(value.canvasBackground, DEFAULT_CONFIG.canvasBackground);
7008
+ const floorPlateBackground = normalizeColor$1(value.floorPlateBackground, DEFAULT_CONFIG.floorPlateBackground);
7005
7009
  return {
7006
7010
  ...DEFAULT_CONFIG,
7007
7011
  ...value,
7008
7012
  siteCameras,
7009
7013
  cameraThumbnail: image,
7010
- cameraThumbnailOpacity: opacity
7014
+ cameraThumbnailOpacity: opacity,
7015
+ canvasBackground,
7016
+ floorPlateBackground
7011
7017
  };
7012
7018
  }
7019
+ function normalizeColor$1(value, fallback) {
7020
+ if (typeof value !== "string") return fallback;
7021
+ const trimmed = value.trim();
7022
+ if (/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(trimmed)) return trimmed;
7023
+ return fallback;
7024
+ }
7013
7025
  function normalizeFloorData(data) {
7014
7026
  if (!data || typeof data !== "object") return createDefaultProject();
7015
7027
  if (!Array.isArray(data.floors) || data.floors.length === 0) return createDefaultProject();
@@ -64753,7 +64765,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64753
64765
  const $panMode = () => store_get(panMode, "$panMode", $$stores);
64754
64766
  const $projectSettings = () => store_get(projectSettings, "$projectSettings", $$stores);
64755
64767
  const [$$stores, $$cleanup] = setup_stores();
64756
- let selectedCameraSerial = prop($$props, "selectedCameraSerial", 3, null), showCameraCones = prop($$props, "showCameraCones", 3, false), showCameraLabels = prop($$props, "showCameraLabels", 3, true), cameraHeatmapMatrix = prop($$props, "cameraHeatmapMatrix", 19, () => []), cameraThumbnail = prop($$props, "cameraThumbnail", 3, "");
64768
+ let selectedCameraSerial = prop($$props, "selectedCameraSerial", 3, null), showCameraCones = prop($$props, "showCameraCones", 3, false), showCameraLabels = prop($$props, "showCameraLabels", 3, true), cameraHeatmapMatrix = prop($$props, "cameraHeatmapMatrix", 19, () => []), cameraThumbnail = prop($$props, "cameraThumbnail", 3, ""), canvasBackground = prop($$props, "canvasBackground", 3, "#2E353F"), floorPlateBackground = prop($$props, "floorPlateBackground", 3, "#ffffff");
64757
64769
  let canvas;
64758
64770
  let ctx;
64759
64771
  let width = /* @__PURE__ */ state(800);
@@ -64853,6 +64865,8 @@ function FloorPlanCanvas($$anchor, $$props) {
64853
64865
  showCameraLabels();
64854
64866
  cameraHeatmapMatrix();
64855
64867
  cameraThumbnail();
64868
+ canvasBackground();
64869
+ floorPlateBackground();
64856
64870
  $$props.projectName;
64857
64871
  $$props.heatmapEnabled;
64858
64872
  $$props.heatmapMatrix;
@@ -65689,13 +65703,23 @@ function FloorPlanCanvas($$anchor, $$props) {
65689
65703
  if (!floor) return null;
65690
65704
  return getFloorBounds(floor, { includeWallThickness: true });
65691
65705
  }
65706
+ function drawFloorPlateBackground() {
65707
+ var _$$get3;
65708
+ if (!((_$$get3 = get(currentFloor)) === null || _$$get3 === void 0 || (_$$get3 = _$$get3.walls) === null || _$$get3 === void 0 ? void 0 : _$$get3.length)) return;
65709
+ const bounds = getCameraThumbnailBounds(get(currentFloor));
65710
+ if (!bounds) return;
65711
+ const topLeft = worldToScreen(bounds.minX, bounds.minY);
65712
+ const bottomRight = worldToScreen(bounds.maxX, bounds.maxY);
65713
+ ctx.fillStyle = floorPlateBackground();
65714
+ ctx.fillRect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
65715
+ }
65692
65716
  function isCameraThumbnailOverlayActive() {
65693
- var _cameraThumbnail2, _$$get3;
65694
- return !!(((_cameraThumbnail2 = cameraThumbnail()) === null || _cameraThumbnail2 === void 0 ? void 0 : _cameraThumbnail2.trim()) && get(bgImage) && !((_$$get3 = get(currentFloor)) === null || _$$get3 === void 0 ? void 0 : _$$get3.backgroundImage));
65717
+ var _cameraThumbnail2, _$$get4;
65718
+ return !!(((_cameraThumbnail2 = cameraThumbnail()) === null || _cameraThumbnail2 === void 0 ? void 0 : _cameraThumbnail2.trim()) && get(bgImage) && !((_$$get4 = get(currentFloor)) === null || _$$get4 === void 0 ? void 0 : _$$get4.backgroundImage));
65695
65719
  }
65696
65720
  function drawBackgroundImage() {
65697
- var _$$get4;
65698
- if (!get(bgImage) || !((_$$get4 = get(currentFloor)) === null || _$$get4 === void 0 ? void 0 : _$$get4.backgroundImage)) return;
65721
+ var _$$get5;
65722
+ if (!get(bgImage) || !((_$$get5 = get(currentFloor)) === null || _$$get5 === void 0 ? void 0 : _$$get5.backgroundImage)) return;
65699
65723
  const bg = get(currentFloor).backgroundImage;
65700
65724
  ctx.save();
65701
65725
  ctx.globalAlpha = bg.opacity;
@@ -65771,7 +65795,7 @@ function FloorPlanCanvas($$anchor, $$props) {
65771
65795
  }
65772
65796
  canvasDirty = false;
65773
65797
  ctx.clearRect(0, 0, get(width), get(height));
65774
- ctx.fillStyle = "#f8f9fa";
65798
+ ctx.fillStyle = canvasBackground();
65775
65799
  ctx.fillRect(0, 0, get(width), get(height));
65776
65800
  if (!$$props.viewOnly) drawGrid();
65777
65801
  if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
@@ -65793,6 +65817,7 @@ function FloorPlanCanvas($$anchor, $$props) {
65793
65817
  function isSelected(id) {
65794
65818
  return id === selId || multiIds.has(id);
65795
65819
  }
65820
+ drawFloorPlateBackground();
65796
65821
  drawRooms$1();
65797
65822
  if (!$$props.viewOnly) drawSnapPoints$1();
65798
65823
  if (get(layerVis).walls) {
@@ -66737,7 +66762,7 @@ function FloorPlanCanvas($$anchor, $$props) {
66737
66762
  return findRoomAt(p, get(detectedRooms), get(currentFloor).walls);
66738
66763
  }
66739
66764
  function onMouseDown(e) {
66740
- var _$$get5;
66765
+ var _$$get6;
66741
66766
  if ($$props.viewOnly) return;
66742
66767
  markDirty();
66743
66768
  if (e.button === 1 || e.button === 0 && (get(spaceDown) || $panMode() || e.shiftKey && get(currentTool) === "select")) {
@@ -66818,7 +66843,7 @@ function FloorPlanCanvas($$anchor, $$props) {
66818
66843
  placingStair.set(false);
66819
66844
  return;
66820
66845
  }
66821
- if (tool === "select" && ((_$$get5 = get(currentFloor)) === null || _$$get5 === void 0 ? void 0 : _$$get5.guides)) {
66846
+ if (tool === "select" && ((_$$get6 = get(currentFloor)) === null || _$$get6 === void 0 ? void 0 : _$$get6.guides)) {
66822
66847
  const GUIDE_HIT = 6 / get(zoom);
66823
66848
  for (const g of get(currentFloor).guides) {
66824
66849
  if (g.orientation === "horizontal" && Math.abs(wp.y - g.position) < GUIDE_HIT) {
@@ -66887,9 +66912,9 @@ function FloorPlanCanvas($$anchor, $$props) {
66887
66912
  const dist = Math.hypot(newPts[1].x - newPts[0].x, newPts[1].y - newPts[0].y);
66888
66913
  const realDist = prompt("Enter the real-world distance between these two points (in cm):");
66889
66914
  if (realDist && Number(realDist) > 0) {
66890
- var _$$get6;
66915
+ var _$$get7;
66891
66916
  const pixelsPerCm = dist / Number(realDist);
66892
- if ((_$$get6 = get(currentFloor)) === null || _$$get6 === void 0 ? void 0 : _$$get6.backgroundImage) updateBackgroundImage({ scale: get(currentFloor).backgroundImage.scale * (1 / pixelsPerCm) });
66917
+ if ((_$$get7 = get(currentFloor)) === null || _$$get7 === void 0 ? void 0 : _$$get7.backgroundImage) updateBackgroundImage({ scale: get(currentFloor).backgroundImage.scale * (1 / pixelsPerCm) });
66893
66918
  }
66894
66919
  calibrationMode.set(false);
66895
66920
  return [];
@@ -67259,7 +67284,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67259
67284
  }
67260
67285
  }
67261
67286
  function onMouseMove(e) {
67262
- var _$$get7, _$$get8, _$$get9, _$$get10;
67287
+ var _$$get8, _$$get9, _$$get10, _$$get11;
67263
67288
  if ($$props.viewOnly) return;
67264
67289
  markDirty();
67265
67290
  const rect = canvas.getBoundingClientRect();
@@ -67277,7 +67302,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67277
67302
  } : r));
67278
67303
  return;
67279
67304
  }
67280
- if (get(draggingGuideId) && ((_$$get7 = get(currentFloor)) === null || _$$get7 === void 0 ? void 0 : _$$get7.guides)) {
67305
+ if (get(draggingGuideId) && ((_$$get8 = get(currentFloor)) === null || _$$get8 === void 0 ? void 0 : _$$get8.guides)) {
67281
67306
  const g = get(currentFloor).guides.find((g) => g.id === get(draggingGuideId));
67282
67307
  if (g) {
67283
67308
  const newPos = g.orientation === "horizontal" ? get(mousePos).y : get(mousePos).x;
@@ -67433,7 +67458,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67433
67458
  }
67434
67459
  }
67435
67460
  }
67436
- if (get(draggingTextAnnotationId) && ((_$$get8 = get(currentFloor)) === null || _$$get8 === void 0 ? void 0 : _$$get8.textAnnotations)) {
67461
+ if (get(draggingTextAnnotationId) && ((_$$get9 = get(currentFloor)) === null || _$$get9 === void 0 ? void 0 : _$$get9.textAnnotations)) {
67437
67462
  const basePos = {
67438
67463
  x: get(mousePos).x - textAnnotationDragOffset.x,
67439
67464
  y: get(mousePos).y - textAnnotationDragOffset.y
@@ -67450,7 +67475,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67450
67475
  }, true);
67451
67476
  }
67452
67477
  }
67453
- if (get(draggingColumnId) && ((_$$get9 = get(currentFloor)) === null || _$$get9 === void 0 ? void 0 : _$$get9.columns)) {
67478
+ if (get(draggingColumnId) && ((_$$get10 = get(currentFloor)) === null || _$$get10 === void 0 ? void 0 : _$$get10.columns)) {
67454
67479
  const basePos = {
67455
67480
  x: get(mousePos).x - columnDragOffset.x,
67456
67481
  y: get(mousePos).y - columnDragOffset.y
@@ -67460,7 +67485,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67460
67485
  y: snap(basePos.y)
67461
67486
  });
67462
67487
  }
67463
- if (get(draggingStairId) && ((_$$get10 = get(currentFloor)) === null || _$$get10 === void 0 ? void 0 : _$$get10.stairs)) {
67488
+ if (get(draggingStairId) && ((_$$get11 = get(currentFloor)) === null || _$$get11 === void 0 ? void 0 : _$$get11.stairs)) {
67464
67489
  const basePos = {
67465
67490
  x: get(mousePos).x - stairDragOffset.x,
67466
67491
  y: get(mousePos).y - stairDragOffset.y
@@ -67471,12 +67496,12 @@ function FloorPlanCanvas($$anchor, $$props) {
67471
67496
  });
67472
67497
  }
67473
67498
  if (get(draggingFurnitureId)) {
67474
- var _$$get11;
67499
+ var _$$get12;
67475
67500
  const basePos = {
67476
67501
  x: get(mousePos).x - dragOffset.x,
67477
67502
  y: get(mousePos).y - dragOffset.y
67478
67503
  };
67479
- const fi = (_$$get11 = get(currentFloor)) === null || _$$get11 === void 0 ? void 0 : _$$get11.furniture.find((f) => f.id === get(draggingFurnitureId));
67504
+ const fi = (_$$get12 = get(currentFloor)) === null || _$$get12 === void 0 ? void 0 : _$$get12.furniture.find((f) => f.id === get(draggingFurnitureId));
67480
67505
  if (fi) {
67481
67506
  const wallSnap = snapFurnitureToWall(basePos, fi.catalogId, fi.rotation);
67482
67507
  if (wallSnap) {
@@ -67489,13 +67514,13 @@ function FloorPlanCanvas($$anchor, $$props) {
67489
67514
  wallAngle: wallSnap.wallAngle
67490
67515
  }, true);
67491
67516
  } else {
67492
- var _$$get12;
67517
+ var _$$get13;
67493
67518
  const snapped = {
67494
67519
  x: snap(basePos.x),
67495
67520
  y: snap(basePos.y)
67496
67521
  };
67497
67522
  const GUIDE_SNAP = 10;
67498
- if ((_$$get12 = get(currentFloor)) === null || _$$get12 === void 0 ? void 0 : _$$get12.guides) for (const g of get(currentFloor).guides) {
67523
+ if ((_$$get13 = get(currentFloor)) === null || _$$get13 === void 0 ? void 0 : _$$get13.guides) for (const g of get(currentFloor).guides) {
67499
67524
  if (g.orientation === "horizontal" && Math.abs(snapped.y - g.position) < GUIDE_SNAP) snapped.y = g.position;
67500
67525
  if (g.orientation === "vertical" && Math.abs(snapped.x - g.position) < GUIDE_SNAP) snapped.x = g.position;
67501
67526
  }
@@ -68191,8 +68216,8 @@ function FloorPlanCanvas($$anchor, $$props) {
68191
68216
  }
68192
68217
  }
68193
68218
  let cursorStyle = /* @__PURE__ */ user_derived(() => {
68194
- var _$$get13;
68195
- return get(spaceDown) || get(isPanning) || $panMode() || get(shiftDown) && get(currentTool) === "select" ? "grab" : get(draggingFurnitureId) ? "move" : get(draggingRoomId) ? "move" : get(draggingMultiSelect) ? "move" : get(draggingDoorId) ? "move" : get(draggingWindowId) ? "move" : get(draggingStairId) ? "move" : get(draggingColumnId) ? "move" : get(draggingTextAnnotationId) ? "move" : get(draggingWallParallel) ? "move" : get(draggingCurveHandle) ? "crosshair" : get(draggingWallEndpoint) ? "crosshair" : get(draggingHandle) === "rotate" ? "grabbing" : get(draggingHandle) === "resize-t" || get(draggingHandle) === "resize-b" ? "ns-resize" : get(draggingHandle) === "resize-l" || get(draggingHandle) === "resize-r" ? "ew-resize" : ((_$$get13 = get(draggingHandle)) === null || _$$get13 === void 0 ? void 0 : _$$get13.startsWith("resize")) ? "nwse-resize" : get(currentTool) === "text" ? "text" : get(currentTool) === "select" ? "default" : get(currentTool) === "furniture" ? "copy" : get(currentTool) === "door" || get(currentTool) === "window" ? get(placementPreview) ? "crosshair" : "not-allowed" : "crosshair";
68219
+ var _$$get14;
68220
+ return get(spaceDown) || get(isPanning) || $panMode() || get(shiftDown) && get(currentTool) === "select" ? "grab" : get(draggingFurnitureId) ? "move" : get(draggingRoomId) ? "move" : get(draggingMultiSelect) ? "move" : get(draggingDoorId) ? "move" : get(draggingWindowId) ? "move" : get(draggingStairId) ? "move" : get(draggingColumnId) ? "move" : get(draggingTextAnnotationId) ? "move" : get(draggingWallParallel) ? "move" : get(draggingCurveHandle) ? "crosshair" : get(draggingWallEndpoint) ? "crosshair" : get(draggingHandle) === "rotate" ? "grabbing" : get(draggingHandle) === "resize-t" || get(draggingHandle) === "resize-b" ? "ns-resize" : get(draggingHandle) === "resize-l" || get(draggingHandle) === "resize-r" ? "ew-resize" : ((_$$get14 = get(draggingHandle)) === null || _$$get14 === void 0 ? void 0 : _$$get14.startsWith("resize")) ? "nwse-resize" : get(currentTool) === "text" ? "text" : get(currentTool) === "select" ? "default" : get(currentTool) === "furniture" ? "copy" : get(currentTool) === "door" || get(currentTool) === "window" ? get(placementPreview) ? "crosshair" : "not-allowed" : "crosshair";
68196
68221
  });
68197
68222
  var div = root$1();
68198
68223
  event("keydown", $window, onKeyDown);
@@ -68279,8 +68304,8 @@ function FloorPlanCanvas($$anchor, $$props) {
68279
68304
  }
68280
68305
  set(editingTextAnnotationId, null);
68281
68306
  } else if (e.key === "Escape") {
68282
- var _$$get14;
68283
- if ((_$$get14 = get(currentFloor)) === null || _$$get14 === void 0 ? void 0 : _$$get14.textAnnotations) {
68307
+ var _$$get15;
68308
+ if ((_$$get15 = get(currentFloor)) === null || _$$get15 === void 0 ? void 0 : _$$get15.textAnnotations) {
68284
68309
  const ta = get(currentFloor).textAnnotations.find((t) => t.id === get(editingTextAnnotationId));
68285
68310
  if (ta && ta.text === "Text" && !get(editingTextAnnotationValue).trim()) {
68286
68311
  removeTextAnnotation(get(editingTextAnnotationId));
@@ -68632,8 +68657,8 @@ function FloorPlanCanvas($$anchor, $$props) {
68632
68657
  var text_16 = child(div_8);
68633
68658
  reset(div_8);
68634
68659
  template_effect(() => {
68635
- var _$$get15;
68636
- return set_text(text_16, `Click to place · Scroll or R to rotate (${(_$$get15 = get(currentPlacingRotation)) !== null && _$$get15 !== void 0 ? _$$get15 : ""}°) · Esc
68660
+ var _$$get16;
68661
+ return set_text(text_16, `Click to place · Scroll or R to rotate (${(_$$get16 = get(currentPlacingRotation)) !== null && _$$get16 !== void 0 ? _$$get16 : ""}°) · Esc
68637
68662
  to cancel`);
68638
68663
  });
68639
68664
  append($$anchor, div_8);
@@ -69875,6 +69900,14 @@ function App($$anchor, $$props) {
69875
69900
  var _$$get12;
69876
69901
  return ((_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraThumbnail) || "";
69877
69902
  });
69903
+ let $11 = /* @__PURE__ */ user_derived(() => {
69904
+ var _$$get13;
69905
+ return (_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.canvasBackground;
69906
+ });
69907
+ let $12 = /* @__PURE__ */ user_derived(() => {
69908
+ var _$$get14;
69909
+ return (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.floorPlateBackground;
69910
+ });
69878
69911
  FloorPlanCanvas(node_3, {
69879
69912
  get viewOnly() {
69880
69913
  return get($0);
@@ -69908,6 +69941,12 @@ function App($$anchor, $$props) {
69908
69941
  },
69909
69942
  get cameraThumbnail() {
69910
69943
  return get($10);
69944
+ },
69945
+ get canvasBackground() {
69946
+ return get($11);
69947
+ },
69948
+ get floorPlateBackground() {
69949
+ return get($12);
69911
69950
  }
69912
69951
  });
69913
69952
  }
@@ -69936,12 +69975,12 @@ function App($$anchor, $$props) {
69936
69975
  {
69937
69976
  let $0 = /* @__PURE__ */ user_derived(() => get(mode) === "3d");
69938
69977
  let $1 = /* @__PURE__ */ user_derived(() => {
69939
- var _$$get$siteCameras, _$$get13;
69940
- return (_$$get$siteCameras = (_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
69978
+ var _$$get$siteCameras, _$$get15;
69979
+ return (_$$get$siteCameras = (_$$get15 = get(config)) === null || _$$get15 === void 0 ? void 0 : _$$get15.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
69941
69980
  });
69942
69981
  let $2 = /* @__PURE__ */ user_derived(() => {
69943
- var _$$get$cameraThumbnai, _$$get14;
69944
- return (_$$get$cameraThumbnai = (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.cameraThumbnail) !== null && _$$get$cameraThumbnai !== void 0 ? _$$get$cameraThumbnai : "";
69982
+ var _$$get$cameraThumbnai, _$$get16;
69983
+ return (_$$get$cameraThumbnai = (_$$get16 = get(config)) === null || _$$get16 === void 0 ? void 0 : _$$get16.cameraThumbnail) !== null && _$$get$cameraThumbnai !== void 0 ? _$$get$cameraThumbnai : "";
69945
69984
  });
69946
69985
  PropertiesPanel($$anchor, {
69947
69986
  get is3D() {