floor-editor-ts 1.2.8 → 1.3.0

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.
@@ -6988,15 +6988,18 @@ var DEFAULT_CONFIG = {
6988
6988
  showCameraCones: false,
6989
6989
  showCameraLabels: true,
6990
6990
  cameraHeatmapMatrix: [],
6991
- siteCameras: []
6991
+ siteCameras: [],
6992
+ cameraThumbnail: ""
6992
6993
  };
6993
6994
  function normalizeConfig(value) {
6994
6995
  if (!value || typeof value !== "object") return { ...DEFAULT_CONFIG };
6995
6996
  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;
6997
+ const image = typeof value.cameraThumbnail === "string" ? value.cameraThumbnail ? value.cameraThumbnail : DEFAULT_CONFIG.cameraThumbnail : DEFAULT_CONFIG.cameraThumbnail;
6996
6998
  return {
6997
6999
  ...DEFAULT_CONFIG,
6998
7000
  ...value,
6999
- siteCameras
7001
+ siteCameras,
7002
+ cameraThumbnail: image
7000
7003
  };
7001
7004
  }
7002
7005
  function normalizeFloorData(data) {
@@ -64714,7 +64717,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64714
64717
  const $panMode = () => store_get(panMode, "$panMode", $$stores);
64715
64718
  const $projectSettings = () => store_get(projectSettings, "$projectSettings", $$stores);
64716
64719
  const [$$stores, $$cleanup] = setup_stores();
64717
- let selectedCameraSerial = prop($$props, "selectedCameraSerial", 3, null), showCameraCones = prop($$props, "showCameraCones", 3, false), showCameraLabels = prop($$props, "showCameraLabels", 3, true), cameraHeatmapMatrix = prop($$props, "cameraHeatmapMatrix", 19, () => []);
64720
+ 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, "");
64718
64721
  let canvas;
64719
64722
  let ctx;
64720
64723
  let width = /* @__PURE__ */ state(800);
@@ -64741,29 +64744,13 @@ function FloorPlanCanvas($$anchor, $$props) {
64741
64744
  };
64742
64745
  }
64743
64746
  user_effect(() => {
64744
- const unsubZoom = canvasZoom.subscribe((v) => {
64745
- if (v !== get(zoom)) set(zoom, v, true);
64746
- });
64747
- const unsubX = canvasCamX.subscribe((v) => {
64748
- if (v !== get(camX)) set(camX, v, true);
64749
- });
64750
- const unsubY = canvasCamY.subscribe((v) => {
64751
- if (v !== get(camY)) set(camY, v, true);
64752
- });
64753
- return () => {
64754
- unsubZoom();
64755
- unsubX();
64756
- unsubY();
64757
- };
64758
- });
64759
- user_effect(() => {
64760
- if (get$1(canvasZoom) !== get(zoom)) canvasZoom.set(get(zoom));
64747
+ canvasZoom.set(get(zoom));
64761
64748
  });
64762
64749
  user_effect(() => {
64763
- if (get$1(canvasCamX) !== get(camX)) canvasCamX.set(get(camX));
64750
+ canvasCamX.set(get(camX));
64764
64751
  });
64765
64752
  user_effect(() => {
64766
- if (get$1(canvasCamY) !== get(camY)) canvasCamY.set(get(camY));
64753
+ canvasCamY.set(get(camY));
64767
64754
  });
64768
64755
  let wallStart = /* @__PURE__ */ state(null);
64769
64756
  let wallSequenceFirst = /* @__PURE__ */ state(null);
@@ -64829,6 +64816,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64829
64816
  showCameraCones();
64830
64817
  showCameraLabels();
64831
64818
  cameraHeatmapMatrix();
64819
+ cameraThumbnail();
64832
64820
  $$props.projectName;
64833
64821
  $$props.heatmapEnabled;
64834
64822
  $$props.heatmapMatrix;
