@umituz/react-native-ai-generation-content 1.27.17 → 1.27.19

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.27.17",
3
+ "version": "1.27.19",
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",
@@ -47,7 +47,8 @@ export interface TextToImageCallbacks {
47
47
  calculateCost: (numImages: NumImages, model?: string | null) => number;
48
48
  canAfford: (cost: number) => boolean;
49
49
  isAuthenticated: () => boolean;
50
- onAuthRequired?: () => void;
50
+ /** Called when auth is required. Pass retryCallback to resume after auth. */
51
+ onAuthRequired?: (retryCallback?: () => void) => void;
51
52
  onCreditsRequired?: (cost: number) => void;
52
53
  onSuccess?: (imageUrls: string[]) => void;
53
54
  onError?: (error: string) => void;
@@ -34,7 +34,7 @@ export interface TextToImageGenerationState {
34
34
  export interface UseGenerationReturn {
35
35
  generationState: TextToImageGenerationState;
36
36
  totalCost: number;
37
- handleGenerate: () => Promise<TextToImageGenerationResult | null>;
37
+ handleGenerate: (options?: { skipAuthCheck?: boolean }) => Promise<TextToImageGenerationResult | null>;
38
38
  }
39
39
 
40
40
  const DEFAULT_ALERT_MESSAGES: AlertMessages = {
@@ -92,7 +92,8 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
92
92
  },
93
93
  });
94
94
 
95
- const handleGenerate = useCallback(async (): Promise<TextToImageGenerationResult | null> => {
95
+ const handleGenerate = useCallback(async (options?: { skipAuthCheck?: boolean }): Promise<TextToImageGenerationResult | null> => {
96
+ const { skipAuthCheck = false } = options ?? {};
96
97
  const trimmedPrompt = formState.prompt.trim();
97
98
 
98
99
  if (!trimmedPrompt) {
@@ -103,12 +104,18 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
103
104
  return { success: false, error: "Prompt is required" };
104
105
  }
105
106
 
106
- // Auth check BEFORE generation
107
- if (!callbacks.isAuthenticated()) {
107
+ // Auth check BEFORE generation (skip if retrying after successful auth)
108
+ if (!skipAuthCheck && !callbacks.isAuthenticated()) {
108
109
  if (typeof __DEV__ !== "undefined" && __DEV__) {
109
110
  console.log("[TextToImage] Auth required");
110
111
  }
111
- callbacks.onAuthRequired?.();
112
+ // Pass retry callback to resume generation after auth (skip auth check on retry)
113
+ callbacks.onAuthRequired?.(() => {
114
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
115
+ console.log("[TextToImage] Retrying generation after auth (skipping auth check)");
116
+ }
117
+ void handleGenerate({ skipAuthCheck: true });
118
+ });
112
119
  return { success: false, error: "Authentication required" };
113
120
  }
114
121
 
@@ -24,8 +24,8 @@ export interface AIFeatureCallbacksConfig<TRequest = unknown, TResult = unknown>
24
24
  imageUrls?: string[];
25
25
  }>;
26
26
 
27
- // Actions from app
28
- showAuthModal: () => void;
27
+ // Actions from app - showAuthModal accepts callback for post-auth resume
28
+ showAuthModal: (callback?: () => void) => void;
29
29
  openPaywall: () => void;
30
30
  deductCredits?: (amount: number) => Promise<void>;
31
31
 
@@ -53,7 +53,8 @@ export interface AIFeatureCallbacks<TRequest = unknown, TResult = unknown> {
53
53
  calculateCost: (multiplier?: number, _model?: string | null) => number;
54
54
  canAfford: (cost: number) => boolean;
55
55
  isAuthenticated: () => boolean;
56
- onAuthRequired: () => void;
56
+ /** Called when auth is required. Pass retryCallback to resume after auth. */
57
+ onAuthRequired: (retryCallback?: () => void) => void;
57
58
  onCreditsRequired: (cost?: number) => void;
58
59
  onSuccess?: (result: TResult) => void;
59
60
  onError?: (error: string) => void;
@@ -97,8 +98,8 @@ export function useAIFeatureCallbacks<TRequest = unknown, TResult = unknown>(
97
98
  [creditCostPerUnit],
98
99
  );
99
100
 
100
- const onAuthRequired = useCallback(() => {
101
- showAuthModal();
101
+ const onAuthRequired = useCallback((retryCallback?: () => void) => {
102
+ showAuthModal(retryCallback);
102
103
  }, [showAuthModal]);
103
104
 
104
105
  const onCreditsRequired = useCallback(