@umituz/react-native-ai-generation-content 1.17.106 → 1.17.108
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
package/src/index.ts
CHANGED
|
@@ -45,6 +45,27 @@ export function interpolateProgress(
|
|
|
45
45
|
return Math.round(progress);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Calculate progress for polling-based operations
|
|
50
|
+
* Returns a rounded integer between minProgress and maxProgress
|
|
51
|
+
*
|
|
52
|
+
* @param currentAttempt - Current polling attempt (1-based)
|
|
53
|
+
* @param maxAttempts - Maximum number of polling attempts
|
|
54
|
+
* @param minProgress - Starting progress percentage (default: 10)
|
|
55
|
+
* @param maxProgress - Maximum progress percentage before completion (default: 95)
|
|
56
|
+
* @returns Rounded progress percentage
|
|
57
|
+
*/
|
|
58
|
+
export function calculatePollingProgress(
|
|
59
|
+
currentAttempt: number,
|
|
60
|
+
maxAttempts: number,
|
|
61
|
+
minProgress: number = 10,
|
|
62
|
+
maxProgress: number = 95,
|
|
63
|
+
): number {
|
|
64
|
+
const ratio = currentAttempt / maxAttempts;
|
|
65
|
+
const progress = minProgress + ratio * (maxProgress - minProgress);
|
|
66
|
+
return Math.round(Math.min(maxProgress, progress));
|
|
67
|
+
}
|
|
68
|
+
|
|
48
69
|
export function createProgressTracker(stages?: ProgressStageConfig[]) {
|
|
49
70
|
const effectiveStages = stages ?? DEFAULT_PROGRESS_STAGES;
|
|
50
71
|
let currentStatus: GenerationStatus = "idle";
|