@umituz/react-native-ai-generation-content 1.26.6 → 1.26.7
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/index.ts +0 -30
- package/src/presentation/screens/ai-feature/AIFeatureScreen.tsx +0 -167
- package/src/presentation/screens/ai-feature/index.ts +0 -21
- package/src/presentation/screens/ai-feature/registry.ts +0 -155
- package/src/presentation/screens/ai-feature/translations.ts +0 -115
- package/src/presentation/screens/ai-feature/types.ts +0 -160
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.7",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -152,35 +152,5 @@ export {
|
|
|
152
152
|
type GenerationConfigProviderProps,
|
|
153
153
|
} from "./infrastructure/providers";
|
|
154
154
|
|
|
155
|
-
// Result Preview Domain
|
|
156
155
|
export * from "./domains/result-preview";
|
|
157
|
-
|
|
158
|
-
// Unified AI Feature Screen
|
|
159
|
-
export {
|
|
160
|
-
AIFeatureScreen,
|
|
161
|
-
AI_FEATURE_CONFIGS,
|
|
162
|
-
getAIFeatureConfig,
|
|
163
|
-
hasAIFeature,
|
|
164
|
-
getAllAIFeatureIds,
|
|
165
|
-
getAIFeaturesByMode,
|
|
166
|
-
createFeatureTranslations,
|
|
167
|
-
createSingleImageTranslations,
|
|
168
|
-
createDualImageTranslations,
|
|
169
|
-
createComparisonTranslations,
|
|
170
|
-
createPromptTranslations,
|
|
171
|
-
} from "./presentation/screens/ai-feature";
|
|
172
|
-
export type {
|
|
173
|
-
AIFeatureId,
|
|
174
|
-
AIFeatureMode,
|
|
175
|
-
AIFeatureOutputType,
|
|
176
|
-
AIFeatureCreditType,
|
|
177
|
-
AIFeatureConfig,
|
|
178
|
-
AIFeatureScreenProps,
|
|
179
|
-
SingleImageTranslationKeys,
|
|
180
|
-
DualImageTranslationKeys,
|
|
181
|
-
ComparisonTranslationKeys,
|
|
182
|
-
PromptTranslationKeys,
|
|
183
|
-
} from "./presentation/screens/ai-feature";
|
|
184
|
-
|
|
185
|
-
|
|
186
156
|
export * from "./domains/generation";
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AIFeatureScreen
|
|
3
|
-
* Unified screen component for all AI features
|
|
4
|
-
* Reduces 9 screens to 1 configurable component
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React, { useMemo, useCallback } from "react";
|
|
8
|
-
import { View } from "react-native";
|
|
9
|
-
import { ScreenLayout } from "@umituz/react-native-design-system";
|
|
10
|
-
import { useLocalization } from "@umituz/react-native-localization";
|
|
11
|
-
|
|
12
|
-
import { AIGenScreenHeader } from "../../components/headers/AIGenScreenHeader";
|
|
13
|
-
import { CreditBadge } from "../../components/headers/CreditBadge";
|
|
14
|
-
import { prepareImage } from "../../../infrastructure/utils/feature-utils";
|
|
15
|
-
import { useCreationPersistence } from "../../../domains/creations/presentation/hooks/useCreationPersistence";
|
|
16
|
-
|
|
17
|
-
// Feature components
|
|
18
|
-
import { AnimeSelfieFeature } from "../../../features/anime-selfie/presentation/components/AnimeSelfieFeature";
|
|
19
|
-
import { RemoveBackgroundFeature } from "../../../features/remove-background/presentation/components/RemoveBackgroundFeature";
|
|
20
|
-
import { HDTouchUpFeature } from "../../../features/hd-touch-up/presentation/components/HDTouchUpFeature";
|
|
21
|
-
import { UpscaleFeature } from "../../../features/upscaling/presentation/components/UpscaleFeature";
|
|
22
|
-
import { PhotoRestoreFeature } from "../../../features/photo-restoration/presentation/components/PhotoRestoreFeature";
|
|
23
|
-
import { RemoveObjectFeature } from "../../../features/remove-object/presentation/components/RemoveObjectFeature";
|
|
24
|
-
import { ReplaceBackgroundFeature } from "../../../features/replace-background/presentation/components/ReplaceBackgroundFeature";
|
|
25
|
-
import { FaceSwapFeature } from "../../../features/face-swap/presentation/components/FaceSwapFeature";
|
|
26
|
-
import { AIHugFeature } from "../../../features/ai-hug/presentation/components/AIHugFeature";
|
|
27
|
-
import { AIKissFeature } from "../../../features/ai-kiss/presentation/components/AIKissFeature";
|
|
28
|
-
import { MemeGeneratorFeature } from "../../../features/meme-generator/presentation/components/MemeGeneratorFeature";
|
|
29
|
-
|
|
30
|
-
import { createFeatureTranslations } from "./translations";
|
|
31
|
-
import type { AIFeatureScreenProps, AIFeatureId } from "./types";
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Feature component mapping
|
|
35
|
-
* Using explicit any type for component registry to allow dynamic prop injection
|
|
36
|
-
*/
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
const FEATURE_COMPONENTS: Record<AIFeatureId, React.ComponentType<any>> = {
|
|
39
|
-
"anime-selfie": AnimeSelfieFeature,
|
|
40
|
-
"remove-background": RemoveBackgroundFeature,
|
|
41
|
-
"hd-touch-up": HDTouchUpFeature,
|
|
42
|
-
upscale: UpscaleFeature,
|
|
43
|
-
"photo-restore": PhotoRestoreFeature,
|
|
44
|
-
"remove-object": RemoveObjectFeature,
|
|
45
|
-
"replace-background": ReplaceBackgroundFeature,
|
|
46
|
-
"face-swap": FaceSwapFeature,
|
|
47
|
-
"ai-hug": AIHugFeature,
|
|
48
|
-
"ai-kiss": AIKissFeature,
|
|
49
|
-
"meme-generator": MemeGeneratorFeature,
|
|
50
|
-
"image-to-video": React.Fragment,
|
|
51
|
-
"text-to-video": React.Fragment,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* AIFeatureScreen - Unified component for all AI features
|
|
56
|
-
*/
|
|
57
|
-
export const AIFeatureScreen: React.FC<AIFeatureScreenProps> = ({
|
|
58
|
-
config,
|
|
59
|
-
creditCost,
|
|
60
|
-
onDeductCredits,
|
|
61
|
-
onSelectImage,
|
|
62
|
-
onSaveMedia,
|
|
63
|
-
onCheckCreditGuard,
|
|
64
|
-
imageCredits,
|
|
65
|
-
headerRightContent,
|
|
66
|
-
}) => {
|
|
67
|
-
const { t } = useLocalization();
|
|
68
|
-
|
|
69
|
-
// Create persistence callbacks
|
|
70
|
-
const persistence = useCreationPersistence({
|
|
71
|
-
type: config.id,
|
|
72
|
-
creditCost,
|
|
73
|
-
onCreditDeduct: onDeductCredits,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Create translations based on feature mode
|
|
77
|
-
const translations = useMemo(
|
|
78
|
-
() => createFeatureTranslations(config, t),
|
|
79
|
-
[config, t],
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
// Create feature config
|
|
83
|
-
const featureConfig = useMemo(
|
|
84
|
-
() => ({
|
|
85
|
-
prepareImage,
|
|
86
|
-
...config.extraConfig,
|
|
87
|
-
...persistence,
|
|
88
|
-
}),
|
|
89
|
-
[config.extraConfig, persistence],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Credit guard callback
|
|
93
|
-
const handleBeforeProcess = useCallback(async () => {
|
|
94
|
-
// Convert featureId to PascalCase for analytics
|
|
95
|
-
const featureName = config.id
|
|
96
|
-
.split("-")
|
|
97
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
98
|
-
.join("");
|
|
99
|
-
return onCheckCreditGuard(creditCost, featureName);
|
|
100
|
-
}, [config.id, creditCost, onCheckCreditGuard]);
|
|
101
|
-
|
|
102
|
-
// Get the feature component
|
|
103
|
-
const FeatureComponent = FEATURE_COMPONENTS[config.id];
|
|
104
|
-
|
|
105
|
-
// Build props based on feature mode
|
|
106
|
-
const featureProps = useMemo(() => {
|
|
107
|
-
const baseProps = {
|
|
108
|
-
config: featureConfig,
|
|
109
|
-
translations,
|
|
110
|
-
onBeforeProcess: handleBeforeProcess,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Add mode-specific props
|
|
114
|
-
switch (config.mode) {
|
|
115
|
-
case "single":
|
|
116
|
-
case "single-with-prompt":
|
|
117
|
-
return {
|
|
118
|
-
...baseProps,
|
|
119
|
-
onSelectImage,
|
|
120
|
-
onSaveImage: onSaveMedia,
|
|
121
|
-
};
|
|
122
|
-
case "text-input":
|
|
123
|
-
return {
|
|
124
|
-
...baseProps,
|
|
125
|
-
onSaveImage: onSaveMedia,
|
|
126
|
-
// Text input doesn't need image selection
|
|
127
|
-
};
|
|
128
|
-
case "dual":
|
|
129
|
-
return {
|
|
130
|
-
...baseProps,
|
|
131
|
-
onSelectSourceImage: onSelectImage,
|
|
132
|
-
onSelectTargetImage: onSelectImage,
|
|
133
|
-
onSaveImage: onSaveMedia,
|
|
134
|
-
};
|
|
135
|
-
case "dual-video":
|
|
136
|
-
return {
|
|
137
|
-
...baseProps,
|
|
138
|
-
onSelectSourceImage: onSelectImage,
|
|
139
|
-
onSelectTargetImage: onSelectImage,
|
|
140
|
-
onSaveVideo: onSaveMedia,
|
|
141
|
-
};
|
|
142
|
-
default:
|
|
143
|
-
return baseProps;
|
|
144
|
-
}
|
|
145
|
-
}, [config.mode, featureConfig, translations, handleBeforeProcess, onSelectImage, onSaveMedia]);
|
|
146
|
-
|
|
147
|
-
// Default header right content with credit badge
|
|
148
|
-
const defaultHeaderRight = (
|
|
149
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
150
|
-
<CreditBadge credits={imageCredits} compact />
|
|
151
|
-
</View>
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<ScreenLayout
|
|
156
|
-
header={
|
|
157
|
-
<AIGenScreenHeader
|
|
158
|
-
title={t(`${config.translationPrefix}.title`)}
|
|
159
|
-
rightContent={headerRightContent ?? defaultHeaderRight}
|
|
160
|
-
/>
|
|
161
|
-
}
|
|
162
|
-
scrollable={false}
|
|
163
|
-
>
|
|
164
|
-
<FeatureComponent {...featureProps} />
|
|
165
|
-
</ScreenLayout>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Feature Screen
|
|
3
|
-
* Unified screen component for all AI features
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { AIFeatureScreen } from "./AIFeatureScreen";
|
|
7
|
-
export { AI_FEATURE_CONFIGS, getAIFeatureConfig, hasAIFeature, getAllAIFeatureIds, getAIFeaturesByMode } from "./registry";
|
|
8
|
-
export { createFeatureTranslations, createSingleImageTranslations, createDualImageTranslations, createComparisonTranslations, createPromptTranslations, createTextInputTranslations } from "./translations";
|
|
9
|
-
export type {
|
|
10
|
-
AIFeatureId,
|
|
11
|
-
AIFeatureMode,
|
|
12
|
-
AIFeatureOutputType,
|
|
13
|
-
AIFeatureCreditType,
|
|
14
|
-
AIFeatureConfig,
|
|
15
|
-
AIFeatureScreenProps,
|
|
16
|
-
SingleImageTranslationKeys,
|
|
17
|
-
DualImageTranslationKeys,
|
|
18
|
-
ComparisonTranslationKeys,
|
|
19
|
-
PromptTranslationKeys,
|
|
20
|
-
TextInputTranslationKeys,
|
|
21
|
-
} from "./types";
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Feature Registry
|
|
3
|
-
* Static configuration for all AI features
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { AIFeatureConfig, AIFeatureId } from "./types";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Feature configurations registry
|
|
10
|
-
*/
|
|
11
|
-
export const AI_FEATURE_CONFIGS: Record<AIFeatureId, AIFeatureConfig> = {
|
|
12
|
-
// Single image features
|
|
13
|
-
"anime-selfie": {
|
|
14
|
-
id: "anime-selfie",
|
|
15
|
-
mode: "single",
|
|
16
|
-
outputType: "image",
|
|
17
|
-
creditType: "image",
|
|
18
|
-
translationPrefix: "anime-selfie",
|
|
19
|
-
},
|
|
20
|
-
"remove-background": {
|
|
21
|
-
id: "remove-background",
|
|
22
|
-
mode: "single",
|
|
23
|
-
outputType: "image",
|
|
24
|
-
creditType: "image",
|
|
25
|
-
translationPrefix: "remove-background",
|
|
26
|
-
extraConfig: { featureType: "remove-background" },
|
|
27
|
-
},
|
|
28
|
-
"hd-touch-up": {
|
|
29
|
-
id: "hd-touch-up",
|
|
30
|
-
mode: "single",
|
|
31
|
-
outputType: "image",
|
|
32
|
-
creditType: "image",
|
|
33
|
-
translationPrefix: "hd-touch-up",
|
|
34
|
-
extraConfig: { featureType: "hd-touch-up" },
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
// Comparison result features
|
|
38
|
-
upscale: {
|
|
39
|
-
id: "upscale",
|
|
40
|
-
mode: "single",
|
|
41
|
-
outputType: "image",
|
|
42
|
-
creditType: "image",
|
|
43
|
-
translationPrefix: "upscale",
|
|
44
|
-
hasComparisonResult: true,
|
|
45
|
-
extraConfig: { featureType: "upscale", defaultScaleFactor: 2 },
|
|
46
|
-
},
|
|
47
|
-
"photo-restore": {
|
|
48
|
-
id: "photo-restore",
|
|
49
|
-
mode: "single",
|
|
50
|
-
outputType: "image",
|
|
51
|
-
creditType: "image",
|
|
52
|
-
translationPrefix: "photo-restore",
|
|
53
|
-
hasComparisonResult: true,
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
// Prompt features
|
|
57
|
-
"remove-object": {
|
|
58
|
-
id: "remove-object",
|
|
59
|
-
mode: "single-with-prompt",
|
|
60
|
-
outputType: "image",
|
|
61
|
-
creditType: "image",
|
|
62
|
-
translationPrefix: "remove-object",
|
|
63
|
-
},
|
|
64
|
-
"replace-background": {
|
|
65
|
-
id: "replace-background",
|
|
66
|
-
mode: "single-with-prompt",
|
|
67
|
-
outputType: "image",
|
|
68
|
-
creditType: "image",
|
|
69
|
-
translationPrefix: "replace-background",
|
|
70
|
-
extraConfig: { featureType: "replace-background" },
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
// Text-input features (no image upload)
|
|
74
|
-
"meme-generator": {
|
|
75
|
-
id: "meme-generator",
|
|
76
|
-
mode: "text-input",
|
|
77
|
-
outputType: "image",
|
|
78
|
-
creditType: "image",
|
|
79
|
-
translationPrefix: "meme-generator",
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
// Dual image features
|
|
83
|
-
"face-swap": {
|
|
84
|
-
id: "face-swap",
|
|
85
|
-
mode: "dual",
|
|
86
|
-
outputType: "image",
|
|
87
|
-
creditType: "image",
|
|
88
|
-
translationPrefix: "face-swap",
|
|
89
|
-
extraConfig: { featureType: "face-swap" },
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
// Dual image video features
|
|
93
|
-
"ai-hug": {
|
|
94
|
-
id: "ai-hug",
|
|
95
|
-
mode: "dual-video",
|
|
96
|
-
outputType: "video",
|
|
97
|
-
creditType: "image",
|
|
98
|
-
translationPrefix: "ai-hug",
|
|
99
|
-
},
|
|
100
|
-
"ai-kiss": {
|
|
101
|
-
id: "ai-kiss",
|
|
102
|
-
mode: "dual-video",
|
|
103
|
-
outputType: "video",
|
|
104
|
-
creditType: "image",
|
|
105
|
-
translationPrefix: "ai-kiss",
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// Generic Video Features
|
|
109
|
-
"image-to-video": {
|
|
110
|
-
id: "image-to-video",
|
|
111
|
-
mode: "single-with-prompt",
|
|
112
|
-
outputType: "video",
|
|
113
|
-
creditType: "video",
|
|
114
|
-
translationPrefix: "image-to-video",
|
|
115
|
-
},
|
|
116
|
-
"text-to-video": {
|
|
117
|
-
id: "text-to-video",
|
|
118
|
-
mode: "text-input",
|
|
119
|
-
outputType: "video",
|
|
120
|
-
creditType: "video",
|
|
121
|
-
translationPrefix: "text-to-video",
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get feature config by ID
|
|
127
|
-
*/
|
|
128
|
-
export function getAIFeatureConfig(featureId: AIFeatureId): AIFeatureConfig {
|
|
129
|
-
const config = AI_FEATURE_CONFIGS[featureId];
|
|
130
|
-
if (!config) {
|
|
131
|
-
throw new Error(`Unknown AI feature: ${featureId}`);
|
|
132
|
-
}
|
|
133
|
-
return config;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Check if feature exists
|
|
138
|
-
*/
|
|
139
|
-
export function hasAIFeature(featureId: string): featureId is AIFeatureId {
|
|
140
|
-
return featureId in AI_FEATURE_CONFIGS;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Get all feature IDs
|
|
145
|
-
*/
|
|
146
|
-
export function getAllAIFeatureIds(): AIFeatureId[] {
|
|
147
|
-
return Object.keys(AI_FEATURE_CONFIGS) as AIFeatureId[];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get features by mode
|
|
152
|
-
*/
|
|
153
|
-
export function getAIFeaturesByMode(mode: AIFeatureConfig["mode"]): AIFeatureConfig[] {
|
|
154
|
-
return Object.values(AI_FEATURE_CONFIGS).filter((config) => config.mode === mode);
|
|
155
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Feature Translations Factory
|
|
3
|
-
* Creates translation objects from prefix and t function
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { AIFeatureConfig } from "./types";
|
|
7
|
-
|
|
8
|
-
type TranslateFunction = (key: string) => string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Create single image translations
|
|
12
|
-
*/
|
|
13
|
-
export function createSingleImageTranslations(prefix: string, t: TranslateFunction) {
|
|
14
|
-
return {
|
|
15
|
-
uploadTitle: t(`${prefix}.uploadTitle`),
|
|
16
|
-
uploadSubtitle: t(`${prefix}.uploadSubtitle`),
|
|
17
|
-
uploadChange: t(`${prefix}.uploadChange`),
|
|
18
|
-
uploadAnalyzing: t(`${prefix}.uploadAnalyzing`),
|
|
19
|
-
description: t(`${prefix}.description`),
|
|
20
|
-
processingText: t(`${prefix}.processingText`),
|
|
21
|
-
processButtonText: t(`${prefix}.processButtonText`),
|
|
22
|
-
successText: t(`${prefix}.successText`),
|
|
23
|
-
saveButtonText: t(`${prefix}.saveButtonText`),
|
|
24
|
-
tryAnotherText: t(`${prefix}.tryAnotherText`),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Create comparison result translations (upscale, photo-restore)
|
|
30
|
-
*/
|
|
31
|
-
export function createComparisonTranslations(prefix: string, t: TranslateFunction) {
|
|
32
|
-
return {
|
|
33
|
-
...createSingleImageTranslations(prefix, t),
|
|
34
|
-
beforeLabel: t(`${prefix}.beforeLabel`),
|
|
35
|
-
afterLabel: t(`${prefix}.afterLabel`),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Create prompt feature translations (remove-object, replace-background)
|
|
41
|
-
*/
|
|
42
|
-
export function createPromptTranslations(prefix: string, t: TranslateFunction) {
|
|
43
|
-
return {
|
|
44
|
-
...createSingleImageTranslations(prefix, t),
|
|
45
|
-
promptPlaceholder: t(`${prefix}.promptPlaceholder`),
|
|
46
|
-
maskTitle: t(`${prefix}.maskTitle`),
|
|
47
|
-
maskSubtitle: t(`${prefix}.maskSubtitle`),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create text-input translations (text-to-image, meme-generator)
|
|
53
|
-
* For pure text-to-image features without image upload
|
|
54
|
-
*/
|
|
55
|
-
export function createTextInputTranslations(prefix: string, t: TranslateFunction) {
|
|
56
|
-
return {
|
|
57
|
-
title: t(`${prefix}.title`),
|
|
58
|
-
description: t(`${prefix}.description`),
|
|
59
|
-
promptPlaceholder: t(`${prefix}.promptPlaceholder`),
|
|
60
|
-
processButtonText: t(`${prefix}.processButtonText`),
|
|
61
|
-
processingText: t(`${prefix}.processingText`),
|
|
62
|
-
successText: t(`${prefix}.successText`),
|
|
63
|
-
saveButtonText: t(`${prefix}.saveButtonText`),
|
|
64
|
-
tryAnotherText: t(`${prefix}.tryAnotherText`),
|
|
65
|
-
styleLabel: t(`${prefix}.styleLabel`),
|
|
66
|
-
tipsLabel: t(`${prefix}.tipsLabel`),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Create dual image translations (face-swap, ai-hug, ai-kiss)
|
|
72
|
-
*/
|
|
73
|
-
export function createDualImageTranslations(prefix: string, t: TranslateFunction) {
|
|
74
|
-
return {
|
|
75
|
-
sourceUploadTitle: t(`${prefix}.sourceUploadTitle`),
|
|
76
|
-
sourceUploadSubtitle: t(`${prefix}.sourceUploadSubtitle`),
|
|
77
|
-
targetUploadTitle: t(`${prefix}.targetUploadTitle`),
|
|
78
|
-
targetUploadSubtitle: t(`${prefix}.targetUploadSubtitle`),
|
|
79
|
-
uploadChange: t(`${prefix}.uploadChange`),
|
|
80
|
-
uploadAnalyzing: t(`${prefix}.uploadAnalyzing`),
|
|
81
|
-
description: t(`${prefix}.description`),
|
|
82
|
-
processingText: t(`${prefix}.processingText`),
|
|
83
|
-
processButtonText: t(`${prefix}.processButtonText`),
|
|
84
|
-
successText: t(`${prefix}.successText`),
|
|
85
|
-
saveButtonText: t(`${prefix}.saveButtonText`),
|
|
86
|
-
tryAnotherText: t(`${prefix}.tryAnotherText`),
|
|
87
|
-
modalTitle: t(`${prefix}.modalTitle`),
|
|
88
|
-
modalMessage: t(`${prefix}.modalMessage`),
|
|
89
|
-
modalHint: t(`${prefix}.modalHint`),
|
|
90
|
-
modalBackgroundHint: t(`${prefix}.modalBackgroundHint`),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Create translations based on feature config
|
|
96
|
-
*/
|
|
97
|
-
export function createFeatureTranslations(config: AIFeatureConfig, t: TranslateFunction) {
|
|
98
|
-
const { translationPrefix, mode, hasComparisonResult } = config;
|
|
99
|
-
|
|
100
|
-
switch (mode) {
|
|
101
|
-
case "single":
|
|
102
|
-
return hasComparisonResult
|
|
103
|
-
? createComparisonTranslations(translationPrefix, t)
|
|
104
|
-
: createSingleImageTranslations(translationPrefix, t);
|
|
105
|
-
case "single-with-prompt":
|
|
106
|
-
return createPromptTranslations(translationPrefix, t);
|
|
107
|
-
case "text-input":
|
|
108
|
-
return createTextInputTranslations(translationPrefix, t);
|
|
109
|
-
case "dual":
|
|
110
|
-
case "dual-video":
|
|
111
|
-
return createDualImageTranslations(translationPrefix, t);
|
|
112
|
-
default:
|
|
113
|
-
return createSingleImageTranslations(translationPrefix, t);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AIFeatureScreen Types
|
|
3
|
-
* Unified type definitions for all AI feature screens
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ReactNode } from "react";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* All supported AI feature types
|
|
10
|
-
*/
|
|
11
|
-
export type AIFeatureId =
|
|
12
|
-
| "anime-selfie"
|
|
13
|
-
| "remove-background"
|
|
14
|
-
| "hd-touch-up"
|
|
15
|
-
| "upscale"
|
|
16
|
-
| "photo-restore"
|
|
17
|
-
| "remove-object"
|
|
18
|
-
| "replace-background"
|
|
19
|
-
| "face-swap"
|
|
20
|
-
| "ai-hug"
|
|
21
|
-
| "ai-kiss"
|
|
22
|
-
| "meme-generator"
|
|
23
|
-
| "image-to-video"
|
|
24
|
-
| "text-to-video";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Image mode for the feature
|
|
28
|
-
*/
|
|
29
|
-
export type AIFeatureMode = "single" | "single-with-prompt" | "dual" | "dual-video" | "text-input";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Output type of the feature
|
|
33
|
-
*/
|
|
34
|
-
export type AIFeatureOutputType = "image" | "video";
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Credit type for the feature
|
|
38
|
-
*/
|
|
39
|
-
export type AIFeatureCreditType = "image" | "video";
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Translation keys structure for single image features
|
|
43
|
-
*/
|
|
44
|
-
export interface SingleImageTranslationKeys {
|
|
45
|
-
uploadTitle: string;
|
|
46
|
-
uploadSubtitle: string;
|
|
47
|
-
uploadChange: string;
|
|
48
|
-
uploadAnalyzing: string;
|
|
49
|
-
description: string;
|
|
50
|
-
processingText: string;
|
|
51
|
-
processButtonText: string;
|
|
52
|
-
successText: string;
|
|
53
|
-
saveButtonText: string;
|
|
54
|
-
tryAnotherText: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Translation keys structure for comparison result features (upscale, photo-restore)
|
|
59
|
-
*/
|
|
60
|
-
export interface ComparisonTranslationKeys extends SingleImageTranslationKeys {
|
|
61
|
-
beforeLabel: string;
|
|
62
|
-
afterLabel: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Translation keys structure for prompt features (remove-object, replace-background)
|
|
67
|
-
*/
|
|
68
|
-
export interface PromptTranslationKeys extends SingleImageTranslationKeys {
|
|
69
|
-
promptPlaceholder: string;
|
|
70
|
-
maskTitle?: string;
|
|
71
|
-
maskSubtitle?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Translation keys structure for dual image features
|
|
76
|
-
*/
|
|
77
|
-
export interface DualImageTranslationKeys {
|
|
78
|
-
sourceUploadTitle: string;
|
|
79
|
-
sourceUploadSubtitle: string;
|
|
80
|
-
targetUploadTitle: string;
|
|
81
|
-
targetUploadSubtitle: string;
|
|
82
|
-
uploadChange: string;
|
|
83
|
-
uploadAnalyzing: string;
|
|
84
|
-
description: string;
|
|
85
|
-
processingText: string;
|
|
86
|
-
processButtonText: string;
|
|
87
|
-
successText: string;
|
|
88
|
-
saveButtonText: string;
|
|
89
|
-
tryAnotherText: string;
|
|
90
|
-
modalTitle?: string;
|
|
91
|
-
modalMessage?: string;
|
|
92
|
-
modalHint?: string;
|
|
93
|
-
modalBackgroundHint?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Translation keys structure for text-input features (text-to-image, meme-generator)
|
|
98
|
-
*/
|
|
99
|
-
export interface TextInputTranslationKeys {
|
|
100
|
-
title: string;
|
|
101
|
-
description: string;
|
|
102
|
-
promptPlaceholder: string;
|
|
103
|
-
processButtonText: string;
|
|
104
|
-
processingText: string;
|
|
105
|
-
successText: string;
|
|
106
|
-
saveButtonText: string;
|
|
107
|
-
tryAnotherText: string;
|
|
108
|
-
styleLabel?: string;
|
|
109
|
-
tipsLabel?: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Static feature configuration (doesn't change at runtime)
|
|
114
|
-
*/
|
|
115
|
-
export interface AIFeatureConfig {
|
|
116
|
-
/** Unique feature identifier */
|
|
117
|
-
readonly id: AIFeatureId;
|
|
118
|
-
/** Feature mode: single image, dual image, etc. */
|
|
119
|
-
readonly mode: AIFeatureMode;
|
|
120
|
-
/** Output type: image or video */
|
|
121
|
-
readonly outputType: AIFeatureOutputType;
|
|
122
|
-
/** Credit type to deduct */
|
|
123
|
-
readonly creditType: AIFeatureCreditType;
|
|
124
|
-
/** Translation key prefix (e.g., "anime-selfie" for t("anime-selfie.uploadTitle")) */
|
|
125
|
-
readonly translationPrefix: string;
|
|
126
|
-
/** Whether this feature has comparison result (before/after slider) */
|
|
127
|
-
readonly hasComparisonResult?: boolean;
|
|
128
|
-
/** Feature-specific extra config */
|
|
129
|
-
readonly extraConfig?: Record<string, unknown>;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Runtime props for AIFeatureScreen
|
|
134
|
-
*/
|
|
135
|
-
export interface AIFeatureScreenProps {
|
|
136
|
-
/** Feature configuration from registry */
|
|
137
|
-
readonly config: AIFeatureConfig;
|
|
138
|
-
/** Credit cost for this feature */
|
|
139
|
-
readonly creditCost: number;
|
|
140
|
-
/** Deduct credits callback */
|
|
141
|
-
readonly onDeductCredits: (cost: number) => Promise<void | boolean>;
|
|
142
|
-
/** Select image callback */
|
|
143
|
-
readonly onSelectImage: () => Promise<string | null>;
|
|
144
|
-
/** Save media callback */
|
|
145
|
-
readonly onSaveMedia: (url: string) => Promise<void>;
|
|
146
|
-
/** Credit guard check callback */
|
|
147
|
-
readonly onCheckCreditGuard: (cost: number, featureName: string) => Promise<boolean>;
|
|
148
|
-
/** Current image credits count */
|
|
149
|
-
readonly imageCredits: number;
|
|
150
|
-
/** Custom header right content */
|
|
151
|
-
readonly headerRightContent?: ReactNode;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Feature registry entry with component
|
|
156
|
-
*/
|
|
157
|
-
export interface AIFeatureRegistryEntry extends AIFeatureConfig {
|
|
158
|
-
/** The Feature component to render */
|
|
159
|
-
readonly Component: React.ComponentType<unknown>;
|
|
160
|
-
}
|