@umituz/react-native-ai-generation-content 1.83.45 → 1.83.47

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.83.45",
3
+ "version": "1.83.47",
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",
@@ -75,11 +75,8 @@ export async function executeImageGeneration(
75
75
  enable_safety_checker: MODEL_INPUT_DEFAULTS.enableSafetyChecker,
76
76
  };
77
77
 
78
- // Single image: use image_url (singular) for edit-style models (e.g. xai/grok-imagine-image/edit)
79
- // Multiple images: use image_urls (array) for multi-reference models
80
- if (imageUrls.length === 1) {
81
- modelInput.image_url = imageUrls[0];
82
- } else if (imageUrls.length > 1) {
78
+ // nano-banana/edit uses image_urls (array) for both single and multi-image
79
+ if (imageUrls.length > 0) {
83
80
  modelInput.image_urls = imageUrls;
84
81
  }
85
82
 
@@ -32,6 +32,8 @@ export interface GenericWizardFlowProps {
32
32
  readonly creditCost: number;
33
33
  /** Calculator function provided by APP - package calls this to get dynamic cost */
34
34
  readonly calculateCredits?: CreditCalculatorFn;
35
+ /** Called after successful generation to deduct credits — provided by the app */
36
+ readonly deductCredits?: (cost: number) => Promise<boolean>;
35
37
  readonly skipResultStep?: boolean;
36
38
  readonly onStepChange?: (stepId: string, stepType: StepType | string) => void;
37
39
  readonly onGenerationStart?: (
@@ -61,6 +63,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = (props) => {
61
63
  alertMessages,
62
64
  creditCost,
63
65
  calculateCredits,
66
+ deductCredits,
64
67
  skipResultStep = false,
65
68
  onStepChange,
66
69
  onGenerationStart,
@@ -119,6 +122,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = (props) => {
119
122
  alertMessages={alertMessages}
120
123
  creditCost={creditCost}
121
124
  calculateCredits={calculateCredits}
125
+ deductCredits={deductCredits}
122
126
  skipResultStep={skipResultStep}
123
127
  onStepChange={onStepChange}
124
128
  onGenerationStart={onGenerationStart}
@@ -34,6 +34,8 @@ interface WizardFlowContentProps {
34
34
  readonly creditCost: number;
35
35
  /** Calculator function provided by APP - package calls this to get dynamic cost */
36
36
  readonly calculateCredits?: CreditCalculatorFn;
37
+ /** Called after successful generation to deduct credits — provided by the app */
38
+ readonly deductCredits?: (cost: number) => Promise<boolean>;
37
39
  readonly skipResultStep?: boolean;
38
40
  readonly onStepChange?: (stepId: string, stepType: StepType | string) => void;
39
41
  readonly onGenerationStart?: (
@@ -60,8 +62,9 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
60
62
  modelConfig,
61
63
  userId,
62
64
  alertMessages,
63
- creditCost, // Still needed for initial feature gate in parent
64
- calculateCredits, // Calculator function from APP
65
+ creditCost,
66
+ calculateCredits,
67
+ deductCredits,
65
68
  skipResultStep = false,
66
69
  onStepChange,
67
70
  onGenerationStart,
@@ -188,6 +191,7 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
188
191
  isGeneratingStep: currentStep?.type === StepType.GENERATING,
189
192
  alertMessages,
190
193
  creditCost: calculatedCreditCost,
194
+ deductCredits,
191
195
  onSuccess: handlers.handleGenerationComplete,
192
196
  onError: handlers.handleGenerationError,
193
197
  onCreditsExhausted,
@@ -12,6 +12,7 @@ export interface UseVideoQueueGenerationProps {
12
12
  readonly persistence: CreationPersistence;
13
13
  readonly strategy: WizardStrategy;
14
14
  readonly creditCost?: number;
15
+ readonly deductCredits?: (cost: number) => Promise<boolean>;
15
16
  readonly onSuccess?: (result: unknown) => void;
16
17
  readonly onError?: (error: string) => void;
17
18
  }
@@ -20,6 +20,7 @@ interface UsePhotoBlockingGenerationProps {
20
20
  readonly persistence: CreationPersistence;
21
21
  readonly strategy: WizardStrategy;
22
22
  readonly creditCost?: number;
23
+ readonly deductCredits?: (cost: number) => Promise<boolean>;
23
24
  readonly alertMessages: AlertMessages;
24
25
  readonly onSuccess?: (result: unknown) => void;
25
26
  readonly onError?: (error: string) => void;
@@ -39,6 +40,7 @@ export function usePhotoBlockingGeneration(
39
40
  scenario,
40
41
  persistence,
41
42
  creditCost,
43
+ deductCredits,
42
44
  strategy,
43
45
  alertMessages,
44
46
  onSuccess,
@@ -67,9 +69,19 @@ export function usePhotoBlockingGeneration(
67
69
  }
68
70
 
69
71
  creationIdRef.current = null;
72
+
73
+ // Deduct credits after successful generation
74
+ if (deductCredits && creditCost) {
75
+ await deductCredits(creditCost).catch((err) => {
76
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
77
+ console.error("[PhotoBlockingGeneration] deductCredits error:", err);
78
+ }
79
+ });
80
+ }
81
+
70
82
  onSuccess?.(result);
71
83
  },
72
- [userId, persistence, onSuccess],
84
+ [userId, persistence, deductCredits, creditCost, onSuccess],
73
85
  );
74
86
 
75
87
  const handleError = useCallback(
@@ -16,7 +16,7 @@ import type {
16
16
  } from "./use-video-queue-generation.types";
17
17
 
18
18
  export function useVideoQueueGeneration(props: UseVideoQueueGenerationProps): UseVideoQueueGenerationReturn {
19
- const { userId, scenario, persistence, strategy, creditCost, onSuccess, onError } = props;
19
+ const { userId, scenario, persistence, strategy, creditCost, deductCredits, onSuccess, onError } = props;
20
20
 
21
21
  const creationIdRef = useRef<string | null>(null);
22
22
  const requestIdRef = useRef<string | null>(null);
@@ -111,6 +111,15 @@ export function useVideoQueueGeneration(props: UseVideoQueueGenerationProps): Us
111
111
 
112
112
  resetRefs();
113
113
 
114
+ // Deduct credits after successful generation
115
+ if (deductCredits && creditCost) {
116
+ await deductCredits(creditCost).catch((err) => {
117
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
118
+ console.error("[VideoQueue] deductCredits error:", err);
119
+ }
120
+ });
121
+ }
122
+
114
123
  if (typeof __DEV__ !== "undefined" && __DEV__) {
115
124
  console.log("[VideoQueue] 🎯 Calling onSuccess callback now...", { persistenceSucceeded });
116
125
  }
@@ -120,7 +129,7 @@ export function useVideoQueueGeneration(props: UseVideoQueueGenerationProps): Us
120
129
  console.log("[VideoQueue] ✅ onSuccess callback completed");
121
130
  }
122
131
  },
123
- [userId, persistence, onSuccess, onError, resetRefs, clearPolling],
132
+ [userId, persistence, deductCredits, creditCost, onSuccess, onError, resetRefs, clearPolling],
124
133
  );
125
134
 
126
135
  const handleError = useCallback(
@@ -28,6 +28,7 @@ export const useWizardGeneration = (props: UseWizardGenerationProps): UseWizardG
28
28
  isGeneratingStep,
29
29
  alertMessages,
30
30
  creditCost,
31
+ deductCredits,
31
32
  onSuccess,
32
33
  onError,
33
34
  onCreditsExhausted,
@@ -53,6 +54,7 @@ export const useWizardGeneration = (props: UseWizardGenerationProps): UseWizardG
53
54
  persistence,
54
55
  strategy,
55
56
  creditCost,
57
+ deductCredits,
56
58
  onSuccess,
57
59
  onError,
58
60
  });
@@ -63,6 +65,7 @@ export const useWizardGeneration = (props: UseWizardGenerationProps): UseWizardG
63
65
  persistence,
64
66
  strategy,
65
67
  creditCost,
68
+ deductCredits,
66
69
  alertMessages,
67
70
  onSuccess,
68
71
  onError,
@@ -36,6 +36,8 @@ export interface UseWizardGenerationProps {
36
36
  readonly alertMessages: AlertMessages;
37
37
  /** Credit cost for this generation - REQUIRED, determined by the app */
38
38
  readonly creditCost: number;
39
+ /** Called after successful generation to deduct credits — provided by the app */
40
+ readonly deductCredits?: (cost: number) => Promise<boolean>;
39
41
  readonly onSuccess?: (result: unknown) => void;
40
42
  readonly onError?: (error: string) => void;
41
43
  readonly onCreditsExhausted?: () => void;