floor-editor-ts 1.3.11 → 1.3.13

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,105 @@ 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 clearAssignedSyncTimer() {
71145
+ if (assignedSyncTimer != null) {
71146
+ clearTimeout(assignedSyncTimer);
71147
+ assignedSyncTimer = null;
71148
+ }
71149
+ }
71150
+ /**
71151
+ * viewOnly must never run assignedCameras sync.
71152
+ * Otherwise `assignedCameras: []` + leftover module `lastSyncedSerials`
71153
+ * (from an edit session / other instance) strips cameras loaded from floorData.
71154
+ */
71155
+ function scheduleAssignedCamerasSync(_reason) {
71156
+ var _$$get;
71157
+ if (get(config).viewOnly) return;
71158
+ const aKey = assignedKey(latestAssigned);
71159
+ const fKey = `${(_$$get = get(activeFloorId)) !== null && _$$get !== void 0 ? _$$get : ""}:${get(activeFloorWallCount)}`;
71160
+ if (aKey === lastScheduledAssignKey && fKey === lastScheduledFloorKey && assignedSyncTimer != null) return;
71161
+ lastScheduledAssignKey = aKey;
71162
+ lastScheduledFloorKey = fKey;
71163
+ clearAssignedSyncTimer();
71164
+ assignedSyncTimer = setTimeout(() => {
71165
+ assignedSyncTimer = null;
71166
+ if (get(config).viewOnly) return;
71167
+ syncAssignedCameras(latestAssigned);
71168
+ }, 0);
71169
+ }
71170
+ function applyFloorData(v) {
71171
+ set(floorData, v, true);
71172
+ let key = "";
71173
+ try {
71174
+ key = JSON.stringify(v !== null && v !== void 0 ? v : null);
71175
+ } catch (_unused) {
71176
+ key = String(Date.now());
71177
+ }
71178
+ if (key === lastFloorDataKey) return;
71179
+ lastFloorDataKey = key;
71180
+ resetAssignedCamerasSyncState();
71181
+ lastScheduledAssignKey = "";
71182
+ lastScheduledFloorKey = "";
71183
+ currentProject.set(normalizeFloorData(v));
71184
+ markClean();
71185
+ if (!get(config).viewOnly) scheduleAssignedCamerasSync("floor");
71186
+ }
71187
+ (_$$props$stores = $$props.stores) === null || _$$props$stores === void 0 || _$$props$stores.floorData.subscribe((v) => applyFloorData(v));
71188
+ (_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => {
71189
+ var _next$assignedCameras;
71190
+ const next = normalizeConfig(v);
71191
+ const wasViewOnly = get(config).viewOnly;
71192
+ set(config, next, true);
71193
+ latestAssigned = (_next$assignedCameras = next.assignedCameras) !== null && _next$assignedCameras !== void 0 ? _next$assignedCameras : [];
71194
+ if (next.cameraThumbnailOpacity != null && get$1(cameraThumbnailOpacity) !== next.cameraThumbnailOpacity) cameraThumbnailOpacity.set(next.cameraThumbnailOpacity);
71195
+ if (next.projectName) {
71196
+ const proj = get$1(currentProject);
71197
+ if (proj && proj.name !== next.projectName) currentProject.update((p) => p ? {
71198
+ ...p,
71199
+ name: next.projectName
71200
+ } : p);
71201
+ }
71202
+ if (next.viewOnly) {
71203
+ resetAssignedCamerasSyncState();
71204
+ lastScheduledAssignKey = "";
71205
+ lastScheduledFloorKey = "";
71206
+ clearAssignedSyncTimer();
71207
+ return;
71208
+ }
71209
+ if (wasViewOnly && !next.viewOnly) {
71210
+ lastScheduledAssignKey = "";
71211
+ lastScheduledFloorKey = "";
71212
+ }
71213
+ scheduleAssignedCamerasSync("config");
71214
+ });
71119
71215
  activeFloor.subscribe((f) => {
71120
71216
  var _f$id, _f$walls$length, _f$walls;
71121
71217
  const id = (_f$id = f === null || f === void 0 ? void 0 : f.id) !== null && _f$id !== void 0 ? _f$id : null;
71122
71218
  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;
71219
+ const floorChanged = id !== get(activeFloorId) || walls !== get(activeFloorWallCount);
71123
71220
  if (id !== get(activeFloorId)) set(activeFloorId, id, true);
71124
71221
  if (walls !== get(activeFloorWallCount)) set(activeFloorWallCount, walls, true);
71222
+ if (floorChanged && !get(config).viewOnly) scheduleAssignedCamerasSync("floor");
71125
71223
  });
