@umituz/react-native-ai-generation-content 1.17.180 → 1.17.181
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
|
@@ -96,6 +96,7 @@ function defaultExtractVideoResult(result: unknown): string | undefined {
|
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Execute any video feature using the active provider
|
|
99
|
+
* Uses subscribe for video features to handle long-running generation with progress updates
|
|
99
100
|
*/
|
|
100
101
|
export async function executeVideoFeature(
|
|
101
102
|
featureType: VideoFeatureType,
|
|
@@ -117,12 +118,11 @@ export async function executeVideoFeature(
|
|
|
117
118
|
const model = provider.getVideoFeatureModel(featureType);
|
|
118
119
|
|
|
119
120
|
if (__DEV__) {
|
|
120
|
-
|
|
121
121
|
console.log(`[Video:${featureType}] Provider: ${provider.providerId}, Model: ${model}`);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
try {
|
|
125
|
-
onProgress?.(
|
|
125
|
+
onProgress?.(5);
|
|
126
126
|
|
|
127
127
|
const inputData: VideoFeatureInputData = {
|
|
128
128
|
sourceImageBase64: cleanBase64(request.sourceImageBase64),
|
|
@@ -131,13 +131,27 @@ export async function executeVideoFeature(
|
|
|
131
131
|
options: request.options,
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
onProgress?.(
|
|
134
|
+
onProgress?.(10);
|
|
135
135
|
|
|
136
136
|
const input = provider.buildVideoFeatureInput(featureType, inputData);
|
|
137
137
|
|
|
138
|
-
onProgress?.(
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
onProgress?.(15);
|
|
139
|
+
|
|
140
|
+
// Use subscribe for video features - provides queue updates and handles long-running tasks
|
|
141
|
+
const result = await provider.subscribe(model, input, {
|
|
142
|
+
timeoutMs: 300000, // 5 minutes timeout for video generation
|
|
143
|
+
onQueueUpdate: (status) => {
|
|
144
|
+
if (__DEV__) {
|
|
145
|
+
console.log(`[Video:${featureType}] Queue update:`, status.status);
|
|
146
|
+
}
|
|
147
|
+
// Map queue status to progress percentage
|
|
148
|
+
if (status.status === "IN_QUEUE") {
|
|
149
|
+
onProgress?.(20);
|
|
150
|
+
} else if (status.status === "IN_PROGRESS") {
|
|
151
|
+
onProgress?.(50);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
});
|
|
141
155
|
|
|
142
156
|
onProgress?.(90);
|
|
143
157
|
|
|
@@ -147,6 +161,9 @@ export async function executeVideoFeature(
|
|
|
147
161
|
onProgress?.(100);
|
|
148
162
|
|
|
149
163
|
if (!videoUrl) {
|
|
164
|
+
if (__DEV__) {
|
|
165
|
+
console.log(`[Video:${featureType}] No video URL found in result:`, JSON.stringify(result, null, 2));
|
|
166
|
+
}
|
|
150
167
|
return { success: false, error: "No video in response" };
|
|
151
168
|
}
|
|
152
169
|
|
|
@@ -156,10 +173,21 @@ export async function executeVideoFeature(
|
|
|
156
173
|
requestId: (result as { requestId?: string })?.requestId,
|
|
157
174
|
};
|
|
158
175
|
} catch (error) {
|
|
159
|
-
|
|
176
|
+
// Extract detailed error message from FAL API errors
|
|
177
|
+
let message = "Processing failed";
|
|
178
|
+
if (error instanceof Error) {
|
|
179
|
+
message = error.message;
|
|
180
|
+
} else if (typeof error === "object" && error !== null) {
|
|
181
|
+
const errObj = error as Record<string, unknown>;
|
|
182
|
+
if (errObj.detail) {
|
|
183
|
+
message = JSON.stringify(errObj.detail);
|
|
184
|
+
} else if (errObj.message) {
|
|
185
|
+
message = String(errObj.message);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
160
189
|
if (__DEV__) {
|
|
161
|
-
|
|
162
|
-
console.error(`[Video:${featureType}] Error:`, message);
|
|
190
|
+
console.error(`[Video:${featureType}] Error:`, message, error);
|
|
163
191
|
}
|
|
164
192
|
return { success: false, error: message };
|
|
165
193
|
}
|