@umituz/react-native-ai-generation-content 1.57.1 → 1.57.3

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.57.1",
3
+ "version": "1.57.3",
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",
@@ -72,7 +72,7 @@ export async function buildVideoInput(
72
72
 
73
73
  export function createVideoStrategy(options: CreateVideoStrategyOptions): WizardStrategy {
74
74
  const { scenario, creditCost } = options;
75
- const videoFeatureType = getVideoFeatureType(scenario.id);
75
+ const videoFeatureType = getVideoFeatureType(scenario);
76
76
 
77
77
  return {
78
78
  execute: async (input: unknown) => {
@@ -4,25 +4,40 @@
4
4
  */
5
5
 
6
6
  import type { VideoFeatureType } from "../../../../../domain/interfaces";
7
+ import type { WizardScenarioData } from "../../presentation/hooks/wizard-generation.types";
7
8
  import { VIDEO_FEATURE_PATTERNS } from "./wizard-strategy.constants";
8
9
 
9
10
  declare const __DEV__: boolean;
10
11
 
11
12
  /**
12
- * Determines the video feature type based on scenario ID
13
+ * Determines the video feature type from scenario
14
+ * Priority: featureType (app-controlled) > pattern matching > default
13
15
  */
14
- export function getVideoFeatureType(scenarioId: string): VideoFeatureType {
15
- const id = scenarioId.toLowerCase();
16
+ export function getVideoFeatureType(scenario: WizardScenarioData): VideoFeatureType {
17
+ const { id, featureType } = scenario;
16
18
 
17
- for (const [pattern, featureType] of Object.entries(VIDEO_FEATURE_PATTERNS)) {
18
- if (id.includes(pattern)) {
19
- return featureType;
19
+ // Primary: Use featureType from main app (package-driven design)
20
+ if (featureType) {
21
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
22
+ console.log("[VideoUtils] Using featureType from app", { id, featureType });
20
23
  }
24
+ return featureType;
21
25
  }
22
26
 
23
- // Default to image-to-video for content scenarios
27
+ // Fallback: Pattern matching for legacy scenarios
28
+ const lowerId = id.toLowerCase();
29
+ for (const [pattern, type] of Object.entries(VIDEO_FEATURE_PATTERNS)) {
30
+ if (lowerId.includes(pattern)) {
31
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
32
+ console.log("[VideoUtils] Pattern match", { id, pattern, type });
33
+ }
34
+ return type;
35
+ }
36
+ }
37
+
38
+ // Default: text-to-video
24
39
  if (typeof __DEV__ !== "undefined" && __DEV__) {
25
- console.log("[VideoUtils] Defaulting to image-to-video", { scenarioId });
40
+ console.log("[VideoUtils] Default to text-to-video", { id });
26
41
  }
27
- return "image-to-video";
42
+ return "text-to-video";
28
43
  }
@@ -19,10 +19,14 @@ export interface BaseWizardFlowProps {
19
19
  readonly isCreditsLoaded: boolean;
20
20
  /** Credit cost for this generation - REQUIRED, determined by the app */
21
21
  readonly creditCost: number;
22
+ /** Is device offline - prevents generation when true */
23
+ readonly isOffline?: boolean;
22
24
  /** Show auth modal with callback */
23
25
  readonly onShowAuthModal: (callback: () => void) => void;
24
26
  /** Show paywall */
25
27
  readonly onShowPaywall: () => void;
28
+ /** Called when network is unavailable and generation is blocked */
29
+ readonly onNetworkError?: () => void;
26
30
  /** Called when generation completes */
27
31
  readonly onGenerationComplete?: () => void;
28
32
  /** Called on generation error */
@@ -19,6 +19,8 @@ export interface WizardScenarioData {
19
19
  readonly model?: string;
20
20
  readonly title?: string;
21
21
  readonly description?: string;
22
+ /** Video feature type - set by main app to control generation mode */
23
+ readonly featureType?: "text-to-video" | "image-to-video" | "ai-kiss" | "ai-hug";
22
24
  [key: string]: unknown;
23
25
  }
24
26
 
@@ -34,8 +34,10 @@ export const ImageToVideoWizardFlow: React.FC<ImageToVideoWizardFlowProps> = (pr
34
34
  creditBalance,
35
35
  isCreditsLoaded,
36
36
  creditCost,
37
+ isOffline,
37
38
  onShowAuthModal,
38
39
  onShowPaywall,
40
+ onNetworkError,
39
41
  onGenerationComplete,
40
42
  onGenerationError,
41
43
  onBack,
@@ -69,11 +71,15 @@ export const ImageToVideoWizardFlow: React.FC<ImageToVideoWizardFlowProps> = (pr
69
71
 
70
72
  const handleGenerationStart = useCallback(
71
73
  (_data: Record<string, unknown>, proceed: () => void) => {
74
+ // Network check - must be online to generate
75
+ if (isOffline) { onNetworkError?.(); return; }
76
+ // Auth check - must be authenticated
72
77
  if (!isAuthenticated) { onShowAuthModal(proceed); return; }
78
+ // Credit check - must have enough credits
73
79
  if (!hasPremium && isCreditsLoaded && creditBalance < creditCost) { onShowPaywall(); return; }
74
80
  proceed();
75
81
  },
76
- [isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onShowAuthModal, onShowPaywall],
82
+ [isOffline, isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onNetworkError, onShowAuthModal, onShowPaywall],
77
83
  );
78
84
 
79
85
  const handleGenerationComplete = useCallback(() => {
@@ -34,8 +34,10 @@ export const TextToImageWizardFlow: React.FC<TextToImageWizardFlowProps> = (prop
34
34
  creditBalance,
35
35
  isCreditsLoaded,
36
36
  creditCost,
37
+ isOffline,
37
38
  onShowAuthModal,
38
39
  onShowPaywall,
40
+ onNetworkError,
39
41
  onGenerationComplete,
40
42
  onGenerationError,
41
43
  onBack,
@@ -69,11 +71,15 @@ export const TextToImageWizardFlow: React.FC<TextToImageWizardFlowProps> = (prop
69
71
 
70
72
  const handleGenerationStart = useCallback(
71
73
  (_data: Record<string, unknown>, proceed: () => void) => {
74
+ // Network check - must be online to generate
75
+ if (isOffline) { onNetworkError?.(); return; }
76
+ // Auth check - must be authenticated
72
77
  if (!isAuthenticated) { onShowAuthModal(proceed); return; }
78
+ // Credit check - must have enough credits
73
79
  if (!hasPremium && isCreditsLoaded && creditBalance < creditCost) { onShowPaywall(); return; }
74
80
  proceed();
75
81
  },
76
- [isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onShowAuthModal, onShowPaywall],
82
+ [isOffline, isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onNetworkError, onShowAuthModal, onShowPaywall],
77
83
  );
78
84
 
79
85
  const handleGenerationComplete = useCallback(() => {
@@ -34,8 +34,10 @@ export const TextToVideoWizardFlow: React.FC<TextToVideoWizardFlowProps> = (prop
34
34
  creditBalance,
35
35
  isCreditsLoaded,
36
36
  creditCost,
37
+ isOffline,
37
38
  onShowAuthModal,
38
39
  onShowPaywall,
40
+ onNetworkError,
39
41
  onGenerationComplete,
40
42
  onGenerationError,
41
43
  onBack,
@@ -69,11 +71,15 @@ export const TextToVideoWizardFlow: React.FC<TextToVideoWizardFlowProps> = (prop
69
71
 
70
72
  const handleGenerationStart = useCallback(
71
73
  (_data: Record<string, unknown>, proceed: () => void) => {
74
+ // Network check - must be online to generate
75
+ if (isOffline) { onNetworkError?.(); return; }
76
+ // Auth check - must be authenticated
72
77
  if (!isAuthenticated) { onShowAuthModal(proceed); return; }
78
+ // Credit check - must have enough credits
73
79
  if (!hasPremium && isCreditsLoaded && creditBalance < creditCost) { onShowPaywall(); return; }
74
80
  proceed();
75
81
  },
76
- [isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onShowAuthModal, onShowPaywall],
82
+ [isOffline, isAuthenticated, hasPremium, creditBalance, creditCost, isCreditsLoaded, onNetworkError, onShowAuthModal, onShowPaywall],
77
83
  );
78
84
 
79
85
  const handleGenerationComplete = useCallback(() => {