@umituz/react-native-ai-pruna-provider 1.0.12 → 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.12",
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",
@@ -68,21 +68,29 @@ function buildImageEditInput(
68
68
  input: Record<string, unknown>,
69
69
  sessionId: string,
70
70
  ): Record<string, unknown> {
71
- // p-image-edit expects images array (base64 or HTTPS URLs file URIs resolved by ai-generation-content)
71
+ // p-image-edit expects images array (base64 with data URI prefix or HTTPS URLs)
72
+ // Base64 format: data:image/jpeg;base64,{base64_string}
72
73
  let images: string[];
73
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
+
74
82
  if (Array.isArray(input.images)) {
75
83
  const validImages = (input.images as unknown[]).filter((img): img is string => typeof img === 'string');
76
84
  if (validImages.length === 0) {
77
85
  throw new Error("Image array is empty or contains no valid strings for p-image-edit.");
78
86
  }
79
- images = validImages.map(stripBase64Prefix);
87
+ images = validImages.map(ensureDataUriPrefix);
80
88
  } else if (typeof input.image === 'string') {
81
- images = [stripBase64Prefix(input.image as string)];
89
+ images = [ensureDataUriPrefix(input.image as string)];
82
90
  } else if (typeof input.image_url === 'string') {
83
- images = [stripBase64Prefix(input.image_url as string)];
91
+ images = [ensureDataUriPrefix(input.image_url as string)];
84
92
  } else if (Array.isArray(input.image_urls)) {
85
- images = (input.image_urls as string[]).map(stripBase64Prefix);
93
+ images = (input.image_urls as string[]).map(ensureDataUriPrefix);
86
94
  } else {
87
95
  throw new Error("Image is required for p-image-edit. Provide 'image', 'images', 'image_url', or 'image_urls'.");
88
96
  }