@umituz/react-native-ai-generation-content 1.26.7 → 1.26.8
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 +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/wizard-strategy.factory.ts +6 -8
- package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +1 -1
- package/src/domains/generation/wizard/presentation/screens/GenericPhotoUploadScreen.tsx +1 -12
- package/src/domains/generation/wizard/presentation/steps/PhotoUploadStep.tsx +1 -3
- package/src/presentation/hooks/generation/useAIGenerateState.ts +3 -0
- package/src/presentation/layouts/types/layout-props.ts +30 -4
- package/src/presentation/hooks/generation/useAIFeatureGeneration.ts +0 -180
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.8",
|
|
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",
|
|
@@ -9,8 +9,6 @@ import type { GenerationStrategy } from "../../../../presentation/hooks/generati
|
|
|
9
9
|
import type { VideoFeatureType } from "../../../../domain/interfaces";
|
|
10
10
|
import { executeVideoFeature } from "../../../../infrastructure/services/video-feature-executor.service";
|
|
11
11
|
import { createCreationsRepository } from "../../../creations/infrastructure/adapters";
|
|
12
|
-
import { enhanceCouplePrompt } from "../../../../features/couple-future/infrastructure/couplePromptEnhancer";
|
|
13
|
-
import type { CoupleFeatureSelection } from "../../../../features/couple-future/domain/types";
|
|
14
12
|
import type { WizardOutputType, WizardScenarioData } from "../../presentation/hooks/useWizardGeneration";
|
|
15
13
|
|
|
16
14
|
declare const __DEV__: boolean;
|
|
@@ -179,29 +177,29 @@ async function buildGenerationInput(
|
|
|
179
177
|
|
|
180
178
|
// For image generation, enhance prompt with style selections
|
|
181
179
|
if (outputType === "image") {
|
|
182
|
-
const
|
|
180
|
+
const styleEnhancements: string[] = [];
|
|
183
181
|
|
|
184
182
|
// Romantic mood (multi-select array)
|
|
185
183
|
const romanticMoods = wizardData.selection_romantic_mood as string[] | undefined;
|
|
186
184
|
if (romanticMoods && romanticMoods.length > 0) {
|
|
187
|
-
|
|
185
|
+
styleEnhancements.push(`Mood: ${romanticMoods.join(", ")}`);
|
|
188
186
|
}
|
|
189
187
|
|
|
190
188
|
// Art style (single select)
|
|
191
189
|
const artStyle = wizardData.selection_art_style as string | undefined;
|
|
192
190
|
if (artStyle && artStyle !== "original") {
|
|
193
|
-
|
|
191
|
+
styleEnhancements.push(`Art style: ${artStyle}`);
|
|
194
192
|
}
|
|
195
193
|
|
|
196
194
|
// Artist style (single select)
|
|
197
195
|
const artist = wizardData.selection_artist_style as string | undefined;
|
|
198
196
|
if (artist && artist !== "original") {
|
|
199
|
-
|
|
197
|
+
styleEnhancements.push(`Artist style: ${artist}`);
|
|
200
198
|
}
|
|
201
199
|
|
|
202
200
|
// Enhance prompt with selected styles
|
|
203
|
-
if (
|
|
204
|
-
prompt =
|
|
201
|
+
if (styleEnhancements.length > 0) {
|
|
202
|
+
prompt = `${prompt}. ${styleEnhancements.join(", ")}`;
|
|
205
203
|
}
|
|
206
204
|
|
|
207
205
|
return {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useState, useCallback } from "react";
|
|
8
8
|
import * as ImagePicker from "expo-image-picker";
|
|
9
9
|
import { Alert } from "react-native";
|
|
10
|
-
import type { UploadedImage } from "
|
|
10
|
+
import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
|
|
11
11
|
|
|
12
12
|
export interface PhotoUploadConfig {
|
|
13
13
|
readonly maxFileSizeMB?: number;
|
|
@@ -17,8 +17,7 @@ import {
|
|
|
17
17
|
} from "@umituz/react-native-design-system";
|
|
18
18
|
import { PhotoUploadCard } from "../../../../presentation/components";
|
|
19
19
|
import { FaceDetectionToggle } from "../../../../domains/face-detection";
|
|
20
|
-
import {
|
|
21
|
-
import type { UploadedImage } from "../../../../features/partner-upload/domain/types";
|
|
20
|
+
import type { UploadedImage } from "../../../../presentation/hooks/generation/useAIGenerateState";
|
|
22
21
|
import { usePhotoUploadState } from "../hooks/usePhotoUploadState";
|
|
23
22
|
|
|
24
23
|
export interface PhotoUploadScreenTranslations {
|
|
@@ -135,16 +134,6 @@ export const GenericPhotoUploadScreen: React.FC<PhotoUploadScreenProps> = ({
|
|
|
135
134
|
{translations.subtitle}
|
|
136
135
|
</AtomicText>
|
|
137
136
|
|
|
138
|
-
{/* Photo Tips - InfoGrid version */}
|
|
139
|
-
{showPhotoTips && (
|
|
140
|
-
<PhotoTips
|
|
141
|
-
t={t}
|
|
142
|
-
titleKey="photoUpload.tips.title"
|
|
143
|
-
headerIcon="bulb"
|
|
144
|
-
style={{ marginHorizontal: 24, marginBottom: 20 }}
|
|
145
|
-
/>
|
|
146
|
-
)}
|
|
147
|
-
|
|
148
137
|
{showFaceDetection && onFaceDetectionToggle && (
|
|
149
138
|
<FaceDetectionToggle
|
|
150
139
|
isEnabled={faceDetectionEnabled}
|
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
8
|
import type { PhotoUploadStepConfig } from "../../domain/entities/wizard-config.types";
|
|
9
|
-
|
|
10
|
-
// Use wizard domain's generic photo upload screen - NO feature-specific references!
|
|
9
|
+
import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
|
|
11
10
|
import { GenericPhotoUploadScreen } from "../screens/GenericPhotoUploadScreen";
|
|
12
|
-
import type { UploadedImage } from "../../../../features/partner-upload/domain/types";
|
|
13
11
|
|
|
14
12
|
export interface PhotoUploadStepProps {
|
|
15
13
|
readonly config: PhotoUploadStepConfig;
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
|
-
import type {
|
|
8
|
-
BaseSingleImageHookReturn,
|
|
9
|
-
BaseDualImageHookReturn,
|
|
10
|
-
} from "../../../features/image-to-image/domain/types";
|
|
11
7
|
import type {
|
|
12
8
|
ModalTranslations,
|
|
13
9
|
BaseLayoutTranslations,
|
|
@@ -24,6 +20,36 @@ import type {
|
|
|
24
20
|
SingleImageWithPromptFeatureState,
|
|
25
21
|
} from "./feature-states";
|
|
26
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Base hook return for single image features
|
|
25
|
+
*/
|
|
26
|
+
export interface BaseSingleImageHookReturn {
|
|
27
|
+
readonly imageUri: string | null;
|
|
28
|
+
readonly processedUrl: string | null;
|
|
29
|
+
readonly isProcessing: boolean;
|
|
30
|
+
readonly progress: number;
|
|
31
|
+
selectImage(): Promise<void>;
|
|
32
|
+
process(): Promise<void>;
|
|
33
|
+
save(): Promise<void>;
|
|
34
|
+
reset(): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Base hook return for dual image features
|
|
39
|
+
*/
|
|
40
|
+
export interface BaseDualImageHookReturn {
|
|
41
|
+
readonly sourceImageUri: string | null;
|
|
42
|
+
readonly targetImageUri: string | null;
|
|
43
|
+
readonly processedUrl: string | null;
|
|
44
|
+
readonly isProcessing: boolean;
|
|
45
|
+
readonly progress: number;
|
|
46
|
+
selectSourceImage(): Promise<void>;
|
|
47
|
+
selectTargetImage(): Promise<void>;
|
|
48
|
+
process(): Promise<void>;
|
|
49
|
+
save(): Promise<void>;
|
|
50
|
+
reset(): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
27
53
|
/**
|
|
28
54
|
* Single image feature layout props
|
|
29
55
|
* Note: No modal - shows fullscreen progress when processing (FutureUS pattern)
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
import { useImageGeneration } from "./useImageGeneration";
|
|
4
|
-
import { useVideoGeneration } from "./useVideoGeneration";
|
|
5
|
-
import { executeImageToVideo } from "../../../features/image-to-video";
|
|
6
|
-
import { executeTextToVideo } from "../../../features/text-to-video";
|
|
7
|
-
import { useGenerationOrchestrator } from "./orchestrator";
|
|
8
|
-
import { prepareImage } from "../../../infrastructure/utils";
|
|
9
|
-
import type { AIFeatureId } from "../../screens/ai-feature/types";
|
|
10
|
-
import type { ImageFeatureType, VideoFeatureType } from "../../../domain/interfaces";
|
|
11
|
-
import type { AlertMessages, GenerationError } from "./types";
|
|
12
|
-
|
|
13
|
-
interface FeatureGenerationConfig {
|
|
14
|
-
featureType: AIFeatureId;
|
|
15
|
-
userId?: string;
|
|
16
|
-
alertMessages: AlertMessages;
|
|
17
|
-
onSuccess?: (result: string) => void;
|
|
18
|
-
onError?: (error: GenerationError) => void;
|
|
19
|
-
creditCost?: number;
|
|
20
|
-
onCreditsExhausted?: () => void;
|
|
21
|
-
/** REQUIRED for video features: Video generation model ID from app config */
|
|
22
|
-
videoModel?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function useAIFeatureGeneration({
|
|
26
|
-
featureType,
|
|
27
|
-
userId,
|
|
28
|
-
alertMessages,
|
|
29
|
-
onSuccess,
|
|
30
|
-
onError,
|
|
31
|
-
creditCost = 1,
|
|
32
|
-
onCreditsExhausted,
|
|
33
|
-
videoModel,
|
|
34
|
-
}: FeatureGenerationConfig) {
|
|
35
|
-
|
|
36
|
-
// Hook for standard image features
|
|
37
|
-
const { generate: generateImage } = useImageGeneration({
|
|
38
|
-
featureType: featureType as ImageFeatureType,
|
|
39
|
-
userId,
|
|
40
|
-
processResult: (imageUrl) => imageUrl,
|
|
41
|
-
alertMessages,
|
|
42
|
-
onSuccess,
|
|
43
|
-
onError,
|
|
44
|
-
creditCost,
|
|
45
|
-
onCreditsExhausted,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Hook for standard video features (ai-hug, ai-kiss)
|
|
49
|
-
const { generate: generateVideo } = useVideoGeneration({
|
|
50
|
-
featureType: featureType as VideoFeatureType,
|
|
51
|
-
userId,
|
|
52
|
-
processResult: (videoUrl) => videoUrl,
|
|
53
|
-
alertMessages,
|
|
54
|
-
onSuccess,
|
|
55
|
-
onError,
|
|
56
|
-
creditCost,
|
|
57
|
-
onCreditsExhausted,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Orchestrator for Image-to-Video
|
|
61
|
-
const { generate: generateImageToVideo } = useGenerationOrchestrator(
|
|
62
|
-
{
|
|
63
|
-
execute: async (input: { imageUri: string; prompt: string; duration: number }, onProgress) => {
|
|
64
|
-
if (!videoModel) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
"videoModel is required for image-to-video feature. " +
|
|
67
|
-
"Please provide videoModel from app's generation config."
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const result = await executeImageToVideo(
|
|
72
|
-
{
|
|
73
|
-
imageUri: input.imageUri, // Pass URI directly
|
|
74
|
-
imageBase64: await prepareImage(input.imageUri),
|
|
75
|
-
motionPrompt: input.prompt,
|
|
76
|
-
options: { duration: input.duration },
|
|
77
|
-
userId: userId || "anonymous",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
model: videoModel,
|
|
81
|
-
buildInput: (image, prompt, opts) => ({
|
|
82
|
-
image,
|
|
83
|
-
prompt,
|
|
84
|
-
...opts
|
|
85
|
-
}),
|
|
86
|
-
onProgress,
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
if (!result.success || !result.videoUrl) throw new Error(result.error || "Generation failed");
|
|
90
|
-
return result.videoUrl;
|
|
91
|
-
},
|
|
92
|
-
getCreditCost: () => creditCost,
|
|
93
|
-
},
|
|
94
|
-
{ userId, alertMessages, onSuccess, onError, onCreditsExhausted }
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
// Orchestrator for Text-to-Video
|
|
98
|
-
const { generate: generateTextToVideo } = useGenerationOrchestrator(
|
|
99
|
-
{
|
|
100
|
-
execute: async (input: { prompt: string; duration: number }, onProgress) => {
|
|
101
|
-
if (!videoModel) {
|
|
102
|
-
throw new Error(
|
|
103
|
-
"videoModel is required for text-to-video feature. " +
|
|
104
|
-
"Please provide videoModel from app's generation config."
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const result = await executeTextToVideo(
|
|
109
|
-
{
|
|
110
|
-
prompt: input.prompt,
|
|
111
|
-
options: { duration: input.duration },
|
|
112
|
-
userId: userId || "anonymous",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
model: videoModel,
|
|
116
|
-
buildInput: (prompt, opts) => ({ prompt, ...opts }),
|
|
117
|
-
onProgress,
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
if (!result.success || !result.videoUrl) throw new Error(result.error || "Generation failed");
|
|
121
|
-
return result.videoUrl;
|
|
122
|
-
},
|
|
123
|
-
getCreditCost: () => creditCost,
|
|
124
|
-
},
|
|
125
|
-
{ userId, alertMessages, onSuccess, onError, onCreditsExhausted }
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const generate = useCallback(async (data: {
|
|
129
|
-
prompt: string;
|
|
130
|
-
style: string;
|
|
131
|
-
duration: number;
|
|
132
|
-
images: { uri: string }[];
|
|
133
|
-
}) => {
|
|
134
|
-
switch (featureType) {
|
|
135
|
-
case "image-to-video":
|
|
136
|
-
if (!data.images[0]?.uri) throw new Error("Image required for image-to-video");
|
|
137
|
-
return await generateImageToVideo({
|
|
138
|
-
imageUri: data.images[0].uri,
|
|
139
|
-
prompt: data.prompt,
|
|
140
|
-
duration: data.duration
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
case "text-to-video":
|
|
144
|
-
return await generateTextToVideo({
|
|
145
|
-
prompt: data.prompt,
|
|
146
|
-
duration: data.duration
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
case "ai-hug":
|
|
150
|
-
case "ai-kiss":
|
|
151
|
-
if (data.images.length < 2) throw new Error("Two images required");
|
|
152
|
-
return await generateVideo({
|
|
153
|
-
sourceImageBase64: await prepareImage(data.images[0].uri),
|
|
154
|
-
targetImageBase64: await prepareImage(data.images[1].uri),
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
default:
|
|
158
|
-
// Default to Image Generation
|
|
159
|
-
if (data.images.length > 0) {
|
|
160
|
-
// Single or dual image
|
|
161
|
-
if (data.images.length === 2 && (featureType === "face-swap")) {
|
|
162
|
-
return await generateImage({
|
|
163
|
-
sourceImageBase64: await prepareImage(data.images[0].uri),
|
|
164
|
-
targetImageBase64: await prepareImage(data.images[1].uri),
|
|
165
|
-
options: { style: data.style }
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
// Single image features
|
|
169
|
-
return await generateImage({
|
|
170
|
-
imageBase64: await prepareImage(data.images[0].uri),
|
|
171
|
-
prompt: data.prompt,
|
|
172
|
-
options: { style: data.style }
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
throw new Error(`Unsupported feature or missing input: ${featureType}`);
|
|
176
|
-
}
|
|
177
|
-
}, [featureType, generateImage, generateVideo, generateImageToVideo, generateTextToVideo]);
|
|
178
|
-
|
|
179
|
-
return { generate };
|
|
180
|
-
}
|