@umituz/react-native-ai-generation-content 1.17.24 → 1.17.25
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/domain/interfaces/ai-provider.interface.ts +66 -0
- package/src/features/ai-hug/domain/types/ai-hug.types.ts +4 -13
- package/src/features/ai-hug/domain/types/index.ts +0 -1
- package/src/features/ai-hug/index.ts +1 -6
- package/src/features/ai-hug/presentation/components/AIHugFeature.tsx +14 -22
- package/src/features/ai-hug/presentation/hooks/useAIHugFeature.ts +16 -35
- package/src/features/ai-kiss/domain/types/ai-kiss.types.ts +4 -13
- package/src/features/ai-kiss/domain/types/index.ts +0 -1
- package/src/features/ai-kiss/index.ts +1 -6
- package/src/features/ai-kiss/presentation/components/AIKissFeature.tsx +13 -20
- package/src/features/ai-kiss/presentation/hooks/useAIKissFeature.ts +16 -35
- package/src/features/anime-selfie/domain/types/anime-selfie.types.ts +0 -8
- package/src/features/anime-selfie/domain/types/index.ts +0 -1
- package/src/features/anime-selfie/index.ts +0 -5
- package/src/features/anime-selfie/presentation/components/AnimeSelfieFeature.tsx +0 -3
- package/src/features/anime-selfie/presentation/hooks/useAnimeSelfieFeature.ts +9 -27
- package/src/features/face-swap/domain/types/face-swap.types.ts +0 -9
- package/src/features/face-swap/domain/types/index.ts +0 -1
- package/src/features/face-swap/index.ts +0 -5
- package/src/features/face-swap/presentation/components/FaceSwapFeature.tsx +0 -3
- package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +9 -28
- package/src/features/hd-touch-up/domain/types/hd-touch-up.types.ts +0 -8
- package/src/features/hd-touch-up/domain/types/index.ts +0 -1
- package/src/features/hd-touch-up/index.ts +0 -5
- package/src/features/hd-touch-up/presentation/components/HDTouchUpFeature.tsx +0 -3
- package/src/features/hd-touch-up/presentation/hooks/useHDTouchUpFeature.ts +9 -26
- package/src/features/photo-restoration/domain/types/index.ts +0 -1
- package/src/features/photo-restoration/domain/types/photo-restore.types.ts +0 -8
- package/src/features/photo-restoration/index.ts +0 -5
- package/src/features/photo-restoration/presentation/components/PhotoRestoreFeature.tsx +0 -4
- package/src/features/photo-restoration/presentation/hooks/usePhotoRestoreFeature.ts +9 -26
- package/src/features/remove-background/domain/types/index.ts +0 -1
- package/src/features/remove-background/domain/types/remove-background.types.ts +0 -8
- package/src/features/remove-background/index.ts +0 -5
- package/src/features/remove-background/presentation/components/RemoveBackgroundFeature.tsx +0 -3
- package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +9 -26
- package/src/features/remove-object/domain/types/index.ts +0 -1
- package/src/features/remove-object/domain/types/remove-object.types.ts +0 -8
- package/src/features/remove-object/index.ts +0 -5
- package/src/features/remove-object/presentation/components/RemoveObjectFeature.tsx +0 -3
- package/src/features/remove-object/presentation/hooks/useRemoveObjectFeature.ts +9 -24
- package/src/features/replace-background/domain/types/index.ts +0 -1
- package/src/features/replace-background/domain/types/replace-background.types.ts +0 -9
- package/src/features/replace-background/index.ts +55 -82
- package/src/features/replace-background/infrastructure/constants/prompts.constants.ts +6 -6
- package/src/features/replace-background/infrastructure/index.ts +2 -2
- package/src/features/replace-background/presentation/components/ReplaceBackgroundFeature.tsx +0 -3
- package/src/features/replace-background/presentation/hooks/useReplaceBackgroundFeature.ts +8 -23
- package/src/features/upscaling/domain/types/upscale.types.ts +0 -8
- package/src/features/upscaling/index.ts +0 -5
- package/src/features/upscaling/presentation/components/UpscaleFeature.tsx +0 -4
- package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +8 -23
- package/src/index.ts +4 -0
- package/src/infrastructure/services/image-feature-executor.service.ts +143 -0
- package/src/infrastructure/services/index.ts +20 -0
- package/src/infrastructure/services/video-feature-executor.service.ts +140 -0
- package/src/features/ai-hug/infrastructure/index.ts +0 -5
- package/src/features/ai-hug/infrastructure/services/ai-hug-executor.ts +0 -96
- package/src/features/ai-hug/infrastructure/services/index.ts +0 -6
- package/src/features/ai-kiss/infrastructure/index.ts +0 -5
- package/src/features/ai-kiss/infrastructure/services/ai-kiss-executor.ts +0 -96
- package/src/features/ai-kiss/infrastructure/services/index.ts +0 -6
- package/src/features/anime-selfie/infrastructure/index.ts +0 -5
- package/src/features/anime-selfie/infrastructure/services/anime-selfie-executor.ts +0 -95
- package/src/features/anime-selfie/infrastructure/services/index.ts +0 -6
- package/src/features/face-swap/infrastructure/index.ts +0 -5
- package/src/features/face-swap/infrastructure/services/face-swap-executor.ts +0 -96
- package/src/features/face-swap/infrastructure/services/index.ts +0 -6
- package/src/features/hd-touch-up/infrastructure/index.ts +0 -1
- package/src/features/hd-touch-up/infrastructure/services/hd-touch-up-executor.ts +0 -97
- package/src/features/hd-touch-up/infrastructure/services/index.ts +0 -2
- package/src/features/photo-restoration/infrastructure/index.ts +0 -1
- package/src/features/photo-restoration/infrastructure/services/index.ts +0 -2
- package/src/features/photo-restoration/infrastructure/services/photo-restore-executor.ts +0 -98
- package/src/features/remove-background/infrastructure/index.ts +0 -5
- package/src/features/remove-background/infrastructure/services/index.ts +0 -6
- package/src/features/remove-background/infrastructure/services/remove-background-executor.ts +0 -95
- package/src/features/remove-object/infrastructure/index.ts +0 -5
- package/src/features/remove-object/infrastructure/services/index.ts +0 -6
- package/src/features/remove-object/infrastructure/services/remove-object-executor.ts +0 -99
- package/src/features/replace-background/infrastructure/services/index.ts +0 -6
- package/src/features/replace-background/infrastructure/services/replace-background-executor.ts +0 -95
- package/src/features/upscaling/infrastructure/index.ts +0 -1
- package/src/features/upscaling/infrastructure/services/index.ts +0 -2
- package/src/features/upscaling/infrastructure/services/upscale-executor.ts +0 -98
|
@@ -50,19 +50,11 @@ export interface AnimeSelfieTranslations {
|
|
|
50
50
|
compareHint?: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export type AnimeSelfieInputBuilder = (
|
|
54
|
-
base64: string,
|
|
55
|
-
options?: AnimeSelfieOptions,
|
|
56
|
-
) => Record<string, unknown>;
|
|
57
|
-
|
|
58
53
|
export type AnimeSelfieResultExtractor = (result: unknown) => string | undefined;
|
|
59
54
|
|
|
60
55
|
export interface AnimeSelfieFeatureConfig {
|
|
61
|
-
providerId?: string;
|
|
62
56
|
creditCost?: number;
|
|
63
57
|
defaultStyle?: AnimeSelfieStyle;
|
|
64
|
-
model: string;
|
|
65
|
-
buildInput: AnimeSelfieInputBuilder;
|
|
66
58
|
extractResult?: AnimeSelfieResultExtractor;
|
|
67
59
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
68
60
|
onImageSelect?: (uri: string) => void;
|
|
@@ -12,14 +12,9 @@ export type {
|
|
|
12
12
|
AnimeSelfieFeatureState,
|
|
13
13
|
AnimeSelfieTranslations,
|
|
14
14
|
AnimeSelfieFeatureConfig,
|
|
15
|
-
AnimeSelfieInputBuilder,
|
|
16
15
|
AnimeSelfieResultExtractor,
|
|
17
16
|
} from "./domain";
|
|
18
17
|
|
|
19
|
-
// Infrastructure Services
|
|
20
|
-
export { executeAnimeSelfie, hasAnimeSelfieSupport } from "./infrastructure";
|
|
21
|
-
export type { ExecuteAnimeSelfieOptions } from "./infrastructure";
|
|
22
|
-
|
|
23
18
|
// Presentation Hooks
|
|
24
19
|
export { useAnimeSelfieFeature } from "./presentation";
|
|
25
20
|
export type {
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
|
|
22
22
|
export interface AnimeSelfieFeatureProps {
|
|
23
23
|
config: AnimeSelfieFeatureConfig;
|
|
24
|
-
userId: string;
|
|
25
24
|
translations: AnimeSelfieTranslations;
|
|
26
25
|
onSelectImage: () => Promise<string | null>;
|
|
27
26
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
@@ -33,7 +32,6 @@ export interface AnimeSelfieFeatureProps {
|
|
|
33
32
|
|
|
34
33
|
export const AnimeSelfieFeature: React.FC<AnimeSelfieFeatureProps> = ({
|
|
35
34
|
config,
|
|
36
|
-
userId,
|
|
37
35
|
translations,
|
|
38
36
|
onSelectImage,
|
|
39
37
|
onSaveImage,
|
|
@@ -43,7 +41,6 @@ export const AnimeSelfieFeature: React.FC<AnimeSelfieFeatureProps> = ({
|
|
|
43
41
|
|
|
44
42
|
const feature = useAnimeSelfieFeature({
|
|
45
43
|
config,
|
|
46
|
-
userId,
|
|
47
44
|
onSelectImage,
|
|
48
45
|
onSaveImage,
|
|
49
46
|
});
|
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
8
8
|
import type {
|
|
9
9
|
AnimeSelfieFeatureState,
|
|
10
10
|
AnimeSelfieFeatureConfig,
|
|
11
11
|
AnimeSelfieResult,
|
|
12
12
|
} from "../../domain/types";
|
|
13
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
|
-
|
|
16
14
|
export interface UseAnimeSelfieFeatureProps {
|
|
17
15
|
config: AnimeSelfieFeatureConfig;
|
|
18
|
-
userId: string;
|
|
19
16
|
onSelectImage: () => Promise<string | null>;
|
|
20
17
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
21
18
|
}
|
|
@@ -38,7 +35,7 @@ const initialState: AnimeSelfieFeatureState = {
|
|
|
38
35
|
export function useAnimeSelfieFeature(
|
|
39
36
|
props: UseAnimeSelfieFeatureProps,
|
|
40
37
|
): UseAnimeSelfieFeatureReturn {
|
|
41
|
-
const { config,
|
|
38
|
+
const { config, onSelectImage, onSaveImage } = props;
|
|
42
39
|
const [state, setState] = useState<AnimeSelfieFeatureState>(initialState);
|
|
43
40
|
|
|
44
41
|
const selectImage = useCallback(async () => {
|
|
@@ -70,37 +67,22 @@ export function useAnimeSelfieFeature(
|
|
|
70
67
|
|
|
71
68
|
config.onProcessingStart?.();
|
|
72
69
|
|
|
73
|
-
if (__DEV__) {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.log("[useAnimeSelfieFeature] Starting anime selfie process");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
79
71
|
|
|
80
|
-
const result
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
userId,
|
|
85
|
-
options: { style: config.defaultStyle },
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
model: config.model,
|
|
89
|
-
buildInput: config.buildInput,
|
|
90
|
-
extractResult: config.extractResult,
|
|
91
|
-
onProgress: handleProgress,
|
|
92
|
-
},
|
|
72
|
+
const result = await executeImageFeature(
|
|
73
|
+
"anime-selfie",
|
|
74
|
+
{ imageBase64, options: { style: config.defaultStyle } },
|
|
75
|
+
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
93
76
|
);
|
|
94
77
|
|
|
95
78
|
if (result.success && result.imageUrl) {
|
|
96
|
-
const url = result.imageUrl;
|
|
97
79
|
setState((prev) => ({
|
|
98
80
|
...prev,
|
|
99
81
|
isProcessing: false,
|
|
100
|
-
processedUrl:
|
|
82
|
+
processedUrl: result.imageUrl!,
|
|
101
83
|
progress: 100,
|
|
102
84
|
}));
|
|
103
|
-
config.onProcessingComplete?.(result);
|
|
85
|
+
config.onProcessingComplete?.(result as AnimeSelfieResult);
|
|
104
86
|
} else {
|
|
105
87
|
const errorMessage = result.error || "Processing failed";
|
|
106
88
|
setState((prev) => ({
|
|
@@ -111,7 +93,7 @@ export function useAnimeSelfieFeature(
|
|
|
111
93
|
}));
|
|
112
94
|
config.onError?.(errorMessage);
|
|
113
95
|
}
|
|
114
|
-
}, [state.imageUri,
|
|
96
|
+
}, [state.imageUri, config, handleProgress]);
|
|
115
97
|
|
|
116
98
|
const save = useCallback(async () => {
|
|
117
99
|
if (!state.processedUrl) return;
|
|
@@ -49,19 +49,10 @@ export interface FaceSwapTranslations {
|
|
|
49
49
|
tryAnotherText: string;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export type FaceSwapInputBuilder = (
|
|
53
|
-
sourceBase64: string,
|
|
54
|
-
targetBase64: string,
|
|
55
|
-
options?: FaceSwapOptions,
|
|
56
|
-
) => Record<string, unknown>;
|
|
57
|
-
|
|
58
52
|
export type FaceSwapResultExtractor = (result: unknown) => string | undefined;
|
|
59
53
|
|
|
60
54
|
export interface FaceSwapFeatureConfig {
|
|
61
|
-
providerId?: string;
|
|
62
55
|
creditCost?: number;
|
|
63
|
-
model: string;
|
|
64
|
-
buildInput: FaceSwapInputBuilder;
|
|
65
56
|
extractResult?: FaceSwapResultExtractor;
|
|
66
57
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
67
58
|
onSourceImageSelect?: (uri: string) => void;
|
|
@@ -11,14 +11,9 @@ export type {
|
|
|
11
11
|
FaceSwapFeatureState,
|
|
12
12
|
FaceSwapTranslations,
|
|
13
13
|
FaceSwapFeatureConfig,
|
|
14
|
-
FaceSwapInputBuilder,
|
|
15
14
|
FaceSwapResultExtractor,
|
|
16
15
|
} from "./domain";
|
|
17
16
|
|
|
18
|
-
// Infrastructure Services
|
|
19
|
-
export { executeFaceSwap, hasFaceSwapSupport } from "./infrastructure";
|
|
20
|
-
export type { ExecuteFaceSwapOptions } from "./infrastructure";
|
|
21
|
-
|
|
22
17
|
// Presentation Hooks
|
|
23
18
|
export { useFaceSwapFeature } from "./presentation";
|
|
24
19
|
export type {
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
|
|
22
22
|
export interface FaceSwapFeatureProps {
|
|
23
23
|
config: FaceSwapFeatureConfig;
|
|
24
|
-
userId: string;
|
|
25
24
|
translations: FaceSwapTranslations;
|
|
26
25
|
onSelectSourceImage: () => Promise<string | null>;
|
|
27
26
|
onSelectTargetImage: () => Promise<string | null>;
|
|
@@ -34,7 +33,6 @@ export interface FaceSwapFeatureProps {
|
|
|
34
33
|
|
|
35
34
|
export const FaceSwapFeature: React.FC<FaceSwapFeatureProps> = ({
|
|
36
35
|
config,
|
|
37
|
-
userId,
|
|
38
36
|
translations,
|
|
39
37
|
onSelectSourceImage,
|
|
40
38
|
onSelectTargetImage,
|
|
@@ -45,7 +43,6 @@ export const FaceSwapFeature: React.FC<FaceSwapFeatureProps> = ({
|
|
|
45
43
|
|
|
46
44
|
const feature = useFaceSwapFeature({
|
|
47
45
|
config,
|
|
48
|
-
userId,
|
|
49
46
|
onSelectSourceImage,
|
|
50
47
|
onSelectTargetImage,
|
|
51
48
|
onSaveImage,
|
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
8
8
|
import type {
|
|
9
9
|
FaceSwapFeatureState,
|
|
10
10
|
FaceSwapFeatureConfig,
|
|
11
11
|
FaceSwapResult,
|
|
12
12
|
} from "../../domain/types";
|
|
13
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
|
-
|
|
16
14
|
export interface UseFaceSwapFeatureProps {
|
|
17
15
|
config: FaceSwapFeatureConfig;
|
|
18
|
-
userId: string;
|
|
19
16
|
onSelectSourceImage: () => Promise<string | null>;
|
|
20
17
|
onSelectTargetImage: () => Promise<string | null>;
|
|
21
18
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
@@ -41,7 +38,7 @@ const initialState: FaceSwapFeatureState = {
|
|
|
41
38
|
export function useFaceSwapFeature(
|
|
42
39
|
props: UseFaceSwapFeatureProps,
|
|
43
40
|
): UseFaceSwapFeatureReturn {
|
|
44
|
-
const { config,
|
|
41
|
+
const { config, onSelectSourceImage, onSelectTargetImage, onSaveImage } = props;
|
|
45
42
|
const [state, setState] = useState<FaceSwapFeatureState>(initialState);
|
|
46
43
|
|
|
47
44
|
const selectSourceImage = useCallback(async () => {
|
|
@@ -86,39 +83,23 @@ export function useFaceSwapFeature(
|
|
|
86
83
|
|
|
87
84
|
config.onProcessingStart?.();
|
|
88
85
|
|
|
89
|
-
if (__DEV__) {
|
|
90
|
-
// eslint-disable-next-line no-console
|
|
91
|
-
console.log("[useFaceSwapFeature] Starting face swap process");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
86
|
const sourceImageBase64 = await config.prepareImage(state.sourceImageUri);
|
|
95
87
|
const targetImageBase64 = await config.prepareImage(state.targetImageUri);
|
|
96
88
|
|
|
97
|
-
const result
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
sourceImageBase64,
|
|
102
|
-
targetImageBase64,
|
|
103
|
-
userId,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
model: config.model,
|
|
107
|
-
buildInput: config.buildInput,
|
|
108
|
-
extractResult: config.extractResult,
|
|
109
|
-
onProgress: handleProgress,
|
|
110
|
-
},
|
|
89
|
+
const result = await executeImageFeature(
|
|
90
|
+
"face-swap",
|
|
91
|
+
{ imageBase64: sourceImageBase64, targetImageBase64 },
|
|
92
|
+
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
111
93
|
);
|
|
112
94
|
|
|
113
95
|
if (result.success && result.imageUrl) {
|
|
114
|
-
const url = result.imageUrl;
|
|
115
96
|
setState((prev) => ({
|
|
116
97
|
...prev,
|
|
117
98
|
isProcessing: false,
|
|
118
|
-
processedUrl:
|
|
99
|
+
processedUrl: result.imageUrl!,
|
|
119
100
|
progress: 100,
|
|
120
101
|
}));
|
|
121
|
-
config.onProcessingComplete?.(result);
|
|
102
|
+
config.onProcessingComplete?.(result as FaceSwapResult);
|
|
122
103
|
} else {
|
|
123
104
|
const errorMessage = result.error || "Processing failed";
|
|
124
105
|
setState((prev) => ({
|
|
@@ -129,7 +110,7 @@ export function useFaceSwapFeature(
|
|
|
129
110
|
}));
|
|
130
111
|
config.onError?.(errorMessage);
|
|
131
112
|
}
|
|
132
|
-
}, [state.sourceImageUri, state.targetImageUri,
|
|
113
|
+
}, [state.sourceImageUri, state.targetImageUri, config, handleProgress]);
|
|
133
114
|
|
|
134
115
|
const save = useCallback(async () => {
|
|
135
116
|
if (!state.processedUrl) return;
|
|
@@ -48,18 +48,10 @@ export interface HDTouchUpTranslations {
|
|
|
48
48
|
compareHint?: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export type HDTouchUpInputBuilder = (
|
|
52
|
-
base64: string,
|
|
53
|
-
options?: HDTouchUpOptions,
|
|
54
|
-
) => Record<string, unknown>;
|
|
55
|
-
|
|
56
51
|
export type HDTouchUpResultExtractor = (result: unknown) => string | undefined;
|
|
57
52
|
|
|
58
53
|
export interface HDTouchUpFeatureConfig {
|
|
59
|
-
providerId?: string;
|
|
60
54
|
creditCost?: number;
|
|
61
|
-
model: string;
|
|
62
|
-
buildInput: HDTouchUpInputBuilder;
|
|
63
55
|
extractResult?: HDTouchUpResultExtractor;
|
|
64
56
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
65
57
|
onImageSelect?: (uri: string) => void;
|
|
@@ -11,14 +11,9 @@ export type {
|
|
|
11
11
|
HDTouchUpFeatureState,
|
|
12
12
|
HDTouchUpTranslations,
|
|
13
13
|
HDTouchUpFeatureConfig,
|
|
14
|
-
HDTouchUpInputBuilder,
|
|
15
14
|
HDTouchUpResultExtractor,
|
|
16
15
|
} from "./domain";
|
|
17
16
|
|
|
18
|
-
// Infrastructure Services
|
|
19
|
-
export { executeHDTouchUp, hasHDTouchUpSupport } from "./infrastructure";
|
|
20
|
-
export type { ExecuteHDTouchUpOptions } from "./infrastructure";
|
|
21
|
-
|
|
22
17
|
// Presentation Hooks
|
|
23
18
|
export { useHDTouchUpFeature } from "./presentation";
|
|
24
19
|
export type {
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
|
|
22
22
|
export interface HDTouchUpFeatureProps {
|
|
23
23
|
config: HDTouchUpFeatureConfig;
|
|
24
|
-
userId: string;
|
|
25
24
|
translations: HDTouchUpTranslations;
|
|
26
25
|
onSelectImage: () => Promise<string | null>;
|
|
27
26
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
@@ -33,7 +32,6 @@ export interface HDTouchUpFeatureProps {
|
|
|
33
32
|
|
|
34
33
|
export const HDTouchUpFeature: React.FC<HDTouchUpFeatureProps> = ({
|
|
35
34
|
config,
|
|
36
|
-
userId,
|
|
37
35
|
translations,
|
|
38
36
|
onSelectImage,
|
|
39
37
|
onSaveImage,
|
|
@@ -43,7 +41,6 @@ export const HDTouchUpFeature: React.FC<HDTouchUpFeatureProps> = ({
|
|
|
43
41
|
|
|
44
42
|
const feature = useHDTouchUpFeature({
|
|
45
43
|
config,
|
|
46
|
-
userId,
|
|
47
44
|
onSelectImage,
|
|
48
45
|
onSaveImage,
|
|
49
46
|
});
|
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
8
8
|
import type {
|
|
9
9
|
HDTouchUpFeatureState,
|
|
10
10
|
HDTouchUpFeatureConfig,
|
|
11
11
|
HDTouchUpResult,
|
|
12
12
|
} from "../../domain/types";
|
|
13
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
|
-
|
|
16
14
|
export interface UseHDTouchUpFeatureProps {
|
|
17
15
|
config: HDTouchUpFeatureConfig;
|
|
18
|
-
userId: string;
|
|
19
16
|
onSelectImage: () => Promise<string | null>;
|
|
20
17
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
21
18
|
}
|
|
@@ -38,7 +35,7 @@ const initialState: HDTouchUpFeatureState = {
|
|
|
38
35
|
export function useHDTouchUpFeature(
|
|
39
36
|
props: UseHDTouchUpFeatureProps,
|
|
40
37
|
): UseHDTouchUpFeatureReturn {
|
|
41
|
-
const { config,
|
|
38
|
+
const { config, onSelectImage, onSaveImage } = props;
|
|
42
39
|
const [state, setState] = useState<HDTouchUpFeatureState>(initialState);
|
|
43
40
|
|
|
44
41
|
const selectImage = useCallback(async () => {
|
|
@@ -70,36 +67,22 @@ export function useHDTouchUpFeature(
|
|
|
70
67
|
|
|
71
68
|
config.onProcessingStart?.();
|
|
72
69
|
|
|
73
|
-
if (__DEV__) {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.log("[useHDTouchUpFeature] Starting HD enhancement");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
79
71
|
|
|
80
|
-
const result
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
userId,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
model: config.model,
|
|
88
|
-
buildInput: config.buildInput,
|
|
89
|
-
extractResult: config.extractResult,
|
|
90
|
-
onProgress: handleProgress,
|
|
91
|
-
},
|
|
72
|
+
const result = await executeImageFeature(
|
|
73
|
+
"hd-touch-up",
|
|
74
|
+
{ imageBase64 },
|
|
75
|
+
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
92
76
|
);
|
|
93
77
|
|
|
94
78
|
if (result.success && result.imageUrl) {
|
|
95
|
-
const url = result.imageUrl;
|
|
96
79
|
setState((prev) => ({
|
|
97
80
|
...prev,
|
|
98
81
|
isProcessing: false,
|
|
99
|
-
processedUrl:
|
|
82
|
+
processedUrl: result.imageUrl!,
|
|
100
83
|
progress: 100,
|
|
101
84
|
}));
|
|
102
|
-
config.onProcessingComplete?.(result);
|
|
85
|
+
config.onProcessingComplete?.(result as HDTouchUpResult);
|
|
103
86
|
} else {
|
|
104
87
|
const errorMessage = result.error || "Processing failed";
|
|
105
88
|
setState((prev) => ({
|
|
@@ -110,7 +93,7 @@ export function useHDTouchUpFeature(
|
|
|
110
93
|
}));
|
|
111
94
|
config.onError?.(errorMessage);
|
|
112
95
|
}
|
|
113
|
-
}, [state.imageUri,
|
|
96
|
+
}, [state.imageUri, config, handleProgress]);
|
|
114
97
|
|
|
115
98
|
const save = useCallback(async () => {
|
|
116
99
|
if (!state.processedUrl) return;
|
|
@@ -48,20 +48,12 @@ export interface PhotoRestoreTranslations {
|
|
|
48
48
|
compareHint?: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export type PhotoRestoreInputBuilder = (
|
|
52
|
-
base64: string,
|
|
53
|
-
options?: PhotoRestoreOptions,
|
|
54
|
-
) => Record<string, unknown>;
|
|
55
|
-
|
|
56
51
|
export type PhotoRestoreResultExtractor = (
|
|
57
52
|
result: unknown,
|
|
58
53
|
) => string | undefined;
|
|
59
54
|
|
|
60
55
|
export interface PhotoRestoreFeatureConfig {
|
|
61
|
-
providerId?: string;
|
|
62
56
|
creditCost?: number;
|
|
63
|
-
model: string;
|
|
64
|
-
buildInput: PhotoRestoreInputBuilder;
|
|
65
57
|
extractResult?: PhotoRestoreResultExtractor;
|
|
66
58
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
67
59
|
onImageSelect?: (uri: string) => void;
|
|
@@ -11,14 +11,9 @@ export type {
|
|
|
11
11
|
PhotoRestoreFeatureState,
|
|
12
12
|
PhotoRestoreTranslations,
|
|
13
13
|
PhotoRestoreFeatureConfig,
|
|
14
|
-
PhotoRestoreInputBuilder,
|
|
15
14
|
PhotoRestoreResultExtractor,
|
|
16
15
|
} from "./domain";
|
|
17
16
|
|
|
18
|
-
// Infrastructure Services
|
|
19
|
-
export { executePhotoRestore, hasPhotoRestoreSupport } from "./infrastructure";
|
|
20
|
-
export type { ExecutePhotoRestoreOptions } from "./infrastructure";
|
|
21
|
-
|
|
22
17
|
// Presentation Hooks
|
|
23
18
|
export { usePhotoRestoreFeature } from "./presentation";
|
|
24
19
|
export type {
|
|
@@ -22,8 +22,6 @@ import type {
|
|
|
22
22
|
export interface PhotoRestoreFeatureProps {
|
|
23
23
|
/** Feature configuration with provider-specific settings */
|
|
24
24
|
config: PhotoRestoreFeatureConfig;
|
|
25
|
-
/** User ID for the generation request */
|
|
26
|
-
userId: string;
|
|
27
25
|
/** Translations for all UI text */
|
|
28
26
|
translations: PhotoRestoreTranslations;
|
|
29
27
|
/** Image picker callback */
|
|
@@ -39,7 +37,6 @@ export interface PhotoRestoreFeatureProps {
|
|
|
39
37
|
|
|
40
38
|
export const PhotoRestoreFeature: React.FC<PhotoRestoreFeatureProps> = ({
|
|
41
39
|
config,
|
|
42
|
-
userId,
|
|
43
40
|
translations,
|
|
44
41
|
onSelectImage,
|
|
45
42
|
onSaveImage,
|
|
@@ -49,7 +46,6 @@ export const PhotoRestoreFeature: React.FC<PhotoRestoreFeatureProps> = ({
|
|
|
49
46
|
|
|
50
47
|
const feature = usePhotoRestoreFeature({
|
|
51
48
|
config,
|
|
52
|
-
userId,
|
|
53
49
|
onSelectImage,
|
|
54
50
|
onSaveImage,
|
|
55
51
|
});
|
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
8
8
|
import type {
|
|
9
9
|
PhotoRestoreFeatureState,
|
|
10
10
|
PhotoRestoreFeatureConfig,
|
|
11
11
|
PhotoRestoreResult,
|
|
12
12
|
} from "../../domain/types";
|
|
13
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
|
-
|
|
16
14
|
export interface UsePhotoRestoreFeatureProps {
|
|
17
15
|
config: PhotoRestoreFeatureConfig;
|
|
18
|
-
userId: string;
|
|
19
16
|
onSelectImage: () => Promise<string | null>;
|
|
20
17
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
21
18
|
}
|
|
@@ -38,7 +35,7 @@ const initialState: PhotoRestoreFeatureState = {
|
|
|
38
35
|
export function usePhotoRestoreFeature(
|
|
39
36
|
props: UsePhotoRestoreFeatureProps,
|
|
40
37
|
): UsePhotoRestoreFeatureReturn {
|
|
41
|
-
const { config,
|
|
38
|
+
const { config, onSelectImage, onSaveImage } = props;
|
|
42
39
|
const [state, setState] = useState<PhotoRestoreFeatureState>(initialState);
|
|
43
40
|
|
|
44
41
|
const selectImage = useCallback(async () => {
|
|
@@ -70,36 +67,22 @@ export function usePhotoRestoreFeature(
|
|
|
70
67
|
|
|
71
68
|
config.onProcessingStart?.();
|
|
72
69
|
|
|
73
|
-
if (__DEV__) {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.log("[usePhotoRestoreFeature] Starting photo restore process");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
79
71
|
|
|
80
|
-
const result
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
userId,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
model: config.model,
|
|
88
|
-
buildInput: config.buildInput,
|
|
89
|
-
extractResult: config.extractResult,
|
|
90
|
-
onProgress: handleProgress,
|
|
91
|
-
},
|
|
72
|
+
const result = await executeImageFeature(
|
|
73
|
+
"photo-restore",
|
|
74
|
+
{ imageBase64 },
|
|
75
|
+
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
92
76
|
);
|
|
93
77
|
|
|
94
78
|
if (result.success && result.imageUrl) {
|
|
95
|
-
const url = result.imageUrl;
|
|
96
79
|
setState((prev) => ({
|
|
97
80
|
...prev,
|
|
98
81
|
isProcessing: false,
|
|
99
|
-
processedUrl:
|
|
82
|
+
processedUrl: result.imageUrl!,
|
|
100
83
|
progress: 100,
|
|
101
84
|
}));
|
|
102
|
-
config.onProcessingComplete?.(result);
|
|
85
|
+
config.onProcessingComplete?.(result as PhotoRestoreResult);
|
|
103
86
|
} else {
|
|
104
87
|
const errorMessage = result.error || "Processing failed";
|
|
105
88
|
setState((prev) => ({
|
|
@@ -110,7 +93,7 @@ export function usePhotoRestoreFeature(
|
|
|
110
93
|
}));
|
|
111
94
|
config.onError?.(errorMessage);
|
|
112
95
|
}
|
|
113
|
-
}, [state.imageUri,
|
|
96
|
+
}, [state.imageUri, config, handleProgress]);
|
|
114
97
|
|
|
115
98
|
const save = useCallback(async () => {
|
|
116
99
|
if (!state.processedUrl) return;
|
|
@@ -48,18 +48,10 @@ export interface RemoveBackgroundTranslations {
|
|
|
48
48
|
compareHint?: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export type RemoveBackgroundInputBuilder = (
|
|
52
|
-
base64: string,
|
|
53
|
-
options?: RemoveBackgroundOptions,
|
|
54
|
-
) => Record<string, unknown>;
|
|
55
|
-
|
|
56
51
|
export type RemoveBackgroundResultExtractor = (result: unknown) => string | undefined;
|
|
57
52
|
|
|
58
53
|
export interface RemoveBackgroundFeatureConfig {
|
|
59
|
-
providerId?: string;
|
|
60
54
|
creditCost?: number;
|
|
61
|
-
model: string;
|
|
62
|
-
buildInput: RemoveBackgroundInputBuilder;
|
|
63
55
|
extractResult?: RemoveBackgroundResultExtractor;
|
|
64
56
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
65
57
|
onImageSelect?: (uri: string) => void;
|
|
@@ -11,14 +11,9 @@ export type {
|
|
|
11
11
|
RemoveBackgroundFeatureState,
|
|
12
12
|
RemoveBackgroundTranslations,
|
|
13
13
|
RemoveBackgroundFeatureConfig,
|
|
14
|
-
RemoveBackgroundInputBuilder,
|
|
15
14
|
RemoveBackgroundResultExtractor,
|
|
16
15
|
} from "./domain";
|
|
17
16
|
|
|
18
|
-
// Infrastructure Services
|
|
19
|
-
export { executeRemoveBackground, hasRemoveBackgroundSupport } from "./infrastructure";
|
|
20
|
-
export type { ExecuteRemoveBackgroundOptions } from "./infrastructure";
|
|
21
|
-
|
|
22
17
|
// Presentation Hooks
|
|
23
18
|
export { useRemoveBackgroundFeature } from "./presentation";
|
|
24
19
|
export type {
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
|
|
22
22
|
export interface RemoveBackgroundFeatureProps {
|
|
23
23
|
config: RemoveBackgroundFeatureConfig;
|
|
24
|
-
userId: string;
|
|
25
24
|
translations: RemoveBackgroundTranslations;
|
|
26
25
|
onSelectImage: () => Promise<string | null>;
|
|
27
26
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
@@ -33,7 +32,6 @@ export interface RemoveBackgroundFeatureProps {
|
|
|
33
32
|
|
|
34
33
|
export const RemoveBackgroundFeature: React.FC<RemoveBackgroundFeatureProps> = ({
|
|
35
34
|
config,
|
|
36
|
-
userId,
|
|
37
35
|
translations,
|
|
38
36
|
onSelectImage,
|
|
39
37
|
onSaveImage,
|
|
@@ -43,7 +41,6 @@ export const RemoveBackgroundFeature: React.FC<RemoveBackgroundFeatureProps> = (
|
|
|
43
41
|
|
|
44
42
|
const feature = useRemoveBackgroundFeature({
|
|
45
43
|
config,
|
|
46
|
-
userId,
|
|
47
44
|
onSelectImage,
|
|
48
45
|
onSaveImage,
|
|
49
46
|
});
|