floor-editor-ts 1.3.11 → 1.3.12

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.
@@ -6472,7 +6472,7 @@ function addFurniture(catalogId, position) {
6472
6472
  }
6473
6473
  });
6474
6474
  }, `Added ${catalogId}`);
6475
- Promise.resolve().then(() => (init_onboarding_svelte(), onboarding_svelte_exports)).then((m) => m.triggerTip("first-furniture", position.x + 20, position.y + 20));
6475
+ if (!isAssignedCamerasSyncing()) Promise.resolve().then(() => (init_onboarding_svelte(), onboarding_svelte_exports)).then((m) => m.triggerTip("first-furniture", position.x + 20, position.y + 20));
6476
6476
  return id;
6477
6477
  }
6478
6478
  /** Move furniture without creating an undo snapshot on every call (used during drag).
@@ -57286,6 +57286,7 @@ function initAutoSave(onDispatch) {
57286
57286
  skipNext = false;
57287
57287
  return;
57288
57288
  }
57289
+ if (isAssignedCamerasSyncing()) return;
57289
57290
  if (!_p) return;
57290
57291
  markDirty(onDispatch);
57291
57292
  });
@@ -57333,6 +57334,12 @@ async function autoSave(onDispatch) {
57333
57334
  saveState.set("unsaved");
57334
57335
  }
57335
57336
  }
57337
+ /** Mark as saved without triggering dirty (e.g. after loadProject) */
57338
+ function markClean() {
57339
+ if (debounceTimer) clearTimeout(debounceTimer);
57340
+ saveState.set("saved");
57341
+ skipNext = true;
57342
+ }
57336
57343
  //#endregion
57337
57344
  //#region src/lib/components/toolbar/VersionHistoryPanel.svelte
57338
57345
  init_client();
@@ -65744,13 +65751,16 @@ function FloorPlanCanvas($$anchor, $$props) {
65744
65751
  };
65745
65752
  }
65746
65753
  user_effect(() => {
65747
- canvasZoom.set(get(zoom));
65754
+ const z = get(zoom);
65755
+ if (get$1(canvasZoom) !== z) canvasZoom.set(z);
65748
65756
  });
65749
65757
  user_effect(() => {
65750
- canvasCamX.set(get(camX));
65758
+ const x = get(camX);
65759
+ if (get$1(canvasCamX) !== x) canvasCamX.set(x);
65751
65760
  });
65752
65761
  user_effect(() => {
65753
- canvasCamY.set(get(camY));
65762
+ const y = get(camY);
65763
+ if (get$1(canvasCamY) !== y) canvasCamY.set(y);
65754
65764
  });
65755
65765
  let wallStart = /* @__PURE__ */ state(null);
65756
65766
  let wallSequenceFirst = /* @__PURE__ */ state(null);
@@ -65847,7 +65857,8 @@ function FloorPlanCanvas($$anchor, $$props) {
65847
65857
  }));
65848
65858
  let showFurniture = /* @__PURE__ */ user_derived(() => get(layerVis).furniture);
65849
65859
  user_effect(() => {
65850
- showFurnitureStore.set(get(layerVis).furniture);
65860
+ const on = get(layerVis).furniture;
65861
+ if (get$1(showFurnitureStore) !== on) showFurnitureStore.set(on);
65851
65862
  });
65852
65863
  let showDoors = /* @__PURE__ */ user_derived(() => get(layerVis).doors);
65853
65864
  let showWindows = /* @__PURE__ */ user_derived(() => get(layerVis).windows);
