@blueharford/scrypted-spatial-awareness 0.6.19 → 0.6.21
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/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.map +1 -1
- package/dist/plugin.zip +0 -0
- package/out/main.nodejs.js +41 -2
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/main.ts +6 -0
- package/src/ui/editor-html.ts +35 -2
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/out/main.nodejs.js
CHANGED
|
@@ -40027,6 +40027,7 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
|
|
|
40027
40027
|
if (request.method === 'GET') {
|
|
40028
40028
|
const topologyJson = this.storage.getItem('topology');
|
|
40029
40029
|
const topology = topologyJson ? JSON.parse(topologyJson) : (0, topology_1.createEmptyTopology)();
|
|
40030
|
+
this.console.log(`[Topology API] GET - drawnZones: ${topology.drawnZones?.length || 0}`);
|
|
40030
40031
|
response.send(JSON.stringify(topology), {
|
|
40031
40032
|
headers: { 'Content-Type': 'application/json' },
|
|
40032
40033
|
});
|
|
@@ -40034,6 +40035,10 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
|
|
|
40034
40035
|
else if (request.method === 'PUT' || request.method === 'POST') {
|
|
40035
40036
|
try {
|
|
40036
40037
|
const topology = JSON.parse(request.body);
|
|
40038
|
+
this.console.log(`[Topology API] PUT received - drawnZones: ${topology.drawnZones?.length || 0}`);
|
|
40039
|
+
if (topology.drawnZones?.length) {
|
|
40040
|
+
this.console.log(`[Topology API] Zone names: ${topology.drawnZones.map(z => z.name).join(', ')}`);
|
|
40041
|
+
}
|
|
40037
40042
|
this.storage.setItem('topology', JSON.stringify(topology));
|
|
40038
40043
|
await this.startTrackingEngine(topology);
|
|
40039
40044
|
response.send(JSON.stringify({ success: true }), {
|
|
@@ -40041,6 +40046,7 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
|
|
|
40041
40046
|
});
|
|
40042
40047
|
}
|
|
40043
40048
|
catch (e) {
|
|
40049
|
+
this.console.error(`[Topology API] PUT error:`, e);
|
|
40044
40050
|
response.send(JSON.stringify({ error: 'Invalid topology JSON' }), {
|
|
40045
40051
|
code: 400,
|
|
40046
40052
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -42281,6 +42287,8 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
42281
42287
|
<button class="btn" id="tool-wall" onclick="setTool('wall')">Draw Wall</button>
|
|
42282
42288
|
<button class="btn" id="tool-room" onclick="setTool('room')">Draw Room</button>
|
|
42283
42289
|
<button class="btn" id="tool-zone" onclick="setTool('zone')" style="background: #2e7d32;">Draw Zone</button>
|
|
42290
|
+
<button class="btn" id="finish-zone-btn" onclick="finishZoneDrawing()" style="background: #1976d2; display: none;">Finish Zone</button>
|
|
42291
|
+
<button class="btn" id="cancel-zone-btn" onclick="cancelZoneDrawing()" style="background: #dc2626; display: none;">Cancel Zone</button>
|
|
42284
42292
|
<button class="btn" id="tool-camera" onclick="setTool('camera')">Place Camera</button>
|
|
42285
42293
|
<button class="btn" id="tool-landmark" onclick="setTool('landmark')">Place Landmark</button>
|
|
42286
42294
|
<button class="btn" id="tool-connect" onclick="setTool('connect')">Connect</button>
|
|
@@ -42518,6 +42526,8 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
42518
42526
|
let zoneDrawingMode = false;
|
|
42519
42527
|
let currentZonePoints = [];
|
|
42520
42528
|
let pendingZoneConfig = null;
|
|
42529
|
+
let lastClickTime = 0;
|
|
42530
|
+
const DOUBLE_CLICK_THRESHOLD = 400; // ms
|
|
42521
42531
|
|
|
42522
42532
|
// Zone colors by type
|
|
42523
42533
|
const ZONE_COLORS = {
|
|
@@ -43723,9 +43733,11 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
43723
43733
|
// Zone list
|
|
43724
43734
|
const zoneList = document.getElementById('zone-list');
|
|
43725
43735
|
const zones = topology.drawnZones || [];
|
|
43736
|
+
console.log('[updateUI] Zone list update - topology.drawnZones:', zones.length, 'zones');
|
|
43726
43737
|
if (zones.length === 0) {
|
|
43727
43738
|
zoneList.innerHTML = '<div class="zone-item" style="color: #666; text-align: center; cursor: default; padding: 8px;">No zones drawn</div>';
|
|
43728
43739
|
} else {
|
|
43740
|
+
console.log('[updateUI] Rendering', zones.length, 'zones:', zones.map(z => z.name).join(', '));
|
|
43729
43741
|
zoneList.innerHTML = zones.map(z => {
|
|
43730
43742
|
const color = ZONE_STROKE_COLORS[z.type] || ZONE_STROKE_COLORS.custom;
|
|
43731
43743
|
return '<div class="camera-item ' + (selectedItem?.type === 'zone' && selectedItem?.id === z.id ? 'selected' : '') + '" onclick="selectZone(\\'' + z.id + '\\')" style="border-left: 3px solid ' + color + ';"><div class="camera-name">' + z.name + '</div><div class="camera-info">' + z.type + ' | ' + z.polygon.length + ' points</div></div>';
|
|
@@ -43868,9 +43880,14 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
43868
43880
|
pendingZoneConfig = { name, type, description };
|
|
43869
43881
|
zoneDrawingMode = true;
|
|
43870
43882
|
currentZonePoints = [];
|
|
43883
|
+
lastClickTime = 0;
|
|
43871
43884
|
closeModal('add-zone-modal');
|
|
43872
|
-
setStatus('Zone drawing mode - click to add points,
|
|
43885
|
+
setStatus('Zone drawing mode - click to add points, click Finish Zone when done', 'warning');
|
|
43886
|
+
// Show zone drawing buttons
|
|
43887
|
+
document.getElementById('finish-zone-btn').style.display = 'inline-block';
|
|
43888
|
+
document.getElementById('cancel-zone-btn').style.display = 'inline-block';
|
|
43873
43889
|
render();
|
|
43890
|
+
console.log('[Zone] Drawing mode started for:', name);
|
|
43874
43891
|
}
|
|
43875
43892
|
|
|
43876
43893
|
function cancelZoneDrawing() {
|
|
@@ -43878,9 +43895,13 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
43878
43895
|
currentZonePoints = [];
|
|
43879
43896
|
pendingZoneConfig = null;
|
|
43880
43897
|
closeModal('add-zone-modal');
|
|
43898
|
+
// Hide zone drawing buttons
|
|
43899
|
+
document.getElementById('finish-zone-btn').style.display = 'none';
|
|
43900
|
+
document.getElementById('cancel-zone-btn').style.display = 'none';
|
|
43881
43901
|
setTool('select');
|
|
43882
43902
|
setStatus('Zone drawing cancelled', 'success');
|
|
43883
43903
|
render();
|
|
43904
|
+
console.log('[Zone] Drawing mode cancelled');
|
|
43884
43905
|
}
|
|
43885
43906
|
|
|
43886
43907
|
function finishZoneDrawing() {
|
|
@@ -43915,6 +43936,10 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
43915
43936
|
currentZonePoints = [];
|
|
43916
43937
|
pendingZoneConfig = null;
|
|
43917
43938
|
|
|
43939
|
+
// Hide zone drawing buttons
|
|
43940
|
+
document.getElementById('finish-zone-btn').style.display = 'none';
|
|
43941
|
+
document.getElementById('cancel-zone-btn').style.display = 'none';
|
|
43942
|
+
|
|
43918
43943
|
setTool('select');
|
|
43919
43944
|
updateUI();
|
|
43920
43945
|
render();
|
|
@@ -44016,9 +44041,21 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
44016
44041
|
|
|
44017
44042
|
// Handle zone drawing mode separately
|
|
44018
44043
|
if (zoneDrawingMode) {
|
|
44044
|
+
const now = Date.now();
|
|
44045
|
+
const timeSinceLastClick = now - lastClickTime;
|
|
44046
|
+
lastClickTime = now;
|
|
44047
|
+
|
|
44048
|
+
// If this is the second click of a double-click, don't add a point
|
|
44049
|
+
// The dblclick event will handle finishing the zone
|
|
44050
|
+
if (timeSinceLastClick < DOUBLE_CLICK_THRESHOLD && currentZonePoints.length >= 3) {
|
|
44051
|
+
console.log('[Zone] Double-click detected, skipping point addition');
|
|
44052
|
+
return;
|
|
44053
|
+
}
|
|
44054
|
+
|
|
44019
44055
|
currentZonePoints.push({ x, y });
|
|
44056
|
+
console.log('[Zone] Added point', currentZonePoints.length, 'at', x, y);
|
|
44020
44057
|
render();
|
|
44021
|
-
setStatus('Point ' + currentZonePoints.length + ' added. ' + (currentZonePoints.length < 3 ? 'Need at least 3 points.' : '
|
|
44058
|
+
setStatus('Point ' + currentZonePoints.length + ' added. ' + (currentZonePoints.length < 3 ? 'Need at least 3 points.' : 'Click Finish Zone to complete.'), 'warning');
|
|
44022
44059
|
return;
|
|
44023
44060
|
}
|
|
44024
44061
|
|
|
@@ -44076,7 +44113,9 @@ exports.EDITOR_HTML = `<!DOCTYPE html>
|
|
|
44076
44113
|
|
|
44077
44114
|
// Double-click to finish zone drawing
|
|
44078
44115
|
canvas.addEventListener('dblclick', (e) => {
|
|
44116
|
+
console.log('[Zone] dblclick event, zoneDrawingMode:', zoneDrawingMode, 'points:', currentZonePoints.length);
|
|
44079
44117
|
if (zoneDrawingMode && currentZonePoints.length >= 3) {
|
|
44118
|
+
console.log('[Zone] Calling finishZoneDrawing from dblclick');
|
|
44080
44119
|
finishZoneDrawing();
|
|
44081
44120
|
}
|
|
44082
44121
|
});
|