71126
71224
  user_effect(() => {
71127
71225
  setFloorCallbackDispatcher($$props.onDispatch ? (eventName, detail) => $$props.onDispatch(eventName, detail) : null);
71128
71226
  return () => setFloorCallbackDispatcher(null);
71129
71227
  });
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
71228
  let commandPaletteOpen = /* @__PURE__ */ state(false);
71150
71229
  let printOpen = /* @__PURE__ */ state(false);
71151
71230
  let mode = /* @__PURE__ */ state("2d");
@@ -71154,27 +71233,18 @@ function App($$anchor, $$props) {
71154
71233
  viewMode.subscribe((m) => {
71155
71234
  set(mode, m, true);
71156
71235
  });
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
71236
  onMount(() => {
71169
71237
  let saveTimeout;
71170
71238
  const unsub = currentProject.subscribe((p) => {
71171
71239
  if (!p) return;
71240
+ if (isAssignedCamerasSyncing()) return;
71172
71241
  clearTimeout(saveTimeout);
71173
71242
  saveTimeout = setTimeout(() => localStore.save(p), 500);
71174
71243
  });
71175
71244
  return () => {
71176
71245
  unsub();
71177
71246
  clearTimeout(saveTimeout);
71247
+ clearAssignedSyncTimer();
71178
71248
  };
71179
71249
  });
71180
71250
  var fragment = root();
@@ -71260,8 +71330,8 @@ function App($$anchor, $$props) {
71260
71330
  append($$anchor, div_2);
71261
71331
  };
71262
71332
  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);
71333
+ var _$$get2;
71334
+ if (get(mode) === "2d" && !((_$$get2 = get(config)) === null || _$$get2 === void 0 ? void 0 : _$$get2.viewOnly)) $$render(consequent_1);
71265
71335
  });
71266
71336
  var div_4 = sibling(node_1, 2);
71267
71337
  var node_3 = child(div_4);
