@umituz/react-native-ai-generation-content 1.28.7 → 1.28.8
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-generation-content",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.8",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -17,6 +17,21 @@ import type {
|
|
|
17
17
|
|
|
18
18
|
declare const __DEV__: boolean;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Calculate progress based on elapsed time
|
|
22
|
+
* Video generation typically takes 2-5 minutes
|
|
23
|
+
* Progress goes from 10% to 90% over the expected duration
|
|
24
|
+
*/
|
|
25
|
+
function calculateTimeBasedProgress(startTime: number, expectedDurationMs: number = 180000): number {
|
|
26
|
+
const elapsed = Date.now() - startTime;
|
|
27
|
+
const progressRange = 80; // Progress from 10% to 90%
|
|
28
|
+
const baseProgress = 10;
|
|
29
|
+
|
|
30
|
+
// Calculate progress based on elapsed time (capped at 90%)
|
|
31
|
+
const timeProgress = Math.min((elapsed / expectedDurationMs) * progressRange, progressRange);
|
|
32
|
+
return Math.round(baseProgress + timeProgress);
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Execute any video feature using the active provider
|
|
22
37
|
* Uses subscribe for video features to handle long-running generation with progress updates
|
|
@@ -54,6 +69,9 @@ export async function executeVideoFeature(
|
|
|
54
69
|
|
|
55
70
|
const input = provider.buildVideoFeatureInput(featureType, inputData);
|
|
56
71
|
|
|
72
|
+
// Track start time for progress calculation
|
|
73
|
+
const startTime = Date.now();
|
|
74
|
+
|
|
57
75
|
const result = await provider.subscribe(model, input, {
|
|
58
76
|
timeoutMs: VIDEO_TIMEOUT_MS,
|
|
59
77
|
onQueueUpdate: (status) => {
|
|
@@ -61,6 +79,12 @@ export async function executeVideoFeature(
|
|
|
61
79
|
console.log(`[Video:${featureType}] Queue status:`, status.status);
|
|
62
80
|
}
|
|
63
81
|
onStatusChange?.(status.status);
|
|
82
|
+
|
|
83
|
+
// Calculate and report progress based on elapsed time
|
|
84
|
+
if (status.status === "IN_PROGRESS" && onProgress) {
|
|
85
|
+
const progress = calculateTimeBasedProgress(startTime);
|
|
86
|
+
onProgress(progress);
|
|
87
|
+
}
|
|
64
88
|
},
|
|
65
89
|
});
|
|
66
90
|
|