@umituz/react-native-ai-generation-content 1.17.107 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.17.107",
3
+ "version": "1.17.108",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -175,6 +175,7 @@ export {
175
175
  getProgressForStatus,
176
176
  interpolateProgress,
177
177
  createProgressTracker,
178
+ calculatePollingProgress,
178
179
  // Status checking
179
180
  checkStatusForErrors,
180
181
  isJobComplete,
@@ -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";