floor-editor-ts 1.2.9 → 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);
@@ -64813,6 +64816,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64813
64816
  showCameraCones();
64814
64817
  showCameraLabels();
64815
64818
  cameraHeatmapMatrix();
64819
+ cameraThumbnail();
64816
64820
  $$props.projectName;
64817
64821
  $$props.heatmapEnabled;
64818
64822
  $$props.heatmapMatrix;
@@ -64890,6 +64894,32 @@ function FloorPlanCanvas($$anchor, $$props) {
64890
64894
  let isCalibrating = /* @__PURE__ */ state(false);
64891
64895
  let calPoints = /* @__PURE__ */ state(proxy([]));
64892
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
+ });
64893
64923
  let draggingRoomLabelId = /* @__PURE__ */ state(null);
64894
64924
  let roomLabelDragStart = {
64895
64925
  x: 0,
@@ -65449,9 +65479,9 @@ function FloorPlanCanvas($$anchor, $$props) {
65449
65479
  }
65450
65480
  }
65451
65481
  function drawMeasurement() {
65452
- var _$$get;
65482
+ var _$$get2;
65453
65483
  if (!get(measureStart)) return;
65454
- 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);
65455
65485
  const s = worldToScreen(get(measureStart).x, get(measureStart).y);
65456
65486
  const e = worldToScreen(end.x, end.y);
65457
65487
  ctx.strokeStyle = "#ef4444";
@@ -65619,17 +65649,28 @@ function FloorPlanCanvas($$anchor, $$props) {
65619
65649
  drawColumn(getCS(), col, selected);
65620
65650
  }
65621
65651
  function drawBackgroundImage() {
65622
- var _$$get2;
65623
- if (!get(bgImage) || !((_$$get2 = get(currentFloor)) === null || _$$get2 === void 0 ? void 0 : _$$get2.backgroundImage)) return;
65652
+ if (!get(bgImage) || !get(currentFloor)) return;
65624
65653
  const bg = get(currentFloor).backgroundImage;
65625
- const s = worldToScreen(bg.position.x, bg.position.y);
65626
65654
  ctx.save();
65627
- ctx.globalAlpha = bg.opacity;
65628
- ctx.translate(s.x, s.y);
65629
- ctx.rotate(bg.rotation * Math.PI / 180);
65630
- const sw = get(bgImage).width * bg.scale * get(zoom);
65631
- const sh = get(bgImage).height * bg.scale * get(zoom);
65632
- 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
+ }
65633
65674
  ctx.restore();
65634
65675
  }
65635
65676
  function getFloorWallBounds(floor = get(currentFloor)) {
@@ -66419,16 +66460,6 @@ function FloorPlanCanvas($$anchor, $$props) {
66419
66460
  set(currentSelectedIds, ids, true);
66420
66461
  markDirty();
66421
66462
  });
66422
- const unsub14 = activeFloor.subscribe((f) => {
66423
- var _f$backgroundImage;
66424
- 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)) {
66425
- const img = new Image();
66426
- img.onload = () => {
66427
- set(bgImage, img, true);
66428
- };
66429
- img.src = f.backgroundImage.dataUrl;
66430
- } else if (!(f === null || f === void 0 ? void 0 : f.backgroundImage)) set(bgImage, null);
66431
- });
66432
66463
  const unsubZoom = canvasZoom.subscribe((v) => {
66433
66464
  set(zoom, v, true);
66434
66465
  });
@@ -66479,7 +66510,6 @@ function FloorPlanCanvas($$anchor, $$props) {
66479
66510
  unsub12();
66480
66511
  unsub13();
66481
66512
  unsub_multi();
66482
- unsub14();
66483
66513
  unsubZoom();
66484
66514
  unsubCamX();
66485
66515
  unsubCamY();
@@ -69784,6 +69814,10 @@ function App($$anchor, $$props) {
69784
69814
  var _$$get11;
69785
69815
  return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.cameraHeatmapMatrix;
69786
69816
  });
69817
+ let $10 = /* @__PURE__ */ user_derived(() => {
69818
+ var _$$get12;
69819
+ return ((_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraThumbnail) || "";
69820
+ });
69787
69821
  FloorPlanCanvas(node_3, {
69788
69822
  get viewOnly() {
69789
69823
  return get($0);
@@ -69814,6 +69848,9 @@ function App($$anchor, $$props) {
69814
69848
  },
69815
69849
  get cameraHeatmapMatrix() {
69816
69850
  return get($9);
69851
+ },
69852
+ get cameraThumbnail() {
69853
+ return get($10);
69817
69854
  }
69818
69855
  });
69819
69856
  }
@@ -69842,8 +69879,8 @@ function App($$anchor, $$props) {
69842
69879
  {
69843
69880
  let $0 = /* @__PURE__ */ user_derived(() => get(mode) === "3d");
69844
69881
  let $1 = /* @__PURE__ */ user_derived(() => {
69845
- var _$$get$siteCameras, _$$get12;
69846
- 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 : [];
69847
69884
  });
69848
69885
  PropertiesPanel($$anchor, {
69849
69886
  get is3D() {
@@ -70016,18 +70053,11 @@ function _ensureShadowRoot() {
70016
70053
  }
70017
70054
  const shadow = this.attachShadow({ mode: "open" });
70018
70055
  const style = document.createElement("style");
70019
- style.textContent = app_default + `
70020
-
70021
- :host {
70022
-
70056
+ style.textContent = app_default + `:host {
70023
70057
  display: block;
70024
-
70025
70058
  width: 100%;
70026
-
70027
70059
  height: 100%;
70028
-
70029
70060
  }
70030
-
70031
70061
  `;
70032
70062
  shadow.appendChild(style);
70033
70063
  _classPrivateFieldSet2(_wrapper, this, document.createElement("div"));