@umituz/react-native-ai-pruna-provider 1.0.24 → 1.0.26
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-pruna-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -46,28 +46,58 @@ export async function uploadFileToStorage(
|
|
|
46
46
|
|
|
47
47
|
generationLogCollector.log(sessionId, TAG, 'Uploading file to Pruna storage...');
|
|
48
48
|
|
|
49
|
+
// __DEV__ log input data size
|
|
50
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
51
|
+
const dataSizeKB = Math.round(base64Data.length / 1024);
|
|
52
|
+
console.log(`[DEV] [${TAG}] File upload input:`, {
|
|
53
|
+
dataSizeKB,
|
|
54
|
+
startsWithDataUri: base64Data.startsWith('data:'),
|
|
55
|
+
startsWithHttp: base64Data.startsWith('http'),
|
|
56
|
+
preview: base64Data.substring(0, 50) + '...',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Detect MIME type BEFORE creating temp file (needed for FormData)
|
|
61
|
+
const mimeType = detectMimeType(base64Data);
|
|
62
|
+
const extension = getExtensionForMime(mimeType);
|
|
63
|
+
const filename = `upload.${extension}`;
|
|
64
|
+
|
|
49
65
|
// Use design system filesystem to create temp file (React Native compatible)
|
|
50
|
-
const tempUri = await base64ToTempFile(base64Data);
|
|
66
|
+
const tempUri = await base64ToTempFile(base64Data, filename);
|
|
51
67
|
|
|
52
68
|
if (!tempUri) {
|
|
53
69
|
throw new Error("Failed to create temporary file from base64 data");
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
// Fetch the temp file to get a Blob
|
|
58
|
-
const response = await fetch(tempUri);
|
|
59
|
-
const blob = await response.blob();
|
|
60
|
-
|
|
61
|
-
// Use blob's MIME type (more accurate than base64 detection)
|
|
62
|
-
const actualMimeType = blob.type || 'image/jpeg';
|
|
63
|
-
const extension = getExtensionForMime(actualMimeType);
|
|
64
|
-
const filename = `upload.${extension}`;
|
|
72
|
+
generationLogCollector.log(sessionId, TAG, `Temp file created, uploading to Pruna as ${filename}...`);
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
// __DEV__ detailed file info
|
|
75
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
76
|
+
console.log(`[DEV] [${TAG}] File details:`, {
|
|
77
|
+
tempUri,
|
|
78
|
+
filename,
|
|
79
|
+
mimeType,
|
|
80
|
+
extension,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
67
83
|
|
|
68
|
-
|
|
84
|
+
try {
|
|
85
|
+
// React Native FormData file upload format (uri + type + name)
|
|
69
86
|
const formData = new FormData();
|
|
70
|
-
formData.append('content',
|
|
87
|
+
formData.append('content', {
|
|
88
|
+
uri: tempUri,
|
|
89
|
+
type: mimeType,
|
|
90
|
+
name: filename,
|
|
91
|
+
} as any);
|
|
92
|
+
|
|
93
|
+
// __DEV__ log FormData
|
|
94
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
95
|
+
console.log(`[DEV] [${TAG}] FormData created (RN file format):`, {
|
|
96
|
+
filename,
|
|
97
|
+
mimeType,
|
|
98
|
+
hasContent: formData.has('content'),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
71
101
|
|
|
72
102
|
const startTime = Date.now();
|
|
73
103
|
|
|
@@ -96,12 +96,41 @@ async function buildImageEditInput(
|
|
|
96
96
|
for (let i = 0; i < rawImages.length; i++) {
|
|
97
97
|
const rawImage = rawImages[i];
|
|
98
98
|
generationLogCollector.log(sessionId, TAG, `p-image-edit: uploading image ${i + 1}/${rawImages.length}...`);
|
|
99
|
+
|
|
100
|
+
// __DEV__ log image details before upload
|
|
101
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
102
|
+
console.log(`[DEV] [${TAG}] Image ${i + 1}/${rawImages.length}:`, {
|
|
103
|
+
sizeKB: Math.round(rawImage.length / 1024),
|
|
104
|
+
isUrl: rawImage.startsWith('http'),
|
|
105
|
+
hasDataUri: rawImage.startsWith('data:'),
|
|
106
|
+
preview: rawImage.substring(0, 50) + '...',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
99
110
|
const url = await uploadFileToStorage(rawImage, apiKey, sessionId);
|
|
100
111
|
imageUrls.push(url);
|
|
112
|
+
|
|
113
|
+
// __DEV__ log successful upload
|
|
114
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
115
|
+
console.log(`[DEV] [${TAG}] Image ${i + 1}/${rawImages.length} uploaded successfully:`, {
|
|
116
|
+
url,
|
|
117
|
+
urlPrefix: url.substring(0, 50) + '...',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
101
120
|
}
|
|
102
121
|
|
|
103
122
|
generationLogCollector.log(sessionId, TAG, `p-image-edit: all ${imageUrls.length} image(s) uploaded successfully`);
|
|
104
123
|
|
|
124
|
+
// __DEV__ log final payload
|
|
125
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
126
|
+
console.log(`[DEV] [${TAG}] Final p-image-edit payload:`, {
|
|
127
|
+
imageCount: imageUrls.length,
|
|
128
|
+
promptLength: prompt.length,
|
|
129
|
+
aspectRatio,
|
|
130
|
+
imageUrls: imageUrls.map(u => u.substring(0, 60) + '...'),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
105
134
|
const payload: Record<string, unknown> = {
|
|
106
135
|
images: imageUrls,
|
|
107
136
|
prompt,
|