floor-editor-ts 1.1.4 → 1.1.5

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.
@@ -6951,6 +6951,54 @@ var localStore = {
6951
6951
  }
6952
6952
  };
6953
6953
  //#endregion
6954
+ //#region src/lib/packageDefaults.ts
6955
+ var DEFAULT_CONFIG = {
6956
+ viewOnly: false,
6957
+ floorMaxWidth: 600,
6958
+ floorMaxHeight: 400,
6959
+ heatmapEnabled: false,
6960
+ heatmapMatrix: [],
6961
+ projectName: void 0,
6962
+ selectedCameraSerial: null,
6963
+ showCameraCones: false,
6964
+ showCameraLabels: true,
6965
+ cameraHeatmapMatrix: []
6966
+ };
6967
+ function normalizeConfig(value) {
6968
+ if (!value || typeof value !== "object") return { ...DEFAULT_CONFIG };
6969
+ return {
6970
+ ...DEFAULT_CONFIG,
6971
+ ...value
6972
+ };
6973
+ }
6974
+ function normalizeFloorData(data) {
6975
+ if (!data || typeof data !== "object") return createDefaultProject();
6976
+ if (!Array.isArray(data.floors) || data.floors.length === 0) return createDefaultProject();
6977
+ if (!data.activeFloorId || !data.floors.some((f) => f.id === data.activeFloorId)) return {
6978
+ ...createDefaultProject(),
6979
+ ...data,
6980
+ floors: data.floors,
6981
+ activeFloorId: data.floors[0].id
6982
+ };
6983
+ return data;
6984
+ }
6985
+ var RUNTIME_FURNITURE_FIELDS = [
6986
+ "showHeatmap",
6987
+ "heatmapMatrix",
6988
+ "hasPerson"
6989
+ ];
6990
+ /** Strip runtime-only fields before persisting or dispatching floor:save. */
6991
+ function exportProjectForSave(project) {
6992
+ const exported = JSON.parse(JSON.stringify(project));
6993
+ exported.updatedAt = /* @__PURE__ */ new Date();
6994
+ for (const floor of exported.floors) floor.furniture = floor.furniture.map((item) => {
6995
+ const clean = { ...item };
6996
+ for (const key of RUNTIME_FURNITURE_FIELDS) delete clean[key];
6997
+ return clean;
6998
+ });
6999
+ return exported;
7000
+ }
7001
+ //#endregion
6954
7002
  //#region src/lib/utils/furnitureCatalog.ts
