@blueharford/scrypted-spatial-awareness 0.4.1 → 0.4.2

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.
package/dist/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueharford/scrypted-spatial-awareness",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Cross-camera object tracking for Scrypted NVR with spatial awareness",
5
5
  "author": "Joshua Seidel <blueharford>",
6
6
  "license": "Apache-2.0",
@@ -342,8 +342,21 @@ export const EDITOR_HTML = `<!DOCTYPE html>
342
342
  if (response.ok) {
343
343
  topology = await response.json();
344
344
  if (!topology.drawings) topology.drawings = [];
345
+ // Load floor plan from separate storage (handles legacy imageData in topology too)
345
346
  if (topology.floorPlan?.imageData) {
347
+ // Legacy: imageData was stored in topology
346
348
  await loadFloorPlanImage(topology.floorPlan.imageData);
349
+ } else if (topology.floorPlan?.type === 'uploaded') {
350
+ // New: load from separate endpoint
351
+ try {
352
+ const fpResponse = await fetch('../api/floor-plan');
353
+ if (fpResponse.ok) {
354
+ const fpData = await fpResponse.json();
355
+ if (fpData.imageData) {
356
+ await loadFloorPlanImage(fpData.imageData);
357
+ }
358
+ }
359
+ } catch (err) { console.error('Failed to load floor plan:', err); }
347
360
  } else if (topology.floorPlan?.type === 'blank') {
348
361
  blankCanvasMode = true;
349
362
  }
@@ -976,7 +989,16 @@ export const EDITOR_HTML = `<!DOCTYPE html>
976
989
  reader.onload = async (e) => {
977
990
  const imageData = e.target.result;
978
991
  await loadFloorPlanImage(imageData);
979
- topology.floorPlan = { imageData, width: floorPlanImage.width, height: floorPlanImage.height };
992
+ // Store floor plan separately via API (not in topology JSON to avoid size issues)
993
+ try {
994
+ await fetch('../api/floor-plan', {
995
+ method: 'POST',
996
+ headers: { 'Content-Type': 'application/json' },
997
+ body: JSON.stringify({ imageData })
998
+ });
999
+ } catch (err) { console.error('Failed to save floor plan:', err); }
1000
+ // Store reference in topology (without the large imageData)
1001
+ topology.floorPlan = { type: 'uploaded', width: floorPlanImage.width, height: floorPlanImage.height };
980
1002
  closeModal('upload-modal');
981
1003
  render();
982
1004
  };
@@ -1138,7 +1160,7 @@ export const EDITOR_HTML = `<!DOCTYPE html>
1138
1160
  function updateConnectionName(id, value) { const conn = topology.connections.find(c => c.id === id); if (conn) conn.name = value; updateUI(); }
1139
1161
  function updateTransitTime(id, field, value) { const conn = topology.connections.find(c => c.id === id); if (conn) conn.transitTime[field] = parseInt(value) * 1000; }
1140
1162
  function updateConnectionBidi(id, value) { const conn = topology.connections.find(c => c.id === id); if (conn) conn.bidirectional = value; render(); }
1141
- function deleteCamera(id) { if (!confirm('Delete this camera?')) return; topology.cameras = topology.cameras.filter(c => c.deviceId !== id); topology.connections = topology.connections.filter(c => c.fromCameraId !== id && c.toCameraId !== id); selectedItem = null; document.getElementById('properties-panel').innerHTML = '<h3>Properties</h3><p style="color: #666;">Select a camera or connection.</p>'; updateUI(); render(); }
1163
+ function deleteCamera(id) { if (!confirm('Delete this camera?')) return; topology.cameras = topology.cameras.filter(c => c.deviceId !== id); topology.connections = topology.connections.filter(c => c.fromCameraId !== id && c.toCameraId !== id); selectedItem = null; document.getElementById('properties-panel').innerHTML = '<h3>Properties</h3><p style="color: #666;">Select a camera or connection.</p>'; updateCameraSelects(); updateUI(); render(); }
1142
1164
  function deleteConnection(id) { if (!confirm('Delete this connection?')) return; topology.connections = topology.connections.filter(c => c.id !== id); selectedItem = null; document.getElementById('properties-panel').innerHTML = '<h3>Properties</h3><p style="color: #666;">Select a camera or connection.</p>'; updateUI(); render(); }
1143
1165
  function setTool(tool) {
1144
1166
  currentTool = tool;