@umituz/react-native-ai-generation-content 1.17.225 → 1.17.226
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/ai-hug/presentation/components/AIHugFeature.tsx +2 -2
- package/src/features/ai-kiss/presentation/components/AIKissFeature.tsx +5 -2
- package/src/features/anime-selfie/presentation/components/AnimeSelfieFeature.tsx +7 -3
- package/src/features/face-swap/presentation/components/FaceSwapFeature.tsx +7 -3
- package/src/features/hd-touch-up/presentation/components/HDTouchUpFeature.tsx +7 -3
- package/src/features/image-to-image/domain/types/base.types.ts +41 -226
- package/src/features/image-to-image/domain/types/partials/config.types.ts +37 -0
- package/src/features/image-to-image/domain/types/partials/hook.types.ts +55 -0
- package/src/features/image-to-image/domain/types/partials/metadata.types.ts +32 -0
- package/src/features/image-to-image/domain/types/partials/result.types.ts +44 -0
- package/src/features/image-to-image/domain/types/partials/state.types.ts +34 -0
- package/src/features/image-to-image/domain/types/partials/translation.types.ts +57 -0
- package/src/features/photo-restoration/presentation/components/PhotoRestoreFeature.tsx +7 -3
- package/src/features/remove-background/presentation/components/RemoveBackgroundFeature.tsx +3 -3
- package/src/features/remove-object/presentation/components/RemoveObjectFeature.tsx +3 -3
- package/src/features/replace-background/presentation/components/ReplaceBackgroundFeature.tsx +7 -3
- package/src/features/upscaling/presentation/components/UpscaleFeature.tsx +7 -3
- package/src/infrastructure/utils/error-classifier.util.ts +8 -40
- package/src/infrastructure/utils/error-patterns.constants.ts +41 -0
- package/src/presentation/hooks/base/use-dual-image-feature.ts +68 -76
- package/src/presentation/hooks/base/use-image-with-prompt-feature.ts +70 -73
- package/src/presentation/hooks/base/utils/feature-state.factory.ts +133 -0
- package/src/presentation/layouts/index.ts +14 -11
- package/src/presentation/layouts/types/feature-states.ts +38 -0
- package/src/presentation/layouts/types/index.ts +35 -0
- package/src/presentation/layouts/types/input-props.ts +34 -0
- package/src/presentation/layouts/{types.ts → types/layout-props.ts} +22 -125
- package/src/presentation/layouts/types/result-props.ts +33 -0
- package/src/presentation/layouts/types/translations.ts +35 -0
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import React, { useMemo } from "react";
|
|
|
8
8
|
import { View, StyleSheet } from "react-native";
|
|
9
9
|
import { DualImagePicker } from "../../../../presentation/components/image-picker/DualImagePicker";
|
|
10
10
|
import { DualImageVideoFeatureLayout } from "../../../../presentation/layouts";
|
|
11
|
-
import type { ProcessingModalRenderProps } from "../../../../presentation/layouts";
|
|
11
|
+
import type { ProcessingModalRenderProps, DualImageInputRenderProps } from "../../../../presentation/layouts";
|
|
12
12
|
import { useAIHugFeature } from "../hooks";
|
|
13
13
|
import type {
|
|
14
14
|
AIHugTranslations,
|
|
@@ -63,7 +63,7 @@ export const AIHugFeature: React.FC<AIHugFeatureProps> = ({
|
|
|
63
63
|
translations={translations}
|
|
64
64
|
modalTranslations={modalTranslations}
|
|
65
65
|
renderProcessingModal={renderProcessingModal}
|
|
66
|
-
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }) => (
|
|
66
|
+
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }: DualImageInputRenderProps) => (
|
|
67
67
|
<View style={styles.pickerContainer}>
|
|
68
68
|
<DualImagePicker
|
|
69
69
|
sourceImageUri={sourceImageUri}
|
|
@@ -8,7 +8,10 @@ import React, { useMemo } from "react";
|
|
|
8
8
|
import { View, StyleSheet } from "react-native";
|
|
9
9
|
import { DualImagePicker } from "../../../../presentation/components/image-picker/DualImagePicker";
|
|
10
10
|
import { DualImageVideoFeatureLayout } from "../../../../presentation/layouts";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ProcessingModalRenderProps,
|
|
13
|
+
DualImageInputRenderProps,
|
|
14
|
+
} from "../../../../presentation/layouts";
|
|
12
15
|
import { useAIKissFeature } from "../hooks";
|
|
13
16
|
import type {
|
|
14
17
|
AIKissTranslations,
|
|
@@ -63,7 +66,7 @@ export const AIKissFeature: React.FC<AIKissFeatureProps> = ({
|
|
|
63
66
|
translations={translations}
|
|
64
67
|
modalTranslations={modalTranslations}
|
|
65
68
|
renderProcessingModal={renderProcessingModal}
|
|
66
|
-
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }) => (
|
|
69
|
+
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }: DualImageInputRenderProps) => (
|
|
67
70
|
<View style={styles.pickerContainer}>
|
|
68
71
|
<DualImagePicker
|
|
69
72
|
sourceImageUri={sourceImageUri}
|
|
@@ -8,7 +8,11 @@ import React, { useMemo } from "react";
|
|
|
8
8
|
import { Image, StyleSheet } from "react-native";
|
|
9
9
|
import { PhotoUploadCard } from "../../../../presentation/components/PhotoUploadCard";
|
|
10
10
|
import { SingleImageFeatureLayout } from "../../../../presentation/layouts";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ProcessingModalRenderProps,
|
|
13
|
+
SingleImageInputRenderProps,
|
|
14
|
+
ResultRenderProps,
|
|
15
|
+
} from "../../../../presentation/layouts";
|
|
12
16
|
import { useAnimeSelfieFeature } from "../hooks";
|
|
13
17
|
import type {
|
|
14
18
|
AnimeSelfieTranslations,
|
|
@@ -61,7 +65,7 @@ export const AnimeSelfieFeature: React.FC<AnimeSelfieFeatureProps> = ({
|
|
|
61
65
|
translations={translations}
|
|
62
66
|
modalTranslations={modalTranslations}
|
|
63
67
|
renderProcessingModal={renderProcessingModal}
|
|
64
|
-
renderInput={({ imageUri, onSelect, isDisabled, isProcessing }) => (
|
|
68
|
+
renderInput={({ imageUri, onSelect, isDisabled, isProcessing }: SingleImageInputRenderProps) => (
|
|
65
69
|
<PhotoUploadCard
|
|
66
70
|
imageUri={imageUri}
|
|
67
71
|
onPress={onSelect}
|
|
@@ -81,7 +85,7 @@ export const AnimeSelfieFeature: React.FC<AnimeSelfieFeatureProps> = ({
|
|
|
81
85
|
}}
|
|
82
86
|
/>
|
|
83
87
|
)}
|
|
84
|
-
renderResult={({ imageUrl, imageSize }) => (
|
|
88
|
+
renderResult={({ imageUrl, imageSize }: ResultRenderProps) => (
|
|
85
89
|
<Image
|
|
86
90
|
source={{ uri: imageUrl }}
|
|
87
91
|
style={[styles.resultImage, { width: imageSize, height: imageSize }]}
|
|
@@ -8,7 +8,11 @@ import React, { useMemo } from "react";
|
|
|
8
8
|
import { View, Image, StyleSheet } from "react-native";
|
|
9
9
|
import { DualImagePicker } from "../../../../presentation/components/image-picker/DualImagePicker";
|
|
10
10
|
import { DualImageFeatureLayout } from "../../../../presentation/layouts";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ProcessingModalRenderProps,
|
|
13
|
+
DualImageInputRenderProps,
|
|
14
|
+
ResultRenderProps,
|
|
15
|
+
} from "../../../../presentation/layouts";
|
|
12
16
|
import { useFaceSwapFeature } from "../hooks";
|
|
13
17
|
import type {
|
|
14
18
|
FaceSwapTranslations,
|
|
@@ -63,7 +67,7 @@ export const FaceSwapFeature: React.FC<FaceSwapFeatureProps> = ({
|
|
|
63
67
|
translations={translations}
|
|
64
68
|
modalTranslations={modalTranslations}
|
|
65
69
|
renderProcessingModal={renderProcessingModal}
|
|
66
|
-
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }) => (
|
|
70
|
+
renderInput={({ sourceImageUri, targetImageUri, onSelectSource, onSelectTarget, isDisabled }: DualImageInputRenderProps) => (
|
|
67
71
|
<View style={styles.pickerContainer}>
|
|
68
72
|
<DualImagePicker
|
|
69
73
|
sourceImageUri={sourceImageUri}
|
|
@@ -77,7 +81,7 @@ export const FaceSwapFeature: React.FC<FaceSwapFeatureProps> = ({
|
|
|
77
81
|
/>
|
|
78
82
|
</View>
|
|
79
83
|
)}
|
|
80
|
-
renderResult={({ imageUrl, imageSize }) => (
|
|
84
|
+
renderResult={({ imageUrl, imageSize }: ResultRenderProps) => (
|
|
81
85
|
<Image
|
|
82
86
|
source={{ uri: imageUrl }}
|
|
83
87
|
style={[styles.resultImage, { width: imageSize, height: imageSize }]}
|
|
@@ -8,7 +8,11 @@ import React, { useMemo } from "react";
|
|
|
8
8
|
import { Image, StyleSheet } from "react-native";
|
|
9
9
|
import { PhotoUploadCard } from "../../../../presentation/components/PhotoUploadCard";
|
|
10
10
|
import { SingleImageFeatureLayout } from "../../../../presentation/layouts";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ProcessingModalRenderProps,
|
|
13
|
+
SingleImageInputRenderProps,
|
|
14
|
+
ResultRenderProps,
|
|
15
|
+
} from "../../../../presentation/layouts";
|
|
12
16
|
import { useHDTouchUpFeature } from "../hooks";
|
|
13
17
|
import type {
|
|
14
18
|
HDTouchUpTranslations,
|
|
@@ -60,7 +64,7 @@ export const HDTouchUpFeature: React.FC<HDTouchUpFeatureProps> = ({
|
|
|
60
64
|
translations={translations}
|
|
61
65
|
modalTranslations={modalTranslations}
|
|
62
66
|
renderProcessingModal={renderProcessingModal}
|
|
63
|
-
renderInput={({ imageUri, onSelect, isDisabled, isProcessing }) => (
|
|
67
|
+
renderInput={({ imageUri, onSelect, isDisabled, isProcessing }: SingleImageInputRenderProps) => (
|
|
64
68
|
<PhotoUploadCard
|
|
65
69
|
imageUri={imageUri}
|
|
66
70
|
onPress={onSelect}
|
|
@@ -80,7 +84,7 @@ export const HDTouchUpFeature: React.FC<HDTouchUpFeatureProps> = ({
|
|
|
80
84
|
}}
|
|
81
85
|
/>
|
|
82
86
|
)}
|
|
83
|
-
renderResult={({ imageUrl, imageSize }) => (
|
|
87
|
+
renderResult={({ imageUrl, imageSize }: ResultRenderProps) => (
|
|
84
88
|
<Image
|
|
85
89
|
source={{ uri: imageUrl }}
|
|
86
90
|
style={[styles.resultImage, { width: imageSize, height: imageSize }]}
|
|
@@ -5,229 +5,44 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ImageFeatureType } from "../../../../domain/interfaces";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Base state for dual image features
|
|
53
|
-
*/
|
|
54
|
-
export interface BaseDualImageState {
|
|
55
|
-
sourceImageUri: string | null;
|
|
56
|
-
targetImageUri: string | null;
|
|
57
|
-
processedUrl: string | null;
|
|
58
|
-
isProcessing: boolean;
|
|
59
|
-
progress: number;
|
|
60
|
-
error: string | null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Base translations for image features
|
|
65
|
-
*/
|
|
66
|
-
export interface BaseImageTranslations {
|
|
67
|
-
uploadTitle: string;
|
|
68
|
-
uploadSubtitle: string;
|
|
69
|
-
uploadChange: string;
|
|
70
|
-
uploadAnalyzing: string;
|
|
71
|
-
description: string;
|
|
72
|
-
processingText: string;
|
|
73
|
-
processButtonText: string;
|
|
74
|
-
successText: string;
|
|
75
|
-
saveButtonText: string;
|
|
76
|
-
tryAnotherText: string;
|
|
77
|
-
beforeLabel?: string;
|
|
78
|
-
afterLabel?: string;
|
|
79
|
-
compareHint?: string;
|
|
80
|
-
/** Modal title shown during processing */
|
|
81
|
-
modalTitle?: string;
|
|
82
|
-
/** Modal message shown during processing */
|
|
83
|
-
modalMessage?: string;
|
|
84
|
-
/** Modal hint/tip shown during processing */
|
|
85
|
-
modalHint?: string;
|
|
86
|
-
/** "Continue in background" text */
|
|
87
|
-
modalBackgroundHint?: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Base translations for dual image features
|
|
92
|
-
*/
|
|
93
|
-
export interface BaseDualImageTranslations {
|
|
94
|
-
sourceUploadTitle: string;
|
|
95
|
-
sourceUploadSubtitle: string;
|
|
96
|
-
targetUploadTitle: string;
|
|
97
|
-
targetUploadSubtitle: string;
|
|
98
|
-
uploadChange: string;
|
|
99
|
-
uploadAnalyzing: string;
|
|
100
|
-
description: string;
|
|
101
|
-
processingText: string;
|
|
102
|
-
processButtonText: string;
|
|
103
|
-
successText: string;
|
|
104
|
-
saveButtonText: string;
|
|
105
|
-
tryAnotherText: string;
|
|
106
|
-
/** Modal title shown during processing */
|
|
107
|
-
modalTitle?: string;
|
|
108
|
-
/** Modal message shown during processing */
|
|
109
|
-
modalMessage?: string;
|
|
110
|
-
/** Modal hint/tip shown during processing */
|
|
111
|
-
modalHint?: string;
|
|
112
|
-
/** "Continue in background" text */
|
|
113
|
-
modalBackgroundHint?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Result extractor function type
|
|
118
|
-
*/
|
|
119
|
-
export type ImageResultExtractor = (result: unknown) => string | undefined;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Single image processing start data
|
|
123
|
-
*/
|
|
124
|
-
export interface SingleImageProcessingStartData {
|
|
125
|
-
creationId: string;
|
|
126
|
-
imageUri: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Dual image processing start data
|
|
131
|
-
*/
|
|
132
|
-
export interface DualImageProcessingStartData {
|
|
133
|
-
creationId: string;
|
|
134
|
-
sourceImageUri: string;
|
|
135
|
-
targetImageUri: string;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Base result with optional creationId for persistence
|
|
140
|
-
*/
|
|
141
|
-
export interface BaseImageResultWithCreationId extends BaseImageResult {
|
|
142
|
-
creationId?: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Base config for all image features
|
|
147
|
-
*/
|
|
148
|
-
export interface BaseImageConfig<TResult extends BaseImageResult = BaseImageResult> {
|
|
149
|
-
featureType: ImageFeatureType;
|
|
150
|
-
creditCost?: number;
|
|
151
|
-
extractResult?: ImageResultExtractor;
|
|
152
|
-
prepareImage: (imageUri: string) => Promise<string>;
|
|
153
|
-
onProcessingStart?: (data: { creationId: string; [key: string]: unknown }) => void;
|
|
154
|
-
onProcessingComplete?: (result: TResult) => void;
|
|
155
|
-
onError?: (error: string, creationId?: string) => void;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Config for single image features
|
|
160
|
-
*/
|
|
161
|
-
export interface SingleImageConfig<TResult extends BaseImageResult = BaseImageResult>
|
|
162
|
-
extends BaseImageConfig<TResult> {
|
|
163
|
-
onImageSelect?: (uri: string) => void;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Config for dual image features
|
|
168
|
-
*/
|
|
169
|
-
export interface DualImageConfig<TResult extends BaseImageResult = BaseImageResult>
|
|
170
|
-
extends BaseImageConfig<TResult> {
|
|
171
|
-
onSourceImageSelect?: (uri: string) => void;
|
|
172
|
-
onTargetImageSelect?: (uri: string) => void;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Base hook props for single image features
|
|
177
|
-
*/
|
|
178
|
-
export interface BaseSingleImageHookProps<
|
|
179
|
-
TConfig extends SingleImageConfig = SingleImageConfig,
|
|
180
|
-
> {
|
|
181
|
-
config: TConfig;
|
|
182
|
-
onSelectImage: () => Promise<string | null>;
|
|
183
|
-
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
184
|
-
/** Called before processing starts. Return false to cancel. */
|
|
185
|
-
onBeforeProcess?: () => Promise<boolean>;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Base hook props for dual image features
|
|
190
|
-
*/
|
|
191
|
-
export interface BaseDualImageHookProps<
|
|
192
|
-
TConfig extends DualImageConfig = DualImageConfig,
|
|
193
|
-
> {
|
|
194
|
-
config: TConfig;
|
|
195
|
-
onSelectSourceImage: () => Promise<string | null>;
|
|
196
|
-
onSelectTargetImage: () => Promise<string | null>;
|
|
197
|
-
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
198
|
-
/** Called before processing starts. Return false to cancel. */
|
|
199
|
-
onBeforeProcess?: () => Promise<boolean>;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Base hook return for single image features
|
|
204
|
-
*/
|
|
205
|
-
export interface BaseSingleImageHookReturn extends BaseSingleImageState {
|
|
206
|
-
selectImage: () => Promise<void>;
|
|
207
|
-
process: () => Promise<void>;
|
|
208
|
-
save: () => Promise<void>;
|
|
209
|
-
reset: () => void;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Base hook return for dual image features
|
|
214
|
-
*/
|
|
215
|
-
export interface BaseDualImageHookReturn extends BaseDualImageState {
|
|
216
|
-
selectSourceImage: () => Promise<void>;
|
|
217
|
-
selectTargetImage: () => Promise<void>;
|
|
218
|
-
process: () => Promise<void>;
|
|
219
|
-
save: () => Promise<void>;
|
|
220
|
-
reset: () => void;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Feature metadata for categorization
|
|
225
|
-
*/
|
|
226
|
-
export interface ImageFeatureMetadata {
|
|
227
|
-
name: string;
|
|
228
|
-
category: ImageProcessingCategory;
|
|
229
|
-
inputMode: ImageInputMode;
|
|
230
|
-
featureType: ImageFeatureType;
|
|
231
|
-
requiresPrompt?: boolean;
|
|
232
|
-
requiresMask?: boolean;
|
|
233
|
-
}
|
|
8
|
+
// Re-export all partial types
|
|
9
|
+
export type {
|
|
10
|
+
BaseSingleImageState,
|
|
11
|
+
BaseImageWithPromptState,
|
|
12
|
+
BaseDualImageState,
|
|
13
|
+
} from "./partials/state.types";
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
BaseImageResult,
|
|
17
|
+
BaseImageResultWithCreationId,
|
|
18
|
+
ImageResultExtractor,
|
|
19
|
+
SingleImageProcessingStartData,
|
|
20
|
+
DualImageProcessingStartData,
|
|
21
|
+
} from "./partials/result.types";
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
BaseImageTranslations,
|
|
25
|
+
BaseDualImageTranslations,
|
|
26
|
+
} from "./partials/translation.types";
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
BaseImageConfig,
|
|
30
|
+
SingleImageConfig,
|
|
31
|
+
DualImageConfig,
|
|
32
|
+
} from "./partials/config.types";
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
BaseSingleImageHookProps,
|
|
36
|
+
BaseDualImageHookProps,
|
|
37
|
+
BaseSingleImageHookReturn,
|
|
38
|
+
BaseDualImageHookReturn,
|
|
39
|
+
} from "./partials/hook.types";
|
|
40
|
+
|
|
41
|
+
export type {
|
|
42
|
+
ImageProcessingCategory,
|
|
43
|
+
ImageInputMode,
|
|
44
|
+
ImageFeatureMetadata,
|
|
45
|
+
} from "./partials/metadata.types";
|
|
46
|
+
|
|
47
|
+
// Legacy re-exports for backward compatibility
|
|
48
|
+
export type { ImageFeatureType };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature Config Types
|
|
3
|
+
* Configuration interfaces for all image processing features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ImageFeatureType } from "../../../../../domain/interfaces";
|
|
7
|
+
import type { BaseImageResult, ImageResultExtractor } from "./result.types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base config for all image features
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseImageConfig<TResult extends BaseImageResult = BaseImageResult> {
|
|
13
|
+
featureType: ImageFeatureType;
|
|
14
|
+
creditCost?: number;
|
|
15
|
+
extractResult?: ImageResultExtractor;
|
|
16
|
+
prepareImage: (imageUri: string) => Promise<string>;
|
|
17
|
+
onProcessingStart?: (data: { creationId: string; [key: string]: unknown }) => void;
|
|
18
|
+
onProcessingComplete?: (result: TResult) => void;
|
|
19
|
+
onError?: (error: string, creationId?: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Config for single image features
|
|
24
|
+
*/
|
|
25
|
+
export interface SingleImageConfig<TResult extends BaseImageResult = BaseImageResult>
|
|
26
|
+
extends BaseImageConfig<TResult> {
|
|
27
|
+
onImageSelect?: (uri: string) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Config for dual image features
|
|
32
|
+
*/
|
|
33
|
+
export interface DualImageConfig<TResult extends BaseImageResult = BaseImageResult>
|
|
34
|
+
extends BaseImageConfig<TResult> {
|
|
35
|
+
onSourceImageSelect?: (uri: string) => void;
|
|
36
|
+
onTargetImageSelect?: (uri: string) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature Hook Types
|
|
3
|
+
* Hook interfaces for all image processing features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SingleImageConfig, DualImageConfig } from "./config.types";
|
|
7
|
+
import type { BaseSingleImageState, BaseDualImageState } from "./state.types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base hook props for single image features
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseSingleImageHookProps<
|
|
13
|
+
TConfig extends SingleImageConfig = SingleImageConfig,
|
|
14
|
+
> {
|
|
15
|
+
config: TConfig;
|
|
16
|
+
onSelectImage: () => Promise<string | null>;
|
|
17
|
+
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
18
|
+
/** Called before processing starts. Return false to cancel. */
|
|
19
|
+
onBeforeProcess?: () => Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base hook props for dual image features
|
|
24
|
+
*/
|
|
25
|
+
export interface BaseDualImageHookProps<
|
|
26
|
+
TConfig extends DualImageConfig = DualImageConfig,
|
|
27
|
+
> {
|
|
28
|
+
config: TConfig;
|
|
29
|
+
onSelectSourceImage: () => Promise<string | null>;
|
|
30
|
+
onSelectTargetImage: () => Promise<string | null>;
|
|
31
|
+
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
32
|
+
/** Called before processing starts. Return false to cancel. */
|
|
33
|
+
onBeforeProcess?: () => Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Base hook return for single image features
|
|
38
|
+
*/
|
|
39
|
+
export interface BaseSingleImageHookReturn extends BaseSingleImageState {
|
|
40
|
+
selectImage: () => Promise<void>;
|
|
41
|
+
process: () => Promise<void>;
|
|
42
|
+
save: () => Promise<void>;
|
|
43
|
+
reset: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Base hook return for dual image features
|
|
48
|
+
*/
|
|
49
|
+
export interface BaseDualImageHookReturn extends BaseDualImageState {
|
|
50
|
+
selectSourceImage: () => Promise<void>;
|
|
51
|
+
selectTargetImage: () => Promise<void>;
|
|
52
|
+
process: () => Promise<void>;
|
|
53
|
+
save: () => Promise<void>;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature Metadata Types
|
|
3
|
+
* Metadata and categorization types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ImageFeatureType } from "../../../../../domain/interfaces";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Image processing categories
|
|
10
|
+
*/
|
|
11
|
+
export type ImageProcessingCategory =
|
|
12
|
+
| "enhancement"
|
|
13
|
+
| "editing"
|
|
14
|
+
| "transformation"
|
|
15
|
+
| "composition";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Input mode for image processing
|
|
19
|
+
*/
|
|
20
|
+
export type ImageInputMode = "single" | "single-with-prompt" | "dual";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Feature metadata for categorization
|
|
24
|
+
*/
|
|
25
|
+
export interface ImageFeatureMetadata {
|
|
26
|
+
name: string;
|
|
27
|
+
category: ImageProcessingCategory;
|
|
28
|
+
inputMode: ImageInputMode;
|
|
29
|
+
featureType: ImageFeatureType;
|
|
30
|
+
requiresPrompt?: boolean;
|
|
31
|
+
requiresMask?: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature Result Types
|
|
3
|
+
* Result interfaces for all image processing features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base result for all image processing features
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseImageResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
imageUrl?: string;
|
|
12
|
+
imageBase64?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
requestId?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base result with optional creationId for persistence
|
|
19
|
+
*/
|
|
20
|
+
export interface BaseImageResultWithCreationId extends BaseImageResult {
|
|
21
|
+
creationId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Result extractor function type
|
|
26
|
+
*/
|
|
27
|
+
export type ImageResultExtractor = (result: unknown) => string | undefined;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Image processing start data
|
|
31
|
+
*/
|
|
32
|
+
export interface SingleImageProcessingStartData {
|
|
33
|
+
creationId: string;
|
|
34
|
+
imageUri: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Dual image processing start data
|
|
39
|
+
*/
|
|
40
|
+
export interface DualImageProcessingStartData {
|
|
41
|
+
creationId: string;
|
|
42
|
+
sourceImageUri: string;
|
|
43
|
+
targetImageUri: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature State Types
|
|
3
|
+
* State interfaces for all image processing features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base state for single image features
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseSingleImageState {
|
|
10
|
+
imageUri: string | null;
|
|
11
|
+
processedUrl: string | null;
|
|
12
|
+
isProcessing: boolean;
|
|
13
|
+
progress: number;
|
|
14
|
+
error: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base state for single image + prompt features
|
|
19
|
+
*/
|
|
20
|
+
export interface BaseImageWithPromptState extends BaseSingleImageState {
|
|
21
|
+
prompt: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Base state for dual image features
|
|
26
|
+
*/
|
|
27
|
+
export interface BaseDualImageState {
|
|
28
|
+
sourceImageUri: string | null;
|
|
29
|
+
targetImageUri: string | null;
|
|
30
|
+
processedUrl: string | null;
|
|
31
|
+
isProcessing: boolean;
|
|
32
|
+
progress: number;
|
|
33
|
+
error: string | null;
|
|
34
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Feature Translation Types
|
|
3
|
+
* Translation interfaces for all image processing features
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base translations for image features
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseImageTranslations {
|
|
10
|
+
uploadTitle: string;
|
|
11
|
+
uploadSubtitle: string;
|
|
12
|
+
uploadChange: string;
|
|
13
|
+
uploadAnalyzing: string;
|
|
14
|
+
description: string;
|
|
15
|
+
processingText: string;
|
|
16
|
+
processButtonText: string;
|
|
17
|
+
successText: string;
|
|
18
|
+
saveButtonText: string;
|
|
19
|
+
tryAnotherText: string;
|
|
20
|
+
beforeLabel?: string;
|
|
21
|
+
afterLabel?: string;
|
|
22
|
+
compareHint?: string;
|
|
23
|
+
/** Modal title shown during processing */
|
|
24
|
+
modalTitle?: string;
|
|
25
|
+
/** Modal message shown during processing */
|
|
26
|
+
modalMessage?: string;
|
|
27
|
+
/** Modal hint/tip shown during processing */
|
|
28
|
+
modalHint?: string;
|
|
29
|
+
/** "Continue in background" text */
|
|
30
|
+
modalBackgroundHint?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Base translations for dual image features
|
|
35
|
+
*/
|
|
36
|
+
export interface BaseDualImageTranslations {
|
|
37
|
+
sourceUploadTitle: string;
|
|
38
|
+
sourceUploadSubtitle: string;
|
|
39
|
+
targetUploadTitle: string;
|
|
40
|
+
targetUploadSubtitle: string;
|
|
41
|
+
uploadChange: string;
|
|
42
|
+
uploadAnalyzing: string;
|
|
43
|
+
description: string;
|
|
44
|
+
processingText: string;
|
|
45
|
+
processButtonText: string;
|
|
46
|
+
successText: string;
|
|
47
|
+
saveButtonText: string;
|
|
48
|
+
tryAnotherText: string;
|
|
49
|
+
/** Modal title shown during processing */
|
|
50
|
+
modalTitle?: string;
|
|
51
|
+
/** Modal message shown during processing */
|
|
52
|
+
modalMessage?: string;
|
|
53
|
+
/** Modal hint/tip shown during processing */
|
|
54
|
+
modalHint?: string;
|
|
55
|
+
/** "Continue in background" text */
|
|
56
|
+
modalBackgroundHint?: string;
|
|
57
|
+
}
|