@umituz/react-native-ai-pruna-provider 1.0.13 → 1.0.14

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.13",
3
+ "version": "1.0.14",
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",
@@ -72,18 +72,25 @@ function buildImageEditInput(
72
72
  // Base64 format: data:image/jpeg;base64,{base64_string}
73
73
  let images: string[];
74
74
 
75
+ const ensureDataUriPrefix = (img: string): string => {
76
+ if (img.startsWith('http')) return img; // Already a URL
77
+ if (img.startsWith('data:')) return img; // Already has data URI prefix
78
+ // Add data URI prefix for raw base64
79
+ return `data:image/jpeg;base64,${img}`;
80
+ };
81
+
75
82
  if (Array.isArray(input.images)) {
76
83
  const validImages = (input.images as unknown[]).filter((img): img is string => typeof img === 'string');
77
84
  if (validImages.length === 0) {
78
85
  throw new Error("Image array is empty or contains no valid strings for p-image-edit.");
79
86
  }
80
- images = validImages; // Keep data URI prefix for base64 images
87
+ images = validImages.map(ensureDataUriPrefix);
81
88
  } else if (typeof input.image === 'string') {
82
- images = [input.image as string]; // Keep data URI prefix for base64 images
89
+ images = [ensureDataUriPrefix(input.image as string)];
83
90
  } else if (typeof input.image_url === 'string') {
84
- images = [input.image_url as string]; // Keep data URI prefix for base64 images
91
+ images = [ensureDataUriPrefix(input.image_url as string)];
85
92
  } else if (Array.isArray(input.image_urls)) {
86
- images = input.image_urls as string[]; // Keep data URI prefix for base64 images
93
+ images = (input.image_urls as string[]).map(ensureDataUriPrefix);
87
94
  } else {
88
95
  throw new Error("Image is required for p-image-edit. Provide 'image', 'images', 'image_url', or 'image_urls'.");
89
96
  }