@umituz/react-native-ai-generation-content 1.17.105 → 1.17.106

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.105",
3
+ "version": "1.17.106",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -50,6 +50,10 @@ export interface SubscribeOptions<T = unknown> {
50
50
  onResult?: (result: T) => void;
51
51
  }
52
52
 
53
+ export interface RunOptions {
54
+ onProgress?: (progress: number) => void;
55
+ }
56
+
53
57
  /**
54
58
  * Feature types for image processing (output: image)
55
59
  */
@@ -116,7 +120,11 @@ export interface IAIProvider {
116
120
  options?: SubscribeOptions<T>,
117
121
  ): Promise<T>;
118
122
 
119
- run<T = unknown>(model: string, input: Record<string, unknown>): Promise<T>;
123
+ run<T = unknown>(
124
+ model: string,
125
+ input: Record<string, unknown>,
126
+ options?: RunOptions,
127
+ ): Promise<T>;
120
128
 
121
129
  reset(): void;
122
130
 
@@ -119,7 +119,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
119
119
  const logResult = {
120
120
  success: result.success,
121
121
  imageCount: result.success ? result.imageUrls?.length : 0,
122
- error: !result.success ? result.error : undefined,
122
+ error: result.success === false ? result.error : undefined,
123
123
  };
124
124
  // eslint-disable-next-line no-console
125
125
  console.log("[TextToImage] Result:", JSON.stringify(logResult));
@@ -19,11 +19,20 @@ export interface ProjectData {
19
19
  style: string;
20
20
  }
21
21
 
22
+ export interface CreationData {
23
+ type: "text-to-video";
24
+ videoUrl: string;
25
+ thumbnailUrl?: string;
26
+ prompt: string;
27
+ metadata?: Record<string, unknown>;
28
+ }
29
+
22
30
  export interface TextToVideoCallbacks {
23
31
  onCreditCheck?: (cost: number) => Promise<boolean>;
32
+ onCreditDeduct?: (cost: number) => Promise<void>;
24
33
  onAuthCheck?: () => boolean;
25
34
  onModeration?: (prompt: string) => Promise<VideoModerationResult>;
26
- onProjectCreate?: (data: ProjectData) => Promise<void>;
35
+ onCreationSave?: (data: CreationData) => Promise<void>;
27
36
  onGenerate?: (result: TextToVideoResult) => void;
28
37
  onError?: (error: string) => void;
29
38
  onProgress?: (progress: number) => void;
@@ -34,6 +34,7 @@ export type {
34
34
  export type {
35
35
  VideoModerationResult,
36
36
  ProjectData,
37
+ CreationData,
37
38
  TextToVideoCallbacks,
38
39
  TextToVideoTranslations,
39
40
  } from "./callback.types";
@@ -71,13 +71,15 @@ export async function executeTextToVideo(
71
71
  }
72
72
 
73
73
  try {
74
- onProgress?.(10);
74
+ onProgress?.(5);
75
75
 
76
76
  const input = buildInput(request.prompt, request.options);
77
- onProgress?.(20);
78
77
 
79
- const result = await provider.run(model, input);
80
- onProgress?.(90);
78
+ const result = await provider.run(model, input, {
79
+ onProgress: (progress) => {
80
+ onProgress?.(progress);
81
+ },
82
+ });
81
83
 
82
84
  const extractor = extractResult || defaultExtractResult;
83
85
  const extracted = extractor(result);
@@ -157,6 +157,23 @@ export function useTextToVideoFeature(
157
157
  isProcessing: false,
158
158
  progress: 100,
159
159
  }));
160
+
161
+ // Deduct credits after successful generation
162
+ if (callbacks.onCreditDeduct) {
163
+ await callbacks.onCreditDeduct(config.creditCost);
164
+ }
165
+
166
+ // Save creation after successful generation
167
+ if (callbacks.onCreationSave) {
168
+ await callbacks.onCreationSave({
169
+ type: "text-to-video",
170
+ videoUrl: result.videoUrl,
171
+ thumbnailUrl: result.thumbnailUrl,
172
+ prompt,
173
+ metadata: options as Record<string, unknown> | undefined,
174
+ });
175
+ }
176
+
160
177
  callbacks.onGenerate?.(result);
161
178
  } else {
162
179
  const error = result.error || "Generation failed";
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export type {
25
25
  AIJobStatusType,
26
26
  AILogEntry,
27
27
  SubscribeOptions,
28
+ RunOptions,
28
29
  ImageFeatureType,
29
30
  VideoFeatureType,
30
31
  ImageFeatureInputData,