@@ -70844,17 +70855,18 @@ function OnboardingTooltip($$anchor, $$props) {
70844
70855
  let visible = /* @__PURE__ */ state(false);
70845
70856
  let autoTimer = null;
70846
70857
  user_effect(() => {
70847
- if (activeTipState.current) {
70848
- set(visible, false);
70858
+ const tip = activeTipState.current;
70859
+ if (tip) {
70860
+ if (get(visible)) set(visible, false);
70849
70861
  requestAnimationFrame(() => {
70850
- set(visible, true);
70862
+ if (activeTipState.current === tip) set(visible, true);
70851
70863
  });
70852
70864
  if (autoTimer) clearTimeout(autoTimer);
70853
70865
  autoTimer = setTimeout(() => {
70854
70866
  dismissTip();
70855
70867
  }, 8e3);
70856
70868
  } else {
70857
- set(visible, false);
70869
+ if (get(visible)) set(visible, false);
70858
70870
  if (autoTimer) {
70859
70871
  clearTimeout(autoTimer);
70860
70872
  autoTimer = null;
@@ -71114,38 +71126,80 @@ function App($$anchor, $$props) {
71114
71126
  let config = /* @__PURE__ */ state(proxy({ ...DEFAULT_CONFIG }));
71115
71127
  let activeFloorId = /* @__PURE__ */ state(null);
71116
71128
  let activeFloorWallCount = /* @__PURE__ */ state(0);
71117
- (_$$props$stores = $$props.stores) === null || _$$props$stores === void 0 || _$$props$stores.floorData.subscribe((v) => set(floorData, v, true));
71118
- (_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => set(config, normalizeConfig(v), true));
71129
+ /** Latest assignedCameras from host config — sync is NOT in $effect (avoids depth loops). */
71130
+ let latestAssigned = [];
71131
+ let assignedSyncTimer = null;
71132
+ let lastScheduledAssignKey = "";
71133
+ let lastScheduledFloorKey = "";
71134
+ let lastFloorDataKey = "";
71135
+ function assignedKey(list) {
71136
+ return list.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("|");
71143
+ }
71144
+ function scheduleAssignedCamerasSync(_reason) {
71145
+ var _$$get;
71146
+ const aKey = assignedKey(latestAssigned);
71147
+ const fKey = `${(_$$get = get(activeFloorId)) !== null && _$$get !== void 0 ? _$$get : ""}:${get(activeFloorWallCount)}`;
71148
+ if (aKey === lastScheduledAssignKey && fKey === lastScheduledFloorKey && assignedSyncTimer != null) return;
71149
+ lastScheduledAssignKey = aKey;
71150
+ lastScheduledFloorKey = fKey;
71151
+ if (assignedSyncTimer != null) clearTimeout(assignedSyncTimer);
71152
+ assignedSyncTimer = setTimeout(() => {
71153
+ assignedSyncTimer = null;
71154
+ syncAssignedCameras(latestAssigned);
71155
+ }, 0);
71156
+ }
71157
+ function applyFloorData(v) {
71158
+ set(floorData, v, true);
71159
+ let key = "";
71160
+ try {
71161
+ key = JSON.stringify(v !== null && v !== void 0 ? v : null);
71162
+ } catch (_unused) {
71163
+ key = String(Date.now());
71164
+ }
71165
+ if (key === lastFloorDataKey) return;
71166
+ lastFloorDataKey = key;
71167
+ resetAssignedCamerasSyncState();
71168
+ lastScheduledAssignKey = "";
71169
+ lastScheduledFloorKey = "";
71170
+ currentProject.set(normalizeFloorData(v));
71171
+ markClean();
71172
+ scheduleAssignedCamerasSync("floor");
71173
+ }
71174
+ (_$$props$stores = $$props.stores) === null || _$$props$stores === void 0 || _$$props$stores.floorData.subscribe((v) => applyFloorData(v));
71175
+ (_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => {
71176
+ var _next$assignedCameras;
71177
+ const next = normalizeConfig(v);
71178
+ set(config, next, true);
71179
+ latestAssigned = (_next$assignedCameras = next.assignedCameras) !== null && _next$assignedCameras !== void 0 ? _next$assignedCameras : [];
71180
+ if (next.cameraThumbnailOpacity != null && get$1(cameraThumbnailOpacity) !== next.cameraThumbnailOpacity) cameraThumbnailOpacity.set(next.cameraThumbnailOpacity);
71181
+ if (next.projectName) {
71182
+ const proj = get$1(currentProject);
71183
+ if (proj && proj.name !== next.projectName) currentProject.update((p) => p ? {
71184
+ ...p,
71185
+ name: next.projectName
71186
+ } : p);
71187
+ }
71188
+ scheduleAssignedCamerasSync("config");
71189
+ });
71119
71190
  activeFloor.subscribe((f) => {
71120
71191
  var _f$id, _f$walls$length, _f$walls;
71121
71192
  const id = (_f$id = f === null || f === void 0 ? void 0 : f.id) !== null && _f$id !== void 0 ? _f$id : null;
71122
71193
  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;
71194
+ const floorChanged = id !== get(activeFloorId) || walls !== get(activeFloorWallCount);
71123
71195
  if (id !== get(activeFloorId)) set(activeFloorId, id, true);
71124
71196
  if (walls !== get(activeFloorWallCount)) set(activeFloorWallCount, walls, true);
71197
+ if (floorChanged) scheduleAssignedCamerasSync("floor");
71125
71198
  });
71126
71199
  user_effect(() => {
71127
71200
  setFloorCallbackDispatcher($$props.onDispatch ? (eventName, detail) => $$props.onDispatch(eventName, detail) : null);
71128
71201
  return () => setFloorCallbackDispatcher(null);
71129
71202
  });
71130
- user_effect(() => {
71131
- if (get(config).cameraThumbnailOpacity != null) cameraThumbnailOpacity.set(get(config).cameraThumbnailOpacity);
71132
- });
71133
- user_effect(() => {
71134
- var _$$get$assignedCamera;
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("|");
71143
- get(activeFloorId);
71144
- get(activeFloorWallCount);
71145
- untrack(() => {
71146
- syncAssignedCameras(assigned);
71147
- });
71148
- });
71149
71203
  let commandPaletteOpen = /* @__PURE__ */ state(false);
71150
71204
  let printOpen = /* @__PURE__ */ state(false);
71151
71205
  let mode = /* @__PURE__ */ state("2d");
@@ -71154,27 +71208,18 @@ function App($$anchor, $$props) {
71154
71208
  viewMode.subscribe((m) => {
71155
71209
  set(mode, m, true);
71156
71210
  });
71157
- user_effect(() => {
71158
- resetAssignedCamerasSyncState();
71159
- currentProject.set(normalizeFloorData(get(floorData)));
71160
- });
71161
- user_effect(() => {
71162
- if (!get(config).projectName) return;
71163
- currentProject.update((p) => p ? {
71164
- ...p,
71165
- name: get(config).projectName
71166
- } : p);
71167
- });
71168
71211
  onMount(() => {
71169
71212
  let saveTimeout;
71170
71213
  const unsub = currentProject.subscribe((p) => {
71171
71214
  if (!p) return;
71215
+ if (isAssignedCamerasSyncing()) return;
71172
71216
  clearTimeout(saveTimeout);
71173
71217
  saveTimeout = setTimeout(() => localStore.save(p), 500);
71174
71218
  });
71175
71219
  return () => {
71176
71220
  unsub();
71177
71221
  clearTimeout(saveTimeout);
71222
+ if (assignedSyncTimer != null) clearTimeout(assignedSyncTimer);
71178
71223
  };
71179
71224
  });
71180
71225
  var fragment = root();
@@ -71260,8 +71305,8 @@ function App($$anchor, $$props) {
71260
71305
  append($$anchor, div_2);
71261
71306
  };
71262
71307
  if_block(node_1, ($$render) => {
71263
- var _$$get;
71264
- if (get(mode) === "2d" && !((_$$get = get(config)) === null || _$$get === void 0 ? void 0 : _$$get.viewOnly)) $$render(consequent_1);
71308
+ var _$$get2;
71309
+ if (get(mode) === "2d" && !((_$$get2 = get(config)) === null || _$$get2 === void 0 ? void 0 : _$$get2.viewOnly)) $$render(consequent_1);
71265
71310
  });
71266
71311
  var div_4 = sibling(node_1, 2);
71267
71312
  var node_3 = child(div_4);
@@ -71270,56 +71315,56 @@ function App($$anchor, $$props) {
71270
71315
  var node_4 = first_child(fragment_2);
71271
71316
  {
71272
71317
  let $0 = /* @__PURE__ */ user_derived(() => {
71273
- var _$$get2;
71274
- return (_$$get2 = get(config)) === null || _$$get2 === void 0 ? void 0 : _$$get2.viewOnly;
71318
+ var _$$get3;
71319
+ return (_$$get3 = get(config)) === null || _$$get3 === void 0 ? void 0 : _$$get3.viewOnly;
71275
71320
  });
71276
71321
  let $1 = /* @__PURE__ */ user_derived(() => {
71277
- var _$$get3;
71278
- return (_$$get3 = get(config)) === null || _$$get3 === void 0 ? void 0 : _$$get3.floorMaxWidth;
71322
+ var _$$get4;
71323
+ return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxWidth;
71279
71324
  });
71280
71325
  let $2 = /* @__PURE__ */ user_derived(() => {
71281
- var _$$get4;
71282
- return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxHeight;
71326
+ var _$$get5;
71327
+ return (_$$get5 = get(config)) === null || _$$get5 === void 0 ? void 0 : _$$get5.floorMaxHeight;
71283
71328
  });
71284
71329
  let $3 = /* @__PURE__ */ user_derived(() => {
71285
- var _$$get5;
71286
- return (_$$get5 = get(config)) === null || _$$get5 === void 0 ? void 0 : _$$get5.heatmapMatrix;
71330
+ var _$$get6;
71331
+ return (_$$get6 = get(config)) === null || _$$get6 === void 0 ? void 0 : _$$get6.heatmapMatrix;
71287
71332
  });
71288
71333
  let $4 = /* @__PURE__ */ user_derived(() => {
71289
- var _$$get6;
71290
- return (_$$get6 = get(config)) === null || _$$get6 === void 0 ? void 0 : _$$get6.heatmapEnabled;
71334
+ var _$$get7;
71335
+ return (_$$get7 = get(config)) === null || _$$get7 === void 0 ? void 0 : _$$get7.heatmapEnabled;
71291
71336
  });
71292
71337
  let $5 = /* @__PURE__ */ user_derived(() => {
71293
- var _$$get7;
71294
- return (_$$get7 = get(config)) === null || _$$get7 === void 0 ? void 0 : _$$get7.heatmapColorScale;
71338
+ var _$$get8;
71339
+ return (_$$get8 = get(config)) === null || _$$get8 === void 0 ? void 0 : _$$get8.heatmapColorScale;
71295
71340
  });
71296
71341
  let $6 = /* @__PURE__ */ user_derived(() => {
71297
- var _$$get8;
71298
- return (_$$get8 = get(config)) === null || _$$get8 === void 0 ? void 0 : _$$get8.selectedCameraSerial;
71342
+ var _$$get9;
71343
+ return (_$$get9 = get(config)) === null || _$$get9 === void 0 ? void 0 : _$$get9.selectedCameraSerial;
71299
71344
  });
71300
71345
  let $7 = /* @__PURE__ */ user_derived(() => {
71301
- var _$$get9;
71302
- return (_$$get9 = get(config)) === null || _$$get9 === void 0 ? void 0 : _$$get9.showCameraCones;
71346
+ var _$$get10;
71347
+ return (_$$get10 = get(config)) === null || _$$get10 === void 0 ? void 0 : _$$get10.showCameraCones;
71303
71348
  });
71304
71349
  let $8 = /* @__PURE__ */ user_derived(() => {
71305
- var _$$get10;
71306
- return (_$$get10 = get(config)) === null || _$$get10 === void 0 ? void 0 : _$$get10.showCameraLabels;
71350
+ var _$$get11;
71351
+ return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.showCameraLabels;
71307
71352
  });
71308
71353
  let $9 = /* @__PURE__ */ user_derived(() => {
71309
- var _$$get11;
71310
- return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.cameraHeatmapMatrix;
71354
+ var _$$get12;
71355
+ return (_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraHeatmapMatrix;
71311
71356
  });
71312
71357
  let $10 = /* @__PURE__ */ user_derived(() => {
71313
- var _$$get12;
71314
- return ((_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraThumbnail) || "";
71358
+ var _$$get13;
71359
+ return ((_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.cameraThumbnail) || "";
71315
71360
  });
71316
71361
  let $11 = /* @__PURE__ */ user_derived(() => {
71317
- var _$$get13;
71318
- return (_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.canvasBackground;
71362
+ var _$$get14;
71363
+ return (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.canvasBackground;
71319
71364
  });
71320
71365
  let $12 = /* @__PURE__ */ user_derived(() => {
71321
- var _$$get14;
71322
- return (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.floorPlateBackground;
71366
+ var _$$get15;
71367
+ return (_$$get15 = get(config)) === null || _$$get15 === void 0 ? void 0 : _$$get15.floorPlateBackground;
71323
71368
  });
71324
71369
  FloorPlanCanvas(node_4, {
71325
71370
  get viewOnly() {
@@ -71388,12 +71433,12 @@ function App($$anchor, $$props) {
71388
71433
  {
71389
71434
  let $0 = /* @__PURE__ */ user_derived(() => get(mode) === "3d");
71390
71435
  let $1 = /* @__PURE__ */ user_derived(() => {
71391
- var _$$get$siteCameras, _$$get15;
71392
- return (_$$get$siteCameras = (_$$get15 = get(config)) === null || _$$get15 === void 0 ? void 0 : _$$get15.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
71436
+ var _$$get$siteCameras, _$$get16;
71437
+ return (_$$get$siteCameras = (_$$get16 = get(config)) === null || _$$get16 === void 0 ? void 0 : _$$get16.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
71393
71438
  });
71394
71439
  let $2 = /* @__PURE__ */ user_derived(() => {
71395
- var _$$get$cameraThumbnai, _$$get16;
71396
- return (_$$get$cameraThumbnai = (_$$get16 = get(config)) === null || _$$get16 === void 0 ? void 0 : _$$get16.cameraThumbnail) !== null && _$$get$cameraThumbnai !== void 0 ? _$$get$cameraThumbnai : "";
71440
+ var _$$get$cameraThumbnai, _$$get17;
71441
+ return (_$$get$cameraThumbnai = (_$$get17 = get(config)) === null || _$$get17 === void 0 ? void 0 : _$$get17.cameraThumbnail) !== null && _$$get$cameraThumbnai !== void 0 ? _$$get$cameraThumbnai : "";
71397
71442
  });
71398
71443
  PropertiesPanel($$anchor, {
71399
71444
  get is3D() {