@umituz/react-native-ai-generation-content 1.20.38 → 1.20.39
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/features/hd-touch-up/presentation/hooks/useHDTouchUpFeature.ts +1 -1
- package/src/features/photo-restoration/presentation/hooks/usePhotoRestoreFeature.ts +1 -1
- package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +1 -1
- package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +1 -1
- package/src/presentation/components/AIGenerationConfig.tsx +0 -3
- package/src/presentation/components/flows/AIGenerateWizardFlow.tsx +2 -2
- package/src/presentation/components/flows/AIGenerateWizardFlow.types.ts +15 -2
- package/src/presentation/components/flows/useAIGenerateWizardFlow.ts +13 -6
- package/src/presentation/hooks/generation/orchestrator.ts +4 -1
- package/src/presentation/hooks/generation/useAIFeatureGeneration.ts +16 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.39",
|
|
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",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useSingleImageFeature, type BaseSingleImageHookReturn } from "../../../image-to-image";
|
|
7
|
-
import type { HDTouchUpFeatureConfig
|
|
7
|
+
import type { HDTouchUpFeatureConfig } from "../../domain/types";
|
|
8
8
|
|
|
9
9
|
export interface UseHDTouchUpFeatureProps {
|
|
10
10
|
config: HDTouchUpFeatureConfig;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useSingleImageFeature, type BaseSingleImageHookReturn } from "../../../image-to-image";
|
|
7
|
-
import type { PhotoRestoreFeatureConfig
|
|
7
|
+
import type { PhotoRestoreFeatureConfig } from "../../domain/types";
|
|
8
8
|
|
|
9
9
|
export interface UsePhotoRestoreFeatureProps {
|
|
10
10
|
config: PhotoRestoreFeatureConfig;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useSingleImageFeature, type BaseSingleImageHookReturn } from "../../../image-to-image";
|
|
7
|
-
import type { RemoveBackgroundFeatureConfig
|
|
7
|
+
import type { RemoveBackgroundFeatureConfig } from "../../domain/types";
|
|
8
8
|
|
|
9
9
|
export interface UseRemoveBackgroundFeatureProps {
|
|
10
10
|
config: RemoveBackgroundFeatureConfig;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useSingleImageFeature, type BaseSingleImageHookReturn } from "../../../image-to-image";
|
|
7
|
-
import type { UpscaleFeatureConfig
|
|
7
|
+
import type { UpscaleFeatureConfig } from "../../domain/types";
|
|
8
8
|
|
|
9
9
|
export interface UseUpscaleFeatureProps {
|
|
10
10
|
config: UpscaleFeatureConfig;
|
|
@@ -4,7 +4,6 @@ import { View, Image, StyleSheet } from "react-native";
|
|
|
4
4
|
import { AIGenerationHero } from "./AIGenerationHero";
|
|
5
5
|
import { AIGenerationForm } from "./AIGenerationForm";
|
|
6
6
|
import type { AIGenerationFormProps } from "./AIGenerationForm.types";
|
|
7
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
8
7
|
|
|
9
8
|
export interface AIGenerationConfigProps extends Omit<AIGenerationFormProps, "isGenerating" | "progress"> {
|
|
10
9
|
readonly heroTitle: string;
|
|
@@ -24,8 +23,6 @@ export const AIGenerationConfig: React.FC<AIGenerationConfigProps> = ({
|
|
|
24
23
|
progress = 0,
|
|
25
24
|
...formProps
|
|
26
25
|
}) => {
|
|
27
|
-
const tokens = useAppDesignTokens();
|
|
28
|
-
|
|
29
26
|
return (
|
|
30
27
|
<View style={styles.container}>
|
|
31
28
|
{heroTitle && (
|
|
@@ -61,7 +61,7 @@ export const AIGenerateWizardFlow: React.FC<AIGenerateWizardFlowProps> = ({
|
|
|
61
61
|
<PartnerStepScreen
|
|
62
62
|
t={t}
|
|
63
63
|
onBack={handleBack}
|
|
64
|
-
onContinue={(img:
|
|
64
|
+
onContinue={(img: { uri: string; previewUrl?: string }) => {
|
|
65
65
|
setStepImage(isStep2 ? 1 : 0, { uri: img.uri, previewUrl: img.previewUrl || img.uri });
|
|
66
66
|
handleNext();
|
|
67
67
|
}}
|
|
@@ -184,7 +184,7 @@ export const AIGenerateWizardFlow: React.FC<AIGenerateWizardFlowProps> = ({
|
|
|
184
184
|
isGenerating={isGenerating}
|
|
185
185
|
progress={progress}
|
|
186
186
|
presets={presets}
|
|
187
|
-
onPresetPress={handleGenerate
|
|
187
|
+
onPresetPress={() => { void handleGenerate(); }}
|
|
188
188
|
prompt={prompt}
|
|
189
189
|
onPromptChange={setPrompt}
|
|
190
190
|
styles={styleOptions}
|
|
@@ -33,11 +33,24 @@ export interface AIGenerateWizardTranslations {
|
|
|
33
33
|
readonly maxFileSize: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export interface StyleOption {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly label: string;
|
|
39
|
+
readonly icon?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PresetOption {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly label: string;
|
|
45
|
+
readonly prompt?: string;
|
|
46
|
+
readonly icon?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
export interface AIGenerateWizardFlowProps {
|
|
37
50
|
readonly featureType: string;
|
|
38
51
|
readonly translations: AIGenerateWizardTranslations;
|
|
39
|
-
readonly styleOptions:
|
|
40
|
-
readonly presets:
|
|
52
|
+
readonly styleOptions: StyleOption[];
|
|
53
|
+
readonly presets: PresetOption[];
|
|
41
54
|
readonly durationOptions: number[];
|
|
42
55
|
readonly onGenerate: (data: {
|
|
43
56
|
prompt: string;
|
|
@@ -3,9 +3,16 @@ import { useMemo, useCallback, useEffect } from "react";
|
|
|
3
3
|
import { useAIGenerateState, AIGenerateStep } from "../../hooks/generation/useAIGenerateState";
|
|
4
4
|
import { getAIFeatureConfig, hasAIFeature } from "../../screens/ai-feature/registry";
|
|
5
5
|
|
|
6
|
+
interface GenerationData {
|
|
7
|
+
prompt: string;
|
|
8
|
+
style: string;
|
|
9
|
+
duration: number;
|
|
10
|
+
images: { uri: string; previewUrl?: string }[];
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
interface UseAIGenerateWizardFlowProps {
|
|
7
14
|
featureType: string;
|
|
8
|
-
onGenerate: (data:
|
|
15
|
+
onGenerate: (data: GenerationData) => Promise<string | null | void>;
|
|
9
16
|
onBack?: () => void;
|
|
10
17
|
}
|
|
11
18
|
|
|
@@ -15,15 +22,15 @@ export function useAIGenerateWizardFlow({
|
|
|
15
22
|
onBack: onBackProp,
|
|
16
23
|
}: UseAIGenerateWizardFlowProps) {
|
|
17
24
|
const state = useAIGenerateState();
|
|
18
|
-
const {
|
|
19
|
-
currentStep, setCurrentStep,
|
|
20
|
-
setProgress, setResult, images, prompt, selectedStyle,
|
|
21
|
-
selectedDuration
|
|
25
|
+
const {
|
|
26
|
+
currentStep, setCurrentStep, setIsGenerating,
|
|
27
|
+
setProgress, setResult, images, prompt, selectedStyle,
|
|
28
|
+
selectedDuration
|
|
22
29
|
} = state;
|
|
23
30
|
|
|
24
31
|
const imageCountRequired = useMemo(() => {
|
|
25
32
|
if (!featureType || !hasAIFeature(featureType)) return 0;
|
|
26
|
-
const config = getAIFeatureConfig(featureType as
|
|
33
|
+
const config = getAIFeatureConfig(featureType as Parameters<typeof getAIFeatureConfig>[0]);
|
|
27
34
|
if (config.mode === "dual" || config.mode === "dual-video") return 2;
|
|
28
35
|
if (config.mode === "single" || config.mode === "single-with-prompt")
|
|
29
36
|
return 1;
|
|
@@ -70,7 +70,10 @@ export const useGenerationOrchestrator = <TInput, TResult>(
|
|
|
70
70
|
|
|
71
71
|
const offlineStore = useOfflineStore();
|
|
72
72
|
const { showError, showSuccess } = useAlert();
|
|
73
|
-
const defaultCredits = useDeductCredit({ userId, onCreditsExhausted }) as
|
|
73
|
+
const defaultCredits = useDeductCredit({ userId, onCreditsExhausted }) as {
|
|
74
|
+
checkCredits: (amount: number) => Promise<boolean>;
|
|
75
|
+
deductCredit: (amount: number) => Promise<void>;
|
|
76
|
+
};
|
|
74
77
|
|
|
75
78
|
// Use provided credit callbacks or default to useDeductCredit hook
|
|
76
79
|
const checkCredits = credits?.checkCredits ?? defaultCredits.checkCredits;
|
|
@@ -9,12 +9,25 @@ import { prepareImage } from "../../../infrastructure/utils";
|
|
|
9
9
|
import type { AIFeatureId } from "../../screens/ai-feature/types";
|
|
10
10
|
import type { ImageFeatureType, VideoFeatureType } from "../../../domain/interfaces";
|
|
11
11
|
|
|
12
|
+
interface AlertMessages {
|
|
13
|
+
success?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
network?: string;
|
|
16
|
+
credits?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface GenerationError {
|
|
20
|
+
type: string;
|
|
21
|
+
message: string;
|
|
22
|
+
originalError?: Error;
|
|
23
|
+
}
|
|
24
|
+
|
|
12
25
|
interface FeatureGenerationConfig {
|
|
13
26
|
featureType: AIFeatureId;
|
|
14
27
|
userId?: string;
|
|
15
|
-
alertMessages:
|
|
16
|
-
onSuccess?: (result:
|
|
17
|
-
onError?: (error:
|
|
28
|
+
alertMessages: AlertMessages;
|
|
29
|
+
onSuccess?: (result: string) => void;
|
|
30
|
+
onError?: (error: GenerationError) => void;
|
|
18
31
|
creditCost?: number;
|
|
19
32
|
onCreditsExhausted?: () => void;
|
|
20
33
|
}
|