6955
7003
  var furnitureCatalog = [
6956
7004
  {
@@ -56762,7 +56810,7 @@ async function autoSave(onDispatch) {
56762
56810
  try {
56763
56811
  const thumbnail = captureThumbnail(p.id);
56764
56812
  onDispatch("floor:autoSave", { data: {
56765
- ...p,
56813
+ ...exportProjectForSave(p),
56766
56814
  thumbnail
56767
56815
  } });
56768
56816
  saveState.set("saved");
@@ -56947,9 +56995,10 @@ function TopBar($$anchor, $$props) {
56947
56995
  }
56948
56996
  async function save() {
56949
56997
  const p = get$1(currentProject);
56998
+ if (!p) return;
56950
56999
  const thumbnail = captureThumbnail(p.id);
56951
57000
  $$props.onDispatch("floor:save", { data: {
56952
- ...p,
57001
+ ...exportProjectForSave(p),
56953
57002
  thumbnail
56954
57003
  } });
56955
57004
  }
@@ -61948,8 +61997,17 @@ function drawFurnitureIcon(ctx, catalogId, w, d, color, strokeColor, heatmapMatr
61948
61997
  }
61949
61998
  //#endregion
61950
61999
  //#region src/lib/utils/shortcuts.ts
62000
+ /** True when the user is typing in a form field — canvas shortcuts should not run. */
62001
+ function isEditableTarget(e) {
62002
+ const el = e.target;
62003
+ if (!el) return false;
62004
+ const tag = el.tagName;
62005
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
62006
+ if (el.isContentEditable) return true;
62007
+ return !!el.closest("[contenteditable=\"true\"]");
62008
+ }
61951
62009
  function handleGlobalShortcut(e, ctx = {}) {
61952
- var _e$target;
62010
+ if (isEditableTarget(e)) return false;
61953
62011
  const mod = e.metaKey || e.ctrlKey;
61954
62012
  if (mod && e.key === "z" && !e.shiftKey) {
61955
62013
  e.preventDefault();
@@ -61970,8 +62028,6 @@ function handleGlobalShortcut(e, ctx = {}) {
61970
62028
  }
61971
62029
  return true;
61972
62030
  }
61973
- const tag = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName;
61974
- if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return false;
61975
62031
  if (e.key === "Escape") {
61976
62032
  selectedTool.set("select");
61977
62033
  selectedElementId.set(null);
@@ -63356,7 +63412,7 @@ function drawWindowDistanceDimensions(cs, wall, window, dimSettings) {
63356
63412
  }
63357
63413
  }
63358
63414
  function drawFurnitureItem(cs, item, selected, options) {
63359
- var _item$scale$x, _item$scale, _item$scale$y, _item$scale2, _item$width, _item$depth, _options$showCameraCo, _options$showCameraLa, _item$color;
63415
+ var _item$scale$x, _item$scale, _item$scale$y, _item$scale2, _item$width, _item$depth, _options$showCameraCo, _options$showCameraLa, _options$cameraHeatma, _item$color;
63360
63416
  const { ctx, zoom } = cs;
63361
63417
  const cat = getCatalogItem(item.catalogId);
63362
63418
  if (!cat) return;
@@ -63370,6 +63426,9 @@ function drawFurnitureItem(cs, item, selected, options) {
63370
63426
  const showCameraCones = (_options$showCameraCo = options === null || options === void 0 ? void 0 : options.showCameraCones) !== null && _options$showCameraCo !== void 0 ? _options$showCameraCo : false;
63371
63427
  const showCameraLabels = (_options$showCameraLa = options === null || options === void 0 ? void 0 : options.showCameraLabels) !== null && _options$showCameraLa !== void 0 ? _options$showCameraLa : true;
63372
63428
  const isCamera = item.catalogId === "camera";
63429
+ const useConfigHeatmap = isCamera && highlighted && !!(options === null || options === void 0 || (_options$cameraHeatma = options.cameraHeatmapMatrix) === null || _options$cameraHeatma === void 0 ? void 0 : _options$cameraHeatma.length);
63430
+ const drawHeatmapMatrix = useConfigHeatmap ? options.cameraHeatmapMatrix : item.heatmapMatrix;
63431
+ const drawShowHeatmap = item.showHeatmap || useConfigHeatmap;
63373
63432
  ctx.save();
63374
63433
  ctx.translate(s.x, s.y);
63375
63434
  ctx.rotate(angle);
@@ -63377,7 +63436,7 @@ function drawFurnitureItem(cs, item, selected, options) {
63377
63436
  const itemColor = (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : cat.color;
63378
63437
  const strokeColor = selected ? "#3b82f6" : itemColor;
63379
63438
  ctx.lineWidth = selected ? 2 : 1;
63380
- drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, item.heatmapMatrix, item.hasPerson, item.showHeatmap, isCamera ? showCameraCones : false, isCamera ? highlighted : false);
63439
+ drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, drawHeatmapMatrix, item.hasPerson, drawShowHeatmap, isCamera ? showCameraCones : false, isCamera ? highlighted : false);
63381
63440
  const fontSize = Math.max(8, Math.min(12, Math.min(w, d) * .2));
63382
63441
  if (showCameraLabels && Math.min(w, d) > 20) {
63383
63442
  var _item$name;
@@ -64586,7 +64645,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64586
64645
  const $panMode = () => store_get(panMode, "$panMode", $$stores);
64587
64646
  const $projectSettings = () => store_get(projectSettings, "$projectSettings", $$stores);
64588
64647
  const [$$stores, $$cleanup] = setup_stores();
64589
- let selectedCameraSerial = prop($$props, "selectedCameraSerial", 3, null), showCameraCones = prop($$props, "showCameraCones", 3, false), showCameraLabels = prop($$props, "showCameraLabels", 3, true);
64648
+ let selectedCameraSerial = prop($$props, "selectedCameraSerial", 3, null), showCameraCones = prop($$props, "showCameraCones", 3, false), showCameraLabels = prop($$props, "showCameraLabels", 3, true), cameraHeatmapMatrix = prop($$props, "cameraHeatmapMatrix", 19, () => []);
64590
64649
  let canvas;
64591
64650
  let ctx;
64592
64651
  let width = /* @__PURE__ */ state(800);
@@ -64678,6 +64737,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64678
64737
  selectedCameraSerial();
64679
64738
  showCameraCones();
64680
64739
  showCameraLabels();
64740
+ cameraHeatmapMatrix();
64681
64741
  $$props.projectName;
64682
64742
  $$props.heatmapEnabled;
64683
64743
  $$props.heatmapMatrix;
@@ -65121,7 +65181,8 @@ function FloorPlanCanvas($$anchor, $$props) {
65121
65181
  drawFurnitureItem(getCS(), item, selected, {
65122
65182
  selectedCameraSerial: selectedCameraSerial(),
65123
65183
  showCameraCones: showCameraCones(),
65124
- showCameraLabels: showCameraLabels()
65184
+ showCameraLabels: showCameraLabels(),
65185
+ cameraHeatmapMatrix: cameraHeatmapMatrix()
65125
65186
  });
65126
65187
  }
65127
65188
  let placementWallSnap = /* @__PURE__ */ state(null);
@@ -68505,6 +68566,7 @@ function FloorPlanCanvas($$anchor, $$props) {
68505
68566
  }
68506
68567
  function onKeyDown(e) {
68507
68568
  if ($$props.viewOnly) return;
68569
+ if (isEditableTarget(e)) return;
68508
68570
  set(shiftDown, e.shiftKey, true);
68509
68571
  if (e.code === "Space") {
68510
68572
  set(spaceDown, true);
@@ -70552,37 +70614,6 @@ function OnboardingTooltip($$anchor, $$props) {
70552
70614
  }
70553
70615
  delegate(["click"]);
70554
70616
  //#endregion
70555
- //#region src/lib/packageDefaults.ts
70556
- var DEFAULT_CONFIG = {
70557
- viewOnly: false,
70558
- floorMaxWidth: 600,
70559
- floorMaxHeight: 400,
70560
- heatmapEnabled: false,
70561
- heatmapMatrix: [],
70562
- projectName: void 0,
70563
- selectedCameraSerial: null,
70564
- showCameraCones: false,
70565
- showCameraLabels: true
70566
- };
70567
- function normalizeConfig(value) {
70568
- if (!value || typeof value !== "object") return { ...DEFAULT_CONFIG };
70569
- return {
70570
- ...DEFAULT_CONFIG,
70571
- ...value
70572
- };
70573
- }
70574
- function normalizeFloorData(data) {
70575
- if (!data || typeof data !== "object") return createDefaultProject();
70576
- if (!Array.isArray(data.floors) || data.floors.length === 0) return createDefaultProject();
70577
- if (!data.activeFloorId || !data.floors.some((f) => f.id === data.activeFloorId)) return {
70578
- ...createDefaultProject(),
70579
- ...data,
70580
- floors: data.floors,
70581
- activeFloorId: data.floors[0].id
70582
- };
70583
- return data;
70584
- }
70585
- //#endregion
70586
70617
  //#region src/App.svelte
70587
70618
  init_client();
70588
70619
  init_index_client();
@@ -70629,12 +70660,12 @@ function App($$anchor, $$props) {
70629
70660
  });
70630
70661
  var fragment = root();
70631
70662
  event("keydown", $window, (e) => {
70632
- var _e$target, _e$target2, _e$target3;
70663
+ if (isEditableTarget(e)) return;
70633
70664
  if (e.key === "p" && (e.ctrlKey || e.metaKey)) {
70634
70665
  e.preventDefault();
70635
70666
  set(printOpen, true);
70636
70667
  }
70637
- if (e.key === "k" && (e.ctrlKey || e.metaKey) || e.key === "/" && !e.ctrlKey && !e.metaKey && ((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName) !== "INPUT" && ((_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.tagName) !== "TEXTAREA") {
70668
+ if (e.key === "k" && (e.ctrlKey || e.metaKey) || e.key === "/" && !e.ctrlKey && !e.metaKey) {
70638
70669
  e.preventDefault();
70639
70670
  set(commandPaletteOpen, !get(commandPaletteOpen));
70640
70671
  }
@@ -70643,7 +70674,7 @@ function App($$anchor, $$props) {
70643
70674
  e.preventDefault();
70644
70675
  }
70645
70676
  if (e.key === "Escape" && get(showHelp)) set(showHelp, false);
70646
- if (e.key === "l" && !e.ctrlKey && !e.metaKey && !e.altKey && ((_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.tagName) !== "INPUT") set(showLayers, !get(showLayers));
70677
+ if (e.key === "l" && !e.ctrlKey && !e.metaKey && !e.altKey) set(showLayers, !get(showLayers));
70647
70678
  });
70648
70679
  var div = first_child(fragment);
70649
70680
  var node = child(div);
@@ -70730,6 +70761,10 @@ function App($$anchor, $$props) {
70730
70761
  var _$$get10;
70731
70762
  return (_$$get10 = get(config)) === null || _$$get10 === void 0 ? void 0 : _$$get10.showCameraLabels;
70732
70763
  });
70764
+ let $9 = /* @__PURE__ */ user_derived(() => {
70765
+ var _$$get11;
70766
+ return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.cameraHeatmapMatrix;
70767
+ });
70733
70768
  FloorPlanCanvas(node_3, {
70734
70769
  get viewOnly() {
70735
70770
  return get($0);
@@ -70757,6 +70792,9 @@ function App($$anchor, $$props) {
70757
70792
  },
70758
70793
  get showCameraLabels() {
70759
70794
  return get($8);
70795
+ },
70796
+ get cameraHeatmapMatrix() {
70797
+ return get($9);
70760
70798
  }
70761
70799
  });
70762
70800
  }