@blueharford/scrypted-spatial-awareness 0.4.3 → 0.4.4
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/package.json +1 -1
- package/src/main.ts +13 -11
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -37,7 +37,7 @@ import { EDITOR_HTML } from './ui/editor-html';
|
|
|
37
37
|
import { TRAINING_HTML } from './ui/training-html';
|
|
38
38
|
import { TrainingConfig, TrainingLandmark } from './models/training';
|
|
39
39
|
|
|
40
|
-
const { deviceManager, systemManager } = sdk;
|
|
40
|
+
const { deviceManager, systemManager, mediaManager } = sdk;
|
|
41
41
|
|
|
42
42
|
const TRACKING_ZONE_PREFIX = 'tracking-zone:';
|
|
43
43
|
const GLOBAL_TRACKER_ID = 'global-tracker';
|
|
@@ -1046,24 +1046,26 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
|
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
-
private getFloorPlanPath(): string {
|
|
1050
|
-
// Use
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1049
|
+
private async getFloorPlanPath(): Promise<string> {
|
|
1050
|
+
// Use mediaManager.getFilesPath() for proper persistent storage
|
|
1051
|
+
const filesPath = await mediaManager.getFilesPath();
|
|
1052
|
+
this.console.log('Files path from mediaManager:', filesPath);
|
|
1053
1053
|
// Ensure directory exists
|
|
1054
|
-
if (!fs.existsSync(
|
|
1055
|
-
fs.mkdirSync(
|
|
1054
|
+
if (!fs.existsSync(filesPath)) {
|
|
1055
|
+
fs.mkdirSync(filesPath, { recursive: true });
|
|
1056
1056
|
}
|
|
1057
|
-
return path.join(
|
|
1057
|
+
return path.join(filesPath, 'floorplan.png');
|
|
1058
1058
|
}
|
|
1059
1059
|
|
|
1060
|
-
private handleFloorPlanRequest(request: HttpRequest, response: HttpResponse): void {
|
|
1060
|
+
private async handleFloorPlanRequest(request: HttpRequest, response: HttpResponse): Promise<void> {
|
|
1061
1061
|
if (request.method === 'GET') {
|
|
1062
1062
|
try {
|
|
1063
|
-
const floorPlanPath = this.getFloorPlanPath();
|
|
1063
|
+
const floorPlanPath = await this.getFloorPlanPath();
|
|
1064
|
+
this.console.log('Loading floor plan from:', floorPlanPath, 'exists:', fs.existsSync(floorPlanPath));
|
|
1064
1065
|
if (fs.existsSync(floorPlanPath)) {
|
|
1065
1066
|
const imageBuffer = fs.readFileSync(floorPlanPath);
|
|
1066
1067
|
const imageData = 'data:image/png;base64,' + imageBuffer.toString('base64');
|
|
1068
|
+
this.console.log('Floor plan loaded, size:', imageBuffer.length);
|
|
1067
1069
|
response.send(JSON.stringify({ imageData }), {
|
|
1068
1070
|
headers: { 'Content-Type': 'application/json' },
|
|
1069
1071
|
});
|
|
@@ -1087,7 +1089,7 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
|
|
|
1087
1089
|
const base64Data = imageData.replace(/^data:image\/\w+;base64,/, '');
|
|
1088
1090
|
const imageBuffer = Buffer.from(base64Data, 'base64');
|
|
1089
1091
|
|
|
1090
|
-
const floorPlanPath = this.getFloorPlanPath();
|
|
1092
|
+
const floorPlanPath = await this.getFloorPlanPath();
|
|
1091
1093
|
fs.writeFileSync(floorPlanPath, imageBuffer);
|
|
1092
1094
|
|
|
1093
1095
|
this.console.log('Floor plan saved to:', floorPlanPath, 'size:', imageBuffer.length);
|