@umituz/react-native-ai-generation-content 1.17.88 → 1.17.90

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.88",
3
+ "version": "1.17.90",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -35,6 +35,8 @@ const initialState: GenerationState = {
35
35
  error: null,
36
36
  };
37
37
 
38
+ declare const __DEV__: boolean;
39
+
38
40
  export function useGeneration(options: UseGenerationOptions): UseGenerationReturn {
39
41
  const { formState, callbacks, onPromptCleared } = options;
40
42
  const [generationState, setGenerationState] = useState<GenerationState>(initialState);
@@ -42,23 +44,35 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
42
44
  const totalCost = callbacks.calculateCost(formState.numImages, formState.selectedModel);
43
45
 
44
46
  const handleGenerate = useCallback(async (): Promise<TextToImageGenerationResult | null> => {
47
+ if (__DEV__) console.log("[TextToImage] handleGenerate called");
48
+
45
49
  const trimmedPrompt = formState.prompt.trim();
46
50
 
47
51
  if (!trimmedPrompt) {
52
+ if (__DEV__) console.log("[TextToImage] No prompt provided");
48
53
  setGenerationState((prev) => ({ ...prev, error: "Prompt is required" }));
49
54
  return null;
50
55
  }
51
56
 
52
- if (!callbacks.isAuthenticated()) {
57
+ const isAuth = callbacks.isAuthenticated();
58
+ if (__DEV__) console.log("[TextToImage] isAuthenticated:", isAuth);
59
+
60
+ if (!isAuth) {
61
+ if (__DEV__) console.log("[TextToImage] Auth required - calling onAuthRequired");
53
62
  callbacks.onAuthRequired?.();
54
63
  return null;
55
64
  }
56
65
 
57
- if (!callbacks.canAfford(totalCost)) {
66
+ const affordable = callbacks.canAfford(totalCost);
67
+ if (__DEV__) console.log("[TextToImage] canAfford:", affordable, "totalCost:", totalCost);
68
+
69
+ if (!affordable) {
70
+ if (__DEV__) console.log("[TextToImage] Credits required - calling onCreditsRequired");
58
71
  callbacks.onCreditsRequired?.(totalCost);
59
72
  return null;
60
73
  }
61
74
 
75
+ if (__DEV__) console.log("[TextToImage] Starting generation...");
62
76
  setGenerationState({ isGenerating: true, progress: 0, error: null });
63
77
 
64
78
  const request: TextToImageGenerationRequest = {
@@ -73,14 +87,19 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
73
87
  outputFormat: formState.outputFormat,
74
88
  };
75
89
 
90
+ if (__DEV__) console.log("[TextToImage] Request:", JSON.stringify(request, null, 2));
91
+
76
92
  try {
77
93
  const result = await callbacks.executeGeneration(request);
94
+ if (__DEV__) console.log("[TextToImage] Result:", JSON.stringify(result, null, 2));
78
95
 
79
96
  if (result.success === true) {
97
+ if (__DEV__) console.log("[TextToImage] Success! Image URLs:", result.imageUrls);
80
98
  callbacks.onSuccess?.(result.imageUrls);
81
99
  onPromptCleared?.();
82
100
  setGenerationState({ isGenerating: false, progress: 100, error: null });
83
101
  } else {
102
+ if (__DEV__) console.log("[TextToImage] Generation failed:", result.error);
84
103
  setGenerationState({ isGenerating: false, progress: 0, error: result.error });
85
104
  callbacks.onError?.(result.error);
86
105
  }
@@ -88,6 +107,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
88
107
  return result;
89
108
  } catch (error) {
90
109
  const message = error instanceof Error ? error.message : String(error);
110
+ if (__DEV__) console.error("[TextToImage] Exception:", message);
91
111
  setGenerationState({ isGenerating: false, progress: 0, error: message });
92
112
  callbacks.onError?.(message);
93
113
  return null;
@@ -27,6 +27,8 @@ export interface GenerateButtonProps {
27
27
  readonly style?: ViewStyle;
28
28
  }
29
29
 
30
+ declare const __DEV__: boolean;
31
+
30
32
  export const GenerateButton: React.FC<GenerateButtonProps> = ({
31
33
  isDisabled = false,
32
34
  isProcessing = false,
@@ -45,11 +47,18 @@ export const GenerateButton: React.FC<GenerateButtonProps> = ({
45
47
  const displayText = isProcessing && processingText ? processingText : text;
46
48
  const finalDisplayText = costLabel ? `${displayText} (${costLabel})` : displayText;
47
49
 
50
+ const handlePress = () => {
51
+ if (__DEV__) console.log("[GenerateButton] onPress called, disabled:", disabled, "isDisabled:", isDisabled, "isProcessing:", isProcessing);
52
+ if (!disabled) {
53
+ onPress();
54
+ }
55
+ };
56
+
48
57
  return (
49
58
  <View style={[styles.container, { marginTop: tokens.spacing.xl }, style]}>
50
59
  <View style={styles.row}>
51
60
  <TouchableOpacity
52
- onPress={onPress}
61
+ onPress={handlePress}
53
62
  disabled={disabled}
54
63
  activeOpacity={0.8}
55
64
  style={[