@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/dist/plugin.zip
CHANGED
|
Binary file
|
package/out/main.nodejs.js
CHANGED
|
@@ -35076,35 +35076,48 @@ const { systemManager, mediaManager } = sdk_1.default;
|
|
|
35076
35076
|
*/
|
|
35077
35077
|
async function mediaObjectToBase64(mediaObject) {
|
|
35078
35078
|
try {
|
|
35079
|
-
|
|
35080
|
-
|
|
35081
|
-
|
|
35082
|
-
|
|
35083
|
-
|
|
35084
|
-
|
|
35085
|
-
|
|
35086
|
-
|
|
35087
|
-
|
|
35088
|
-
|
|
35089
|
-
|
|
35090
|
-
|
|
35091
|
-
// Try alternate approach: get raw data using any type
|
|
35079
|
+
const mimeType = mediaObject?.mimeType || 'image/jpeg';
|
|
35080
|
+
console.log(`[Image] Converting MediaObject, mimeType=${mimeType}`);
|
|
35081
|
+
// Use createMediaObject to ensure we have a proper MediaObject with mimeType
|
|
35082
|
+
// Then convert to buffer - this should handle the conversion internally
|
|
35083
|
+
let buffer;
|
|
35084
|
+
try {
|
|
35085
|
+
// Try direct conversion with the source mime type
|
|
35086
|
+
buffer = await mediaManager.convertMediaObjectToBuffer(mediaObject, mimeType);
|
|
35087
|
+
}
|
|
35088
|
+
catch (convErr) {
|
|
35089
|
+
console.warn(`[Image] Direct conversion failed, trying with explicit JPEG:`, convErr);
|
|
35090
|
+
// Try creating a new MediaObject with explicit mimeType
|
|
35092
35091
|
try {
|
|
35092
|
+
// Get raw data if available
|
|
35093
35093
|
const anyMedia = mediaObject;
|
|
35094
35094
|
if (typeof anyMedia.getData === 'function') {
|
|
35095
|
-
const
|
|
35096
|
-
if (
|
|
35097
|
-
console.log(`[Image] Got data
|
|
35098
|
-
|
|
35099
|
-
|
|
35100
|
-
|
|
35101
|
-
|
|
35095
|
+
const rawData = await anyMedia.getData();
|
|
35096
|
+
if (rawData && Buffer.isBuffer(rawData) && rawData.length > 1000) {
|
|
35097
|
+
console.log(`[Image] Got raw data: ${rawData.length} bytes`);
|
|
35098
|
+
buffer = rawData;
|
|
35099
|
+
}
|
|
35100
|
+
else {
|
|
35101
|
+
console.warn(`[Image] getData returned invalid data`);
|
|
35102
|
+
return null;
|
|
35102
35103
|
}
|
|
35103
35104
|
}
|
|
35105
|
+
else {
|
|
35106
|
+
console.warn('[Image] No getData method available');
|
|
35107
|
+
return null;
|
|
35108
|
+
}
|
|
35104
35109
|
}
|
|
35105
35110
|
catch (dataErr) {
|
|
35106
|
-
console.warn('[Image]
|
|
35111
|
+
console.warn('[Image] Alternate data fetch failed:', dataErr);
|
|
35112
|
+
return null;
|
|
35107
35113
|
}
|
|
35114
|
+
}
|
|
35115
|
+
// Check if we got an actual Buffer (not a proxy)
|
|
35116
|
+
const isRealBuffer = Buffer.isBuffer(buffer);
|
|
35117
|
+
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
35118
|
+
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
35119
|
+
if (!isRealBuffer || bufferLength === 0) {
|
|
35120
|
+
console.warn('[Image] Did not receive a valid Buffer');
|
|
35108
35121
|
return null;
|
|
35109
35122
|
}
|
|
35110
35123
|
// Check if buffer is too small to be a valid image (< 1KB is suspicious)
|