@@ -64906,6 +64894,32 @@ function FloorPlanCanvas($$anchor, $$props) {
64906
64894
  let isCalibrating = /* @__PURE__ */ state(false);
64907
64895
  let calPoints = /* @__PURE__ */ state(proxy([]));
64908
64896
  let bgImage = /* @__PURE__ */ state(null);
64897
+ user_effect(() => {
64898
+ var _$$get, _cameraThumbnail$trim, _cameraThumbnail;
64899
+ const floorBgUrl = (_$$get = get(currentFloor)) === null || _$$get === void 0 || (_$$get = _$$get.backgroundImage) === null || _$$get === void 0 ? void 0 : _$$get.dataUrl;
64900
+ const thumbnailUrl = (_cameraThumbnail$trim = (_cameraThumbnail = cameraThumbnail()) === null || _cameraThumbnail === void 0 ? void 0 : _cameraThumbnail.trim()) !== null && _cameraThumbnail$trim !== void 0 ? _cameraThumbnail$trim : "";
64901
+ const url = floorBgUrl || thumbnailUrl;
64902
+ if (!url) {
64903
+ set(bgImage, null);
64904
+ return;
64905
+ }
64906
+ let cancelled = false;
64907
+ const img = new Image();
64908
+ img.onload = () => {
64909
+ if (cancelled) return;
64910
+ set(bgImage, img, true);
64911
+ markDirty();
64912
+ };
64913
+ img.onerror = () => {
64914
+ if (cancelled) return;
64915
+ set(bgImage, null);
64916
+ markDirty();
64917
+ };
64918
+ img.src = url;
64919
+ return () => {
64920
+ cancelled = true;
64921
+ };
64922
+ });
64909
64923
  let draggingRoomLabelId = /* @__PURE__ */ state(null);
64910
64924
  let roomLabelDragStart = {
64911
64925
  x: 0,
@@ -65465,9 +65479,9 @@ function FloorPlanCanvas($$anchor, $$props) {
65465
65479
  }
65466
65480
  }
65467
65481
  function drawMeasurement() {
65468
- var _$$get;
65482
+ var _$$get2;
65469
65483
  if (!get(measureStart)) return;
65470
- const end = (_$$get = get(measureEnd)) !== null && _$$get !== void 0 ? _$$get : get(mousePos);
65484
+ const end = (_$$get2 = get(measureEnd)) !== null && _$$get2 !== void 0 ? _$$get2 : get(mousePos);
65471
65485
  const s = worldToScreen(get(measureStart).x, get(measureStart).y);
65472
65486
  const e = worldToScreen(end.x, end.y);
65473
65487
  ctx.strokeStyle = "#ef4444";
@@ -65635,17 +65649,28 @@ function FloorPlanCanvas($$anchor, $$props) {
65635
65649
  drawColumn(getCS(), col, selected);
65636
65650
  }
65637
65651
  function drawBackgroundImage() {
65638
- var _$$get2;
65639
- if (!get(bgImage) || !((_$$get2 = get(currentFloor)) === null || _$$get2 === void 0 ? void 0 : _$$get2.backgroundImage)) return;
65652
+ if (!get(bgImage) || !get(currentFloor)) return;
65640
65653
  const bg = get(currentFloor).backgroundImage;
65641
- const s = worldToScreen(bg.position.x, bg.position.y);
65642
65654
  ctx.save();
65643
- ctx.globalAlpha = bg.opacity;
65644
- ctx.translate(s.x, s.y);
65645
- ctx.rotate(bg.rotation * Math.PI / 180);
65646
- const sw = get(bgImage).width * bg.scale * get(zoom);
65647
- const sh = get(bgImage).height * bg.scale * get(zoom);
65648
- ctx.drawImage(get(bgImage), -sw / 2, -sh / 2, sw, sh);
65655
+ if (bg) {
65656
+ const s = worldToScreen(bg.position.x, bg.position.y);
65657
+ ctx.globalAlpha = bg.opacity;
65658
+ ctx.translate(s.x, s.y);
65659
+ ctx.rotate(bg.rotation * Math.PI / 180);
65660
+ const sw = get(bgImage).width * bg.scale * get(zoom);
65661
+ const sh = get(bgImage).height * bg.scale * get(zoom);
65662
+ ctx.drawImage(get(bgImage), -sw / 2, -sh / 2, sw, sh);
65663
+ } else if (cameraThumbnail()) {
65664
+ const bounds = getFloorBounds(get(currentFloor), { includeWallThickness: true });
65665
+ if (!bounds) {
65666
+ ctx.restore();
65667
+ return;
65668
+ }
65669
+ ctx.globalAlpha = .85;
65670
+ const topLeft = worldToScreen(bounds.minX, bounds.minY);
65671
+ const bottomRight = worldToScreen(bounds.maxX, bounds.maxY);
65672
+ ctx.drawImage(get(bgImage), topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
65673
+ }
65649
65674
  ctx.restore();
65650
65675
  }
65651
65676
  function getFloorWallBounds(floor = get(currentFloor)) {
@@ -66435,15 +66460,14 @@ function FloorPlanCanvas($$anchor, $$props) {
66435
66460
  set(currentSelectedIds, ids, true);
66436
66461
  markDirty();
66437
66462
  });
66438
- const unsub14 = activeFloor.subscribe((f) => {
66439
- var _f$backgroundImage;
66440
- if ((f === null || f === void 0 || (_f$backgroundImage = f.backgroundImage) === null || _f$backgroundImage === void 0 ? void 0 : _f$backgroundImage.dataUrl) && (!get(bgImage) || get(bgImage).src !== f.backgroundImage.dataUrl)) {
66441
- const img = new Image();
66442
- img.onload = () => {
66443
- set(bgImage, img, true);
66444
- };
66445
- img.src = f.backgroundImage.dataUrl;
66446
- } else if (!(f === null || f === void 0 ? void 0 : f.backgroundImage)) set(bgImage, null);
66463
+ const unsubZoom = canvasZoom.subscribe((v) => {
66464
+ set(zoom, v, true);
66465
+ });
66466
+ const unsubCamX = canvasCamX.subscribe((v) => {
66467
+ set(camX, v, true);
66468
+ });
66469
+ const unsubCamY = canvasCamY.subscribe((v) => {
66470
+ set(camY, v, true);
66447
66471
  });
66448
66472
  function handlePaste(e) {
66449
66473
  if (!e.clipboardData) return;
@@ -66486,7 +66510,9 @@ function FloorPlanCanvas($$anchor, $$props) {
66486
66510
  unsub12();
66487
66511
  unsub13();
66488
66512
  unsub_multi();
66489
- unsub14();
66513
+ unsubZoom();
66514
+ unsubCamX();
66515
+ unsubCamY();
66490
66516
  unsub_col();
66491
66517
  unsub_cols();
66492
66518
  unsub_layers();
@@ -69788,6 +69814,10 @@ function App($$anchor, $$props) {
69788
69814
  var _$$get11;
69789
69815
  return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.cameraHeatmapMatrix;
69790
69816
  });
69817
+ let $10 = /* @__PURE__ */ user_derived(() => {
69818
+ var _$$get12;
69819
+ return ((_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraThumbnail) || "";
69820
+ });
69791
69821
  FloorPlanCanvas(node_3, {
69792
69822
  get viewOnly() {
69793
69823
  return get($0);
@@ -69818,6 +69848,9 @@ function App($$anchor, $$props) {
69818
69848
  },
69819
69849
  get cameraHeatmapMatrix() {
69820
69850
  return get($9);
69851
+ },
69852
+ get cameraThumbnail() {
69853
+ return get($10);
69821
69854
  }
69822
69855
  });
69823
69856
  }
@@ -69846,8 +69879,8 @@ function App($$anchor, $$props) {
69846
69879
  {
69847
69880
  let $0 = /* @__PURE__ */ user_derived(() => get(mode) === "3d");
69848
69881
  let $1 = /* @__PURE__ */ user_derived(() => {
69849
- var _$$get$siteCameras, _$$get12;
69850
- return (_$$get$siteCameras = (_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
69882
+ var _$$get$siteCameras, _$$get13;
69883
+ return (_$$get$siteCameras = (_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
69851
69884
  });
69852
69885
  PropertiesPanel($$anchor, {
69853
69886
  get is3D() {
@@ -70020,18 +70053,11 @@ function _ensureShadowRoot() {
70020
70053
  }
70021
70054
  const shadow = this.attachShadow({ mode: "open" });
70022
70055
  const style = document.createElement("style");
70023
- style.textContent = app_default + `
70024
-
70025
- :host {
70026
-
70056
+ style.textContent = app_default + `:host {
70027
70057
  display: block;
70028
-
70029
70058
  width: 100%;
70030
-
70031
70059
  height: 100%;
70032
-
70033
70060
  }
70034
-
70035
70061
  `;
70036
70062
  shadow.appendChild(style);
70037
70063
  _classPrivateFieldSet2(_wrapper, this, document.createElement("div"));