@@ -71270,56 +71340,56 @@ function App($$anchor, $$props) {
71270
71340
  var node_4 = first_child(fragment_2);
71271
71341
  {
71272
71342
  let $0 = /* @__PURE__ */ user_derived(() => {
71273
- var _$$get2;
71274
- return (_$$get2 = get(config)) === null || _$$get2 === void 0 ? void 0 : _$$get2.viewOnly;
71343
+ var _$$get3;
71344
+ return (_$$get3 = get(config)) === null || _$$get3 === void 0 ? void 0 : _$$get3.viewOnly;
71275
71345
  });
71276
71346
  let $1 = /* @__PURE__ */ user_derived(() => {
71277
- var _$$get3;
71278
- return (_$$get3 = get(config)) === null || _$$get3 === void 0 ? void 0 : _$$get3.floorMaxWidth;
71347
+ var _$$get4;
71348
+ return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxWidth;
71279
71349
  });
71280
71350
  let $2 = /* @__PURE__ */ user_derived(() => {
71281
- var _$$get4;
71282
- return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxHeight;
71351
+ var _$$get5;
71352
+ return (_$$get5 = get(config)) === null || _$$get5 === void 0 ? void 0 : _$$get5.floorMaxHeight;
71283
71353
  });
71284
71354
  let $3 = /* @__PURE__ */ user_derived(() => {
71285
- var _$$get5;
71286
- return (_$$get5 = get(config)) === null || _$$get5 === void 0 ? void 0 : _$$get5.heatmapMatrix;
71355
+ var _$$get6;
71356
+ return (_$$get6 = get(config)) === null || _$$get6 === void 0 ? void 0 : _$$get6.heatmapMatrix;
71287
71357
  });
71288
71358
  let $4 = /* @__PURE__ */ user_derived(() => {
71289
- var _$$get6;
71290
- return (_$$get6 = get(config)) === null || _$$get6 === void 0 ? void 0 : _$$get6.heatmapEnabled;
71359
+ var _$$get7;
71360
+ return (_$$get7 = get(config)) === null || _$$get7 === void 0 ? void 0 : _$$get7.heatmapEnabled;
71291
71361
  });
71292
71362
  let $5 = /* @__PURE__ */ user_derived(() => {
71293
- var _$$get7;
71294
- return (_$$get7 = get(config)) === null || _$$get7 === void 0 ? void 0 : _$$get7.heatmapColorScale;
71363
+ var _$$get8;
71364
+ return (_$$get8 = get(config)) === null || _$$get8 === void 0 ? void 0 : _$$get8.heatmapColorScale;
71295
71365
  });
71296
71366
  let $6 = /* @__PURE__ */ user_derived(() => {
71297
- var _$$get8;
71298
- return (_$$get8 = get(config)) === null || _$$get8 === void 0 ? void 0 : _$$get8.selectedCameraSerial;
71367
+ var _$$get9;
71368
+ return (_$$get9 = get(config)) === null || _$$get9 === void 0 ? void 0 : _$$get9.selectedCameraSerial;
71299
71369
  });
71300
71370
  let $7 = /* @__PURE__ */ user_derived(() => {
71301
- var _$$get9;
71302
- return (_$$get9 = get(config)) === null || _$$get9 === void 0 ? void 0 : _$$get9.showCameraCones;
71371
+ var _$$get10;
71372
+ return (_$$get10 = get(config)) === null || _$$get10 === void 0 ? void 0 : _$$get10.showCameraCones;
71303
71373
  });
71304
71374
  let $8 = /* @__PURE__ */ user_derived(() => {
71305
- var _$$get10;
71306
- return (_$$get10 = get(config)) === null || _$$get10 === void 0 ? void 0 : _$$get10.showCameraLabels;
71375
+ var _$$get11;
71376
+ return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.showCameraLabels;
71307
71377
  });
71308
71378
  let $9 = /* @__PURE__ */ user_derived(() => {
71309
- var _$$get11;
71310
- return (_$$get11 = get(config)) === null || _$$get11 === void 0 ? void 0 : _$$get11.cameraHeatmapMatrix;
71379
+ var _$$get12;
71380
+ return (_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraHeatmapMatrix;
71311
71381
  });
71312
71382
  let $10 = /* @__PURE__ */ user_derived(() => {
71313
- var _$$get12;
71314
- return ((_$$get12 = get(config)) === null || _$$get12 === void 0 ? void 0 : _$$get12.cameraThumbnail) || "";
71383
+ var _$$get13;
71384
+ return ((_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.cameraThumbnail) || "";
71315
71385
  });
71316
71386
  let $11 = /* @__PURE__ */ user_derived(() => {
71317
- var _$$get13;
71318
- return (_$$get13 = get(config)) === null || _$$get13 === void 0 ? void 0 : _$$get13.canvasBackground;
71387
+ var _$$get14;
71388
+ return (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.canvasBackground;
71319
71389
  });
71320
71390
  let $12 = /* @__PURE__ */ user_derived(() => {
71321
- var _$$get14;
71322
- return (_$$get14 = get(config)) === null || _$$get14 === void 0 ? void 0 : _$$get14.floorPlateBackground;
71391
+ var _$$get15;
71392
+ return (_$$get15 = get(config)) === null || _$$get15 === void 0 ? void 0 : _$$get15.floorPlateBackground;
71323
71393
  });
71324
71394
  FloorPlanCanvas(node_4, {
71325
71395
  get viewOnly() {
@@ -71388,12 +71458,12 @@ function App($$anchor, $$props) {
71388
71458
  {
71389
71459
  let $0 = /* @__PURE__ */ user_derived(() => get(mode) === "3d");
71390
71460
  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 : [];
71461
+ var _$$get$siteCameras, _$$get16;
71462
+ return (_$$get$siteCameras = (_$$get16 = get(config)) === null || _$$get16 === void 0 ? void 0 : _$$get16.siteCameras) !== null && _$$get$siteCameras !== void 0 ? _$$get$siteCameras : [];
71393
71463
  });
71394
71464
  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 : "";
71465
+ var _$$get$cameraThumbnai, _$$get17;
71466
+ return (_$$get$cameraThumbnai = (_$$get17 = get(config)) === null || _$$get17 === void 0 ? void 0 : _$$get17.cameraThumbnail) !== null && _$$get$cameraThumbnai !== void 0 ? _$$get$cameraThumbnai : "";
71397
71467
  });
71398
71468
  PropertiesPanel($$anchor, {
71399
71469
  get is3D() {
@@ -71542,7 +71612,11 @@ var FloorEditor = class extends HTMLElement {
71542
71612
  _classPrivateFieldInitSpec(this, _wrapper, null);
71543
71613
  _classPrivateFieldInitSpec(this, _store, {
71544
71614
  floorData: writable(null),
71545
- config: writable(DEFAULT_CONFIG)
71615
+ /** Default viewOnly — host sets viewOnly:false for the editor instance. */
71616
+ config: writable({
71617
+ ...DEFAULT_CONFIG,
71618
+ viewOnly: true
71619
+ })
71546
71620
  });
71547
71621
  }
71548
71622
  connectedCallback() {