@umituz/react-native-ai-generation-content 1.17.146 → 1.17.148

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.
Files changed (72) hide show
  1. package/package.json +1 -1
  2. package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +3 -3
  3. package/src/domains/creations/index.ts +1 -1
  4. package/src/domains/creations/infrastructure/repositories/CreationsFetcher.ts +6 -6
  5. package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +5 -5
  6. package/src/domains/creations/infrastructure/repositories/CreationsWriter.ts +5 -5
  7. package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +1 -1
  8. package/src/domains/creations/presentation/components/GalleryHeader.tsx +1 -1
  9. package/src/domains/creations/presentation/hooks/advancedFilter.types.ts +38 -0
  10. package/src/domains/creations/presentation/hooks/filterHelpers.ts +145 -0
  11. package/src/domains/creations/presentation/hooks/index.ts +5 -0
  12. package/src/domains/creations/presentation/hooks/useAdvancedFilter.ts +34 -184
  13. package/src/domains/flashcard-generation/parsers/flashcard-response.parser.ts +1 -1
  14. package/src/features/face-swap/domain/types/face-swap.types.ts +13 -41
  15. package/src/features/face-swap/domain/types/index.ts +0 -1
  16. package/src/features/face-swap/index.ts +1 -5
  17. package/src/features/face-swap/presentation/hooks/index.ts +1 -4
  18. package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +17 -121
  19. package/src/features/image-to-image/domain/index.ts +1 -0
  20. package/src/features/image-to-image/domain/types/base.types.ts +189 -0
  21. package/src/features/image-to-image/domain/types/index.ts +1 -0
  22. package/src/features/image-to-image/index.ts +2 -0
  23. package/src/features/image-to-image/presentation/hooks/index.ts +3 -0
  24. package/src/features/image-to-image/presentation/hooks/useDualImageFeature.ts +154 -0
  25. package/src/features/image-to-image/presentation/hooks/useImageWithPromptFeature.ts +180 -0
  26. package/src/features/image-to-image/presentation/hooks/useSingleImageFeature.ts +132 -0
  27. package/src/features/image-to-image/presentation/index.ts +1 -0
  28. package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +10 -10
  29. package/src/features/image-to-video/presentation/hooks/useImageToVideoFeature.ts +8 -8
  30. package/src/features/image-to-video/presentation/hooks/useImageToVideoForm.ts +5 -5
  31. package/src/features/meme-generator/infrastructure/services/MemeGenerationService.ts +2 -2
  32. package/src/features/remove-background/domain/types/index.ts +0 -1
  33. package/src/features/remove-background/domain/types/remove-background.types.ts +14 -40
  34. package/src/features/remove-background/index.ts +1 -5
  35. package/src/features/remove-background/presentation/hooks/index.ts +1 -4
  36. package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +15 -100
  37. package/src/features/replace-background/domain/types/index.ts +1 -2
  38. package/src/features/replace-background/domain/types/replace-background.types.ts +14 -39
  39. package/src/features/replace-background/index.ts +0 -1
  40. package/src/features/replace-background/presentation/hooks/useReplaceBackgroundFeature.ts +30 -118
  41. package/src/features/script-generator/presentation/hooks/useScriptGenerator.ts +1 -1
  42. package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +2 -2
  43. package/src/features/text-to-image/presentation/hooks/useGeneration.ts +12 -12
  44. package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +9 -9
  45. package/src/features/text-to-video/presentation/hooks/textToVideoExecution.ts +134 -0
  46. package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +24 -118
  47. package/src/features/text-to-video/presentation/hooks/useTextToVideoForm.ts +1 -1
  48. package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +2 -2
  49. package/src/features/upscaling/domain/types/upscale.types.ts +12 -42
  50. package/src/features/upscaling/index.ts +1 -5
  51. package/src/features/upscaling/presentation/hooks/index.ts +1 -4
  52. package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +15 -106
  53. package/src/index.ts +7 -1
  54. package/src/infrastructure/config/app-services.config.ts +2 -2
  55. package/src/infrastructure/orchestration/GenerationOrchestrator.ts +23 -114
  56. package/src/infrastructure/orchestration/index.ts +3 -1
  57. package/src/infrastructure/orchestration/orchestrator.errors.ts +29 -0
  58. package/src/infrastructure/orchestration/orchestrator.types.ts +48 -0
  59. package/src/infrastructure/services/generation-orchestrator.service.ts +5 -5
  60. package/src/infrastructure/services/image-feature-executor.service.ts +2 -2
  61. package/src/infrastructure/services/job-poller.service.ts +1 -1
  62. package/src/infrastructure/services/job-poller.ts +3 -3
  63. package/src/infrastructure/services/provider-registry.service.ts +6 -6
  64. package/src/infrastructure/services/provider-validator.ts +4 -4
  65. package/src/infrastructure/services/video-feature-executor.service.ts +2 -2
  66. package/src/infrastructure/utils/error-classifier.util.ts +2 -2
  67. package/src/infrastructure/utils/feature-utils.ts +4 -4
  68. package/src/infrastructure/utils/result-validator.util.ts +1 -1
  69. package/src/infrastructure/utils/video-helpers.ts +3 -3
  70. package/src/presentation/components/AIGenerationForm.tsx +2 -2
  71. package/src/presentation/components/buttons/GenerateButton.tsx +3 -3
  72. package/src/presentation/hooks/useGenerationCallbacksBuilder.ts +1 -1
@@ -0,0 +1,180 @@
1
+ /**
2
+ * useImageWithPromptFeature Hook Factory
3
+ * Base hook for image + prompt processing features (e.g., replace-background)
4
+ */
5
+
6
+ import { useState, useCallback } from "react";
7
+ import { executeImageFeature } from "../../../../infrastructure/services";
8
+ import type {
9
+ BaseImageWithPromptState,
10
+ SingleImageConfig,
11
+ BaseImageResult,
12
+ } from "../../domain/types";
13
+
14
+ const INITIAL_STATE: BaseImageWithPromptState = {
15
+ imageUri: null,
16
+ prompt: "",
17
+ processedUrl: null,
18
+ isProcessing: false,
19
+ progress: 0,
20
+ error: null,
21
+ };
22
+
23
+ export interface ImageWithPromptConfig<TResult extends BaseImageResult = BaseImageResult>
24
+ extends SingleImageConfig<TResult> {
25
+ defaultPrompt?: string;
26
+ onPromptChange?: (prompt: string) => void;
27
+ }
28
+
29
+ export interface ImageWithPromptHookProps<
30
+ TConfig extends ImageWithPromptConfig = ImageWithPromptConfig,
31
+ > {
32
+ config: TConfig;
33
+ onSelectImage: () => Promise<string | null>;
34
+ onSaveImage: (imageUrl: string) => Promise<void>;
35
+ }
36
+
37
+ export interface ImageWithPromptHookReturn extends BaseImageWithPromptState {
38
+ selectImage: () => Promise<void>;
39
+ setPrompt: (prompt: string) => void;
40
+ process: () => Promise<void>;
41
+ save: () => Promise<void>;
42
+ reset: () => void;
43
+ }
44
+
45
+ export interface ImageWithPromptOptions {
46
+ buildInput?: (
47
+ imageBase64: string,
48
+ prompt: string,
49
+ config: ImageWithPromptConfig,
50
+ ) => Record<string, unknown>;
51
+ promptRequired?: boolean;
52
+ }
53
+
54
+ export function useImageWithPromptFeature<
55
+ TConfig extends ImageWithPromptConfig = ImageWithPromptConfig,
56
+ TResult extends BaseImageResult = BaseImageResult,
57
+ >(
58
+ props: ImageWithPromptHookProps<TConfig>,
59
+ options?: ImageWithPromptOptions,
60
+ ): ImageWithPromptHookReturn {
61
+ const { config, onSelectImage, onSaveImage } = props;
62
+ const [state, setState] = useState<BaseImageWithPromptState>({
63
+ ...INITIAL_STATE,
64
+ prompt: config.defaultPrompt || "",
65
+ });
66
+
67
+ const selectImage = useCallback(async () => {
68
+ try {
69
+ const uri = await onSelectImage();
70
+ if (uri) {
71
+ setState((prev) => ({ ...prev, imageUri: uri, error: null }));
72
+ config.onImageSelect?.(uri);
73
+ }
74
+ } catch (error) {
75
+ const message = error instanceof Error ? error.message : String(error);
76
+ setState((prev) => ({ ...prev, error: message }));
77
+ }
78
+ }, [onSelectImage, config]);
79
+
80
+ const setPrompt = useCallback(
81
+ (prompt: string) => {
82
+ setState((prev) => ({ ...prev, prompt, error: null }));
83
+ config.onPromptChange?.(prompt);
84
+ },
85
+ [config],
86
+ );
87
+
88
+ const handleProgress = useCallback((progress: number) => {
89
+ setState((prev) => ({ ...prev, progress }));
90
+ }, []);
91
+
92
+ const process = useCallback(async () => {
93
+ if (!state.imageUri) return;
94
+
95
+ if (options?.promptRequired && !state.prompt.trim()) {
96
+ const error = "Prompt is required";
97
+ setState((prev) => ({ ...prev, error }));
98
+ config.onError?.(error);
99
+ return;
100
+ }
101
+
102
+ setState((prev) => ({
103
+ ...prev,
104
+ isProcessing: true,
105
+ progress: 0,
106
+ error: null,
107
+ }));
108
+
109
+ config.onProcessingStart?.();
110
+
111
+ try {
112
+ const imageBase64 = await config.prepareImage(state.imageUri);
113
+
114
+ const input = options?.buildInput
115
+ ? options.buildInput(imageBase64, state.prompt, config)
116
+ : { imageBase64, prompt: state.prompt };
117
+
118
+ const result = await executeImageFeature(
119
+ config.featureType,
120
+ input,
121
+ { extractResult: config.extractResult, onProgress: handleProgress },
122
+ );
123
+
124
+ if (result.success && result.imageUrl) {
125
+ setState((prev) => ({
126
+ ...prev,
127
+ isProcessing: false,
128
+ processedUrl: result.imageUrl!,
129
+ progress: 100,
130
+ }));
131
+ config.onProcessingComplete?.(result as TResult);
132
+ } else {
133
+ const errorMessage = result.error || "Processing failed";
134
+ setState((prev) => ({
135
+ ...prev,
136
+ isProcessing: false,
137
+ error: errorMessage,
138
+ progress: 0,
139
+ }));
140
+ config.onError?.(errorMessage);
141
+ }
142
+ } catch (error) {
143
+ const message = error instanceof Error ? error.message : String(error);
144
+ setState((prev) => ({
145
+ ...prev,
146
+ isProcessing: false,
147
+ error: message,
148
+ progress: 0,
149
+ }));
150
+ config.onError?.(message);
151
+ }
152
+ }, [state.imageUri, state.prompt, config, options, handleProgress]);
153
+
154
+ const save = useCallback(async () => {
155
+ if (!state.processedUrl) return;
156
+
157
+ try {
158
+ await onSaveImage(state.processedUrl);
159
+ } catch (error) {
160
+ const message = error instanceof Error ? error.message : String(error);
161
+ setState((prev) => ({ ...prev, error: message }));
162
+ }
163
+ }, [state.processedUrl, onSaveImage]);
164
+
165
+ const reset = useCallback(() => {
166
+ setState({
167
+ ...INITIAL_STATE,
168
+ prompt: config.defaultPrompt || "",
169
+ });
170
+ }, [config.defaultPrompt]);
171
+
172
+ return {
173
+ ...state,
174
+ selectImage,
175
+ setPrompt,
176
+ process,
177
+ save,
178
+ reset,
179
+ };
180
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * useSingleImageFeature Hook Factory
3
+ * Base hook for single image processing features
4
+ */
5
+
6
+ import { useState, useCallback } from "react";
7
+ import { executeImageFeature } from "../../../../infrastructure/services";
8
+ import type {
9
+ BaseSingleImageState,
10
+ BaseSingleImageHookProps,
11
+ BaseSingleImageHookReturn,
12
+ SingleImageConfig,
13
+ BaseImageResult,
14
+ } from "../../domain/types";
15
+
16
+ const INITIAL_STATE: BaseSingleImageState = {
17
+ imageUri: null,
18
+ processedUrl: null,
19
+ isProcessing: false,
20
+ progress: 0,
21
+ error: null,
22
+ };
23
+
24
+ export interface SingleImageFeatureOptions<TConfig extends SingleImageConfig> {
25
+ buildInput?: (imageBase64: string, config: TConfig) => Record<string, unknown>;
26
+ }
27
+
28
+ export function useSingleImageFeature<
29
+ TConfig extends SingleImageConfig = SingleImageConfig,
30
+ TResult extends BaseImageResult = BaseImageResult,
31
+ >(
32
+ props: BaseSingleImageHookProps<TConfig>,
33
+ options?: SingleImageFeatureOptions<TConfig>,
34
+ ): BaseSingleImageHookReturn {
35
+ const { config, onSelectImage, onSaveImage } = props;
36
+ const [state, setState] = useState<BaseSingleImageState>(INITIAL_STATE);
37
+
38
+ const selectImage = useCallback(async () => {
39
+ try {
40
+ const uri = await onSelectImage();
41
+ if (uri) {
42
+ setState((prev) => ({ ...prev, imageUri: uri, error: null }));
43
+ config.onImageSelect?.(uri);
44
+ }
45
+ } catch (error) {
46
+ const message = error instanceof Error ? error.message : String(error);
47
+ setState((prev) => ({ ...prev, error: message }));
48
+ }
49
+ }, [onSelectImage, config]);
50
+
51
+ const handleProgress = useCallback((progress: number) => {
52
+ setState((prev) => ({ ...prev, progress }));
53
+ }, []);
54
+
55
+ const process = useCallback(async () => {
56
+ if (!state.imageUri) return;
57
+
58
+ setState((prev) => ({
59
+ ...prev,
60
+ isProcessing: true,
61
+ progress: 0,
62
+ error: null,
63
+ }));
64
+
65
+ config.onProcessingStart?.();
66
+
67
+ try {
68
+ const imageBase64 = await config.prepareImage(state.imageUri);
69
+
70
+ const input = options?.buildInput
71
+ ? options.buildInput(imageBase64, config)
72
+ : { imageBase64 };
73
+
74
+ const result = await executeImageFeature(
75
+ config.featureType,
76
+ input,
77
+ { extractResult: config.extractResult, onProgress: handleProgress },
78
+ );
79
+
80
+ if (result.success && result.imageUrl) {
81
+ setState((prev) => ({
82
+ ...prev,
83
+ isProcessing: false,
84
+ processedUrl: result.imageUrl!,
85
+ progress: 100,
86
+ }));
87
+ config.onProcessingComplete?.(result as TResult);
88
+ } else {
89
+ const errorMessage = result.error || "Processing failed";
90
+ setState((prev) => ({
91
+ ...prev,
92
+ isProcessing: false,
93
+ error: errorMessage,
94
+ progress: 0,
95
+ }));
96
+ config.onError?.(errorMessage);
97
+ }
98
+ } catch (error) {
99
+ const message = error instanceof Error ? error.message : String(error);
100
+ setState((prev) => ({
101
+ ...prev,
102
+ isProcessing: false,
103
+ error: message,
104
+ progress: 0,
105
+ }));
106
+ config.onError?.(message);
107
+ }
108
+ }, [state.imageUri, config, options, handleProgress]);
109
+
110
+ const save = useCallback(async () => {
111
+ if (!state.processedUrl) return;
112
+
113
+ try {
114
+ await onSaveImage(state.processedUrl);
115
+ } catch (error) {
116
+ const message = error instanceof Error ? error.message : String(error);
117
+ setState((prev) => ({ ...prev, error: message }));
118
+ }
119
+ }, [state.processedUrl, onSaveImage]);
120
+
121
+ const reset = useCallback(() => {
122
+ setState(INITIAL_STATE);
123
+ }, []);
124
+
125
+ return {
126
+ ...state,
127
+ selectImage,
128
+ process,
129
+ save,
130
+ reset,
131
+ };
132
+ }
@@ -0,0 +1 @@
1
+ export * from "./hooks";
@@ -52,7 +52,7 @@ export async function executeImageToVideo(
52
52
  options: ExecuteImageToVideoOptions,
53
53
  ): Promise<ImageToVideoResult> {
54
54
  if (typeof __DEV__ !== "undefined" && __DEV__) {
55
- // eslint-disable-next-line no-console
55
+
56
56
  console.log("[ImageToVideoExecutor] executeImageToVideo() called");
57
57
  }
58
58
 
@@ -60,7 +60,7 @@ export async function executeImageToVideo(
60
60
 
61
61
  if (!provider) {
62
62
  if (typeof __DEV__ !== "undefined" && __DEV__) {
63
- // eslint-disable-next-line no-console
63
+
64
64
  console.error("[ImageToVideoExecutor] No AI provider configured");
65
65
  }
66
66
  return { success: false, error: "No AI provider configured" };
@@ -68,7 +68,7 @@ export async function executeImageToVideo(
68
68
 
69
69
  if (!provider.isInitialized()) {
70
70
  if (typeof __DEV__ !== "undefined" && __DEV__) {
71
- // eslint-disable-next-line no-console
71
+
72
72
  console.error("[ImageToVideoExecutor] AI provider not initialized");
73
73
  }
74
74
  return { success: false, error: "AI provider not initialized" };
@@ -81,7 +81,7 @@ export async function executeImageToVideo(
81
81
  const { model, buildInput, extractResult, onProgress } = options;
82
82
 
83
83
  if (typeof __DEV__ !== "undefined" && __DEV__) {
84
- // eslint-disable-next-line no-console
84
+
85
85
  console.log(`[ImageToVideoExecutor] Provider: ${provider.providerId}, Model: ${model}`);
86
86
  }
87
87
 
@@ -89,7 +89,7 @@ export async function executeImageToVideo(
89
89
  onProgress?.(5);
90
90
 
91
91
  if (typeof __DEV__ !== "undefined" && __DEV__) {
92
- // eslint-disable-next-line no-console
92
+
93
93
  console.log("[ImageToVideoExecutor] Starting provider.subscribe()...");
94
94
  }
95
95
 
@@ -101,7 +101,7 @@ export async function executeImageToVideo(
101
101
  const result = await provider.subscribe(model, input, {
102
102
  onQueueUpdate: (status) => {
103
103
  if (typeof __DEV__ !== "undefined" && __DEV__) {
104
- // eslint-disable-next-line no-console
104
+
105
105
  console.log("[ImageToVideoExecutor] Queue status:", status.status, "position:", status.queuePosition);
106
106
  }
107
107
  // Map provider status to progress using centralized mapper
@@ -112,12 +112,12 @@ export async function executeImageToVideo(
112
112
  });
113
113
 
114
114
  if (typeof __DEV__ !== "undefined" && __DEV__) {
115
- // eslint-disable-next-line no-console
115
+
116
116
  console.log("[ImageToVideoExecutor] Subscribe resolved, result keys:", result ? Object.keys(result as object) : "null");
117
117
  }
118
118
 
119
119
  if (typeof __DEV__ !== "undefined" && __DEV__) {
120
- // eslint-disable-next-line no-console
120
+
121
121
  console.log("[ImageToVideoExecutor] provider.subscribe() completed");
122
122
  }
123
123
 
@@ -127,7 +127,7 @@ export async function executeImageToVideo(
127
127
 
128
128
  if (!extracted?.videoUrl) {
129
129
  if (typeof __DEV__ !== "undefined" && __DEV__) {
130
- // eslint-disable-next-line no-console
130
+
131
131
  console.error("[ImageToVideoExecutor] No video URL in response");
132
132
  }
133
133
  return { success: false, error: "No video in response" };
@@ -141,7 +141,7 @@ export async function executeImageToVideo(
141
141
  } catch (error) {
142
142
  const message = error instanceof Error ? error.message : String(error);
143
143
  if (typeof __DEV__ !== "undefined" && __DEV__) {
144
- // eslint-disable-next-line no-console
144
+
145
145
  console.error("[ImageToVideoExecutor] Error:", message);
146
146
  }
147
147
  return { success: false, error: message };
@@ -76,7 +76,7 @@ export function useImageToVideoFeature(
76
76
  }));
77
77
 
78
78
  if (typeof __DEV__ !== "undefined" && __DEV__) {
79
- // eslint-disable-next-line no-console
79
+
80
80
  console.log("[ImageToVideoFeature] Starting generation, creationId:", creationId);
81
81
  }
82
82
 
@@ -90,7 +90,7 @@ export function useImageToVideoFeature(
90
90
  metadata: options as Record<string, unknown> | undefined,
91
91
  }).catch((err) => {
92
92
  if (typeof __DEV__ !== "undefined" && __DEV__) {
93
- // eslint-disable-next-line no-console
93
+
94
94
  console.warn("[ImageToVideoFeature] onGenerationStart failed:", err);
95
95
  }
96
96
  });
@@ -100,7 +100,7 @@ export function useImageToVideoFeature(
100
100
  const imageBase64 = await config.prepareImage(imageUri);
101
101
 
102
102
  if (typeof __DEV__ !== "undefined" && __DEV__) {
103
- // eslint-disable-next-line no-console
103
+
104
104
  console.log("[ImageToVideoFeature] Image prepared, calling executeImageToVideo");
105
105
  }
106
106
 
@@ -160,7 +160,7 @@ export function useImageToVideoFeature(
160
160
  } catch (err) {
161
161
  const errorMessage = err instanceof Error ? err.message : String(err);
162
162
  if (typeof __DEV__ !== "undefined" && __DEV__) {
163
- // eslint-disable-next-line no-console
163
+
164
164
  console.error("[ImageToVideoFeature] Generation error:", errorMessage);
165
165
  }
166
166
  setState((prev) => ({
@@ -183,7 +183,7 @@ export function useImageToVideoFeature(
183
183
  const effectiveMotionPrompt = paramMotionPrompt ?? state.motionPrompt;
184
184
 
185
185
  if (typeof __DEV__ !== "undefined" && __DEV__) {
186
- // eslint-disable-next-line no-console
186
+
187
187
  console.log("[ImageToVideoFeature] generate called, hasImage:", !!effectiveImageUri);
188
188
  }
189
189
 
@@ -192,7 +192,7 @@ export function useImageToVideoFeature(
192
192
  setState((prev) => ({ ...prev, error }));
193
193
  callbacks?.onError?.(error);
194
194
  if (typeof __DEV__ !== "undefined" && __DEV__) {
195
- // eslint-disable-next-line no-console
195
+
196
196
  console.log("[ImageToVideoFeature] Generate failed: Image is required");
197
197
  }
198
198
  return { success: false, error };
@@ -204,7 +204,7 @@ export function useImageToVideoFeature(
204
204
 
205
205
  if (callbacks?.onAuthCheck && !callbacks.onAuthCheck()) {
206
206
  if (typeof __DEV__ !== "undefined" && __DEV__) {
207
- // eslint-disable-next-line no-console
207
+
208
208
  console.log("[ImageToVideoFeature] Generate failed: Authentication required");
209
209
  }
210
210
  return { success: false, error: "Authentication required" };
@@ -215,7 +215,7 @@ export function useImageToVideoFeature(
215
215
  if (!hasCredits) {
216
216
  callbacks?.onShowPaywall?.(config.creditCost);
217
217
  if (typeof __DEV__ !== "undefined" && __DEV__) {
218
- // eslint-disable-next-line no-console
218
+
219
219
  console.log("[ImageToVideoFeature] Generate failed: Insufficient credits");
220
220
  }
221
221
  return { success: false, error: "Insufficient credits" };
@@ -63,32 +63,32 @@ export function useImageToVideoForm(
63
63
 
64
64
  const handleSelectImages = useCallback(async () => {
65
65
  if (__DEV__) {
66
- // eslint-disable-next-line no-console
66
+
67
67
  console.log("[useImageToVideoForm] handleSelectImages called");
68
68
  }
69
69
  if (callbacks.onSelectImages) {
70
70
  try {
71
71
  const images = await callbacks.onSelectImages();
72
72
  if (__DEV__) {
73
- // eslint-disable-next-line no-console
73
+
74
74
  console.log("[useImageToVideoForm] Images selected:", images.length);
75
75
  }
76
76
  if (images.length > 0) {
77
77
  actions.addImages(images);
78
78
  if (__DEV__) {
79
- // eslint-disable-next-line no-console
79
+
80
80
  console.log("[useImageToVideoForm] Images added to state");
81
81
  }
82
82
  }
83
83
  } catch (error) {
84
84
  if (__DEV__) {
85
- // eslint-disable-next-line no-console
85
+
86
86
  console.error("[useImageToVideoForm] Error selecting images:", error);
87
87
  }
88
88
  }
89
89
  } else {
90
90
  if (__DEV__) {
91
- // eslint-disable-next-line no-console
91
+
92
92
  console.warn("[useImageToVideoForm] No onSelectImages callback provided");
93
93
  }
94
94
  }
@@ -32,7 +32,7 @@ export class MemeGenerationService {
32
32
  return text;
33
33
  } catch (error) {
34
34
  if (__DEV__) {
35
- // eslint-disable-next-line no-console
35
+
36
36
  console.error("[MemeGenerationService] Enhance prompt error:", error);
37
37
  }
38
38
  return prompt;
@@ -71,7 +71,7 @@ export class MemeGenerationService {
71
71
  throw new Error("No image generated");
72
72
  } catch (error) {
73
73
  if (__DEV__) {
74
- // eslint-disable-next-line no-console
74
+
75
75
  console.error("[MemeGenerationService] Generate meme error:", error);
76
76
  }
77
77
  throw error;
@@ -8,6 +8,5 @@ export type {
8
8
  RemoveBackgroundResult,
9
9
  RemoveBackgroundFeatureState,
10
10
  RemoveBackgroundTranslations,
11
- RemoveBackgroundResultExtractor,
12
11
  RemoveBackgroundFeatureConfig,
13
12
  } from "./remove-background.types";
@@ -1,8 +1,15 @@
1
1
  /**
2
2
  * Remove Background Feature Types
3
- * Request, Result, Config types for background removal
3
+ * Extends base image-to-image types with remove-background options
4
4
  */
5
5
 
6
+ import type {
7
+ BaseImageResult,
8
+ BaseSingleImageState,
9
+ BaseImageTranslations,
10
+ SingleImageConfig,
11
+ } from "../../../image-to-image/domain/types";
12
+
6
13
  export interface RemoveBackgroundOptions {
7
14
  refineEdges?: boolean;
8
15
  outputFormat?: "png" | "webp";
@@ -16,46 +23,13 @@ export interface RemoveBackgroundRequest {
16
23
  options?: RemoveBackgroundOptions;
17
24
  }
18
25
 
19
- export interface RemoveBackgroundResult {
20
- success: boolean;
21
- imageUrl?: string;
22
- imageBase64?: string;
23
- error?: string;
24
- requestId?: string;
25
- }
26
-
27
- export interface RemoveBackgroundFeatureState {
28
- imageUri: string | null;
29
- processedUrl: string | null;
30
- isProcessing: boolean;
31
- progress: number;
32
- error: string | null;
33
- }
26
+ export type RemoveBackgroundResult = BaseImageResult;
34
27
 
35
- export interface RemoveBackgroundTranslations {
36
- uploadTitle: string;
37
- uploadSubtitle: string;
38
- uploadChange: string;
39
- uploadAnalyzing: string;
40
- description: string;
41
- processingText: string;
42
- processButtonText: string;
43
- successText: string;
44
- saveButtonText: string;
45
- tryAnotherText: string;
46
- beforeLabel?: string;
47
- afterLabel?: string;
48
- compareHint?: string;
49
- }
28
+ export type RemoveBackgroundFeatureState = BaseSingleImageState;
50
29
 
51
- export type RemoveBackgroundResultExtractor = (result: unknown) => string | undefined;
30
+ export type RemoveBackgroundTranslations = BaseImageTranslations;
52
31
 
53
- export interface RemoveBackgroundFeatureConfig {
54
- creditCost?: number;
55
- extractResult?: RemoveBackgroundResultExtractor;
56
- prepareImage: (imageUri: string) => Promise<string>;
57
- onImageSelect?: (uri: string) => void;
58
- onProcessingStart?: () => void;
59
- onProcessingComplete?: (result: RemoveBackgroundResult) => void;
60
- onError?: (error: string) => void;
32
+ export interface RemoveBackgroundFeatureConfig
33
+ extends SingleImageConfig<RemoveBackgroundResult> {
34
+ defaultOptions?: RemoveBackgroundOptions;
61
35
  }
@@ -11,15 +11,11 @@ export type {
11
11
  RemoveBackgroundFeatureState,
12
12
  RemoveBackgroundTranslations,
13
13
  RemoveBackgroundFeatureConfig,
14
- RemoveBackgroundResultExtractor,
15
14
  } from "./domain";
16
15
 
17
16
  // Presentation Hooks
18
17
  export { useRemoveBackgroundFeature } from "./presentation";
19
- export type {
20
- UseRemoveBackgroundFeatureProps,
21
- UseRemoveBackgroundFeatureReturn,
22
- } from "./presentation";
18
+ export type { UseRemoveBackgroundFeatureProps } from "./presentation";
23
19
 
24
20
  // Presentation Components
25
21
  export { RemoveBackgroundFeature } from "./presentation";
@@ -3,7 +3,4 @@
3
3
  */
4
4
 
5
5
  export { useRemoveBackgroundFeature } from "./useRemoveBackgroundFeature";
6
- export type {
7
- UseRemoveBackgroundFeatureProps,
8
- UseRemoveBackgroundFeatureReturn,
9
- } from "./useRemoveBackgroundFeature";
6
+ export type { UseRemoveBackgroundFeatureProps } from "./useRemoveBackgroundFeature";