@blueharford/scrypted-spatial-awareness 0.5.7 → 0.5.8
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 +34 -21
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/core/spatial-reasoning.ts +33 -24
package/out/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -84,41 +84,50 @@ export interface ImageData {
|
|
|
84
84
|
*/
|
|
85
85
|
export async function mediaObjectToBase64(mediaObject: MediaObject): Promise<ImageData | null> {
|
|
86
86
|
try {
|
|
87
|
-
|
|
87
|
+
const mimeType = mediaObject?.mimeType || 'image/jpeg';
|
|
88
|
+
console.log(`[Image] Converting MediaObject, mimeType=${mimeType}`);
|
|
88
89
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// Use createMediaObject to ensure we have a proper MediaObject with mimeType
|
|
91
|
+
// Then convert to buffer - this should handle the conversion internally
|
|
92
|
+
let buffer: Buffer;
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
99
|
-
|
|
100
|
-
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
101
|
-
|
|
102
|
-
if (!isRealBuffer || bufferLength === 0) {
|
|
103
|
-
console.warn('[Image] Did not receive a valid Buffer');
|
|
94
|
+
try {
|
|
95
|
+
// Try direct conversion with the source mime type
|
|
96
|
+
buffer = await mediaManager.convertMediaObjectToBuffer(mediaObject, mimeType);
|
|
97
|
+
} catch (convErr) {
|
|
98
|
+
console.warn(`[Image] Direct conversion failed, trying with explicit JPEG:`, convErr);
|
|
104
99
|
|
|
105
|
-
// Try
|
|
100
|
+
// Try creating a new MediaObject with explicit mimeType
|
|
106
101
|
try {
|
|
102
|
+
// Get raw data if available
|
|
107
103
|
const anyMedia = mediaObject as any;
|
|
108
104
|
if (typeof anyMedia.getData === 'function') {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
console.log(`[Image] Got data
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
const rawData = await anyMedia.getData();
|
|
106
|
+
if (rawData && Buffer.isBuffer(rawData) && rawData.length > 1000) {
|
|
107
|
+
console.log(`[Image] Got raw data: ${rawData.length} bytes`);
|
|
108
|
+
buffer = rawData;
|
|
109
|
+
} else {
|
|
110
|
+
console.warn(`[Image] getData returned invalid data`);
|
|
111
|
+
return null;
|
|
116
112
|
}
|
|
113
|
+
} else {
|
|
114
|
+
console.warn('[Image] No getData method available');
|
|
115
|
+
return null;
|
|
117
116
|
}
|
|
118
117
|
} catch (dataErr) {
|
|
119
|
-
console.warn('[Image]
|
|
118
|
+
console.warn('[Image] Alternate data fetch failed:', dataErr);
|
|
119
|
+
return null;
|
|
120
120
|
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check if we got an actual Buffer (not a proxy)
|
|
124
|
+
const isRealBuffer = Buffer.isBuffer(buffer);
|
|
125
|
+
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
126
|
+
|
|
127
|
+
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
121
128
|
|
|
129
|
+
if (!isRealBuffer || bufferLength === 0) {
|
|
130
|
+
console.warn('[Image] Did not receive a valid Buffer');
|
|
122
131
|
return null;
|
|
123
132
|
}
|
|
124
133
|
|