@umituz/react-native-ai-pruna-provider 1.0.23 → 1.0.25

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.23",
3
+ "version": "1.0.25",
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,12 +46,16 @@ export async function uploadFileToStorage(
46
46
 
47
47
  generationLogCollector.log(sessionId, TAG, 'Uploading file to Pruna storage...');
48
48
 
49
- // Detect MIME type BEFORE creating temp file (needed for filename)
50
- const mimeType = detectMimeType(base64Data);
51
- const extension = getExtensionForMime(mimeType);
52
- const filename = `upload.${extension}`;
53
-
54
- generationLogCollector.log(sessionId, TAG, `Detected MIME type: ${mimeType}, extension: ${extension}`);
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
+ }
55
59
 
56
60
  // Use design system filesystem to create temp file (React Native compatible)
57
61
  const tempUri = await base64ToTempFile(base64Data);
@@ -64,12 +68,38 @@ export async function uploadFileToStorage(
64
68
  // Fetch the temp file to get a Blob
65
69
  const response = await fetch(tempUri);
66
70
  const blob = await response.blob();
67
- generationLogCollector.log(sessionId, TAG, `Temp file created (${blob.size} bytes, type: ${blob.type || mimeType}), uploading to Pruna as ${filename}...`);
71
+
72
+ // Use blob's MIME type (more accurate than base64 detection)
73
+ const actualMimeType = blob.type || 'image/jpeg';
74
+ const extension = getExtensionForMime(actualMimeType);
75
+ const filename = `upload.${extension}`;
76
+
77
+ generationLogCollector.log(sessionId, TAG, `Temp file created (${blob.size} bytes, type: ${actualMimeType}), uploading to Pruna as ${filename}...`);
78
+
79
+ // __DEV__ detailed blob logging
80
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
81
+ console.log(`[DEV] [${TAG}] Blob details:`, {
82
+ tempUri,
83
+ blobSize: blob.size,
84
+ blobType: blob.type,
85
+ actualMimeType,
86
+ extension,
87
+ filename,
88
+ });
89
+ }
68
90
 
69
91
  // Create FormData with the blob AND proper filename with extension
70
92
  const formData = new FormData();
71
93
  formData.append('content', blob, filename);
72
94
 
95
+ // __DEV__ log FormData entries (if possible)
96
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
97
+ console.log(`[DEV] [${TAG}] FormData created:`, {
98
+ hasContent: formData.has('content'),
99
+ filename,
100
+ });
101
+ }
102
+
73
103
  const startTime = Date.now();
74
104
 
75
105
  // Apply timeout to prevent indefinite hangs
@@ -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,