@umituz/react-native-ai-fal-provider 3.2.27 → 3.2.29
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-fal-provider",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.29",
|
|
4
4
|
"description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -84,75 +84,73 @@ export async function preprocessInput(
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
// Handle
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
// Handle image URL arrays (image_urls, input_image_urls, reference_image_urls)
|
|
88
|
+
for (const arrayField of ["image_urls", "input_image_urls", "reference_image_urls"] as const) {
|
|
89
|
+
if (Array.isArray(result[arrayField]) && (result[arrayField] as unknown[]).length > 0) {
|
|
90
|
+
const imageUrls = result[arrayField] as unknown[];
|
|
91
|
+
const uploadTasks: Array<{ index: number; url: string | Promise<string> }> = [];
|
|
92
|
+
const errors: string[] = [];
|
|
93
|
+
|
|
94
|
+
for (let i = 0; i < imageUrls.length; i++) {
|
|
95
|
+
const imageUrl = imageUrls[i];
|
|
96
|
+
|
|
97
|
+
if (!imageUrl) {
|
|
98
|
+
errors.push(`${arrayField}[${i}] is null or undefined`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (isBase64DataUri(imageUrl)) {
|
|
103
|
+
const uploadPromise = uploadToFalStorage(imageUrl)
|
|
104
|
+
.then((url) => url)
|
|
105
|
+
.catch((error) => {
|
|
106
|
+
const errorMessage = `Failed to upload ${arrayField}[${i}]: ${getErrorMessage(error)}`;
|
|
107
|
+
console.error(`[preprocessInput] ${errorMessage}`);
|
|
108
|
+
errors.push(errorMessage);
|
|
109
|
+
throw new Error(errorMessage);
|
|
110
|
+
});
|
|
111
|
+
uploadTasks.push({ index: i, url: uploadPromise });
|
|
112
|
+
} else if (typeof imageUrl === "string") {
|
|
113
|
+
uploadTasks.push({ index: i, url: imageUrl });
|
|
114
|
+
} else {
|
|
115
|
+
errors.push(`${arrayField}[${i}] has invalid type: ${typeof imageUrl}`);
|
|
116
|
+
}
|
|
99
117
|
}
|
|
100
118
|
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
.then((url) => url)
|
|
104
|
-
.catch((error) => {
|
|
105
|
-
const errorMessage = `Failed to upload image_urls[${i}]: ${getErrorMessage(error)}`;
|
|
106
|
-
console.error(`[preprocessInput] ${errorMessage}`);
|
|
107
|
-
errors.push(errorMessage);
|
|
108
|
-
throw new Error(errorMessage);
|
|
109
|
-
});
|
|
110
|
-
uploadTasks.push({ index: i, url: uploadPromise });
|
|
111
|
-
} else if (typeof imageUrl === "string") {
|
|
112
|
-
uploadTasks.push({ index: i, url: imageUrl });
|
|
113
|
-
} else {
|
|
114
|
-
errors.push(`image_urls[${i}] has invalid type: ${typeof imageUrl}`);
|
|
119
|
+
if (errors.length > 0) {
|
|
120
|
+
throw new Error(`Image URL validation failed:\n${errors.join('\n')}`);
|
|
115
121
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (errors.length > 0) {
|
|
119
|
-
throw new Error(`Image URL validation failed:\n${errors.join('\n')}`);
|
|
120
|
-
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Wait for all uploads using Promise.allSettled to handle failures gracefully
|
|
128
|
-
// This ensures all uploads complete before reporting errors
|
|
129
|
-
const uploadResults = await Promise.allSettled(
|
|
130
|
-
uploadTasks.map((task) => Promise.resolve(task.url))
|
|
131
|
-
);
|
|
123
|
+
if (uploadTasks.length === 0) {
|
|
124
|
+
throw new Error(`${arrayField} array must contain at least one valid image URL`);
|
|
125
|
+
}
|
|
132
126
|
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
const uploadResults = await Promise.allSettled(
|
|
128
|
+
uploadTasks.map((task) => Promise.resolve(task.url))
|
|
129
|
+
);
|
|
135
130
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
const processedUrls: string[] = [];
|
|
132
|
+
const uploadErrors: string[] = [];
|
|
133
|
+
|
|
134
|
+
uploadResults.forEach((uploadResult, index) => {
|
|
135
|
+
if (uploadResult.status === 'fulfilled') {
|
|
136
|
+
processedUrls.push(uploadResult.value);
|
|
137
|
+
} else {
|
|
138
|
+
uploadErrors.push(
|
|
139
|
+
`Upload ${index} failed: ${getErrorMessage(uploadResult.reason)}`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (uploadErrors.length > 0) {
|
|
145
|
+
console.warn(
|
|
146
|
+
`[input-preprocessor] ${processedUrls.length} of ${uploadTasks.length} uploads succeeded. ` +
|
|
147
|
+
'Successful uploads remain in FAL storage.'
|
|
142
148
|
);
|
|
149
|
+
throw new Error(`Image upload failures:\n${uploadErrors.join('\n')}`);
|
|
143
150
|
}
|
|
144
|
-
});
|
|
145
151
|
|
|
146
|
-
|
|
147
|
-
if (uploadErrors.length > 0) {
|
|
148
|
-
console.warn(
|
|
149
|
-
`[input-preprocessor] ${processedUrls.length} of ${uploadTasks.length} uploads succeeded. ` +
|
|
150
|
-
'Successful uploads remain in FAL storage.'
|
|
151
|
-
);
|
|
152
|
-
throw new Error(`Image upload failures:\n${uploadErrors.join('\n')}`);
|
|
152
|
+
result[arrayField] = processedUrls;
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
result.image_urls = processedUrls;
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
// Wait for ALL uploads to complete (both individual keys and array)
|