@umituz/react-native-ai-generation-content 1.17.9 → 1.17.11

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 (41) hide show
  1. package/package.json +1 -1
  2. package/src/features/hd-touch-up/domain/index.ts +1 -0
  3. package/src/features/hd-touch-up/domain/types/hd-touch-up.types.ts +69 -0
  4. package/src/features/hd-touch-up/domain/types/index.ts +10 -0
  5. package/src/features/hd-touch-up/index.ts +31 -0
  6. package/src/features/hd-touch-up/infrastructure/index.ts +1 -0
  7. package/src/features/hd-touch-up/infrastructure/services/hd-touch-up-executor.ts +97 -0
  8. package/src/features/hd-touch-up/infrastructure/services/index.ts +2 -0
  9. package/src/features/hd-touch-up/presentation/components/HDTouchUpFeature.tsx +199 -0
  10. package/src/features/hd-touch-up/presentation/components/index.ts +2 -0
  11. package/src/features/hd-touch-up/presentation/hooks/index.ts +5 -0
  12. package/src/features/hd-touch-up/presentation/hooks/useHDTouchUpFeature.ts +137 -0
  13. package/src/features/hd-touch-up/presentation/index.ts +2 -0
  14. package/src/features/photo-restoration/presentation/components/PhotoRestoreResultView.tsx +1 -1
  15. package/src/index.ts +7 -1
  16. /package/src/features/{background → replace-background}/domain/entities/background.types.ts +0 -0
  17. /package/src/features/{background → replace-background}/domain/entities/component.types.ts +0 -0
  18. /package/src/features/{background → replace-background}/domain/entities/config.types.ts +0 -0
  19. /package/src/features/{background → replace-background}/domain/entities/index.ts +0 -0
  20. /package/src/features/{background → replace-background}/domain/types/index.ts +0 -0
  21. /package/src/features/{background → replace-background}/domain/types/replace-background.types.ts +0 -0
  22. /package/src/features/{background → replace-background}/index.ts +0 -0
  23. /package/src/features/{background → replace-background}/infrastructure/constants/index.ts +0 -0
  24. /package/src/features/{background → replace-background}/infrastructure/constants/prompts.constants.ts +0 -0
  25. /package/src/features/{background → replace-background}/infrastructure/index.ts +0 -0
  26. /package/src/features/{background → replace-background}/infrastructure/services/index.ts +0 -0
  27. /package/src/features/{background → replace-background}/infrastructure/services/replace-background-executor.ts +0 -0
  28. /package/src/features/{background → replace-background}/presentation/components/BackgroundFeature.tsx +0 -0
  29. /package/src/features/{background → replace-background}/presentation/components/ComparisonSlider.tsx +0 -0
  30. /package/src/features/{background → replace-background}/presentation/components/ErrorDisplay.tsx +0 -0
  31. /package/src/features/{background → replace-background}/presentation/components/FeatureHeader.tsx +0 -0
  32. /package/src/features/{background → replace-background}/presentation/components/GenerateButton.tsx +0 -0
  33. /package/src/features/{background → replace-background}/presentation/components/ImagePicker.tsx +0 -0
  34. /package/src/features/{background → replace-background}/presentation/components/ModeSelector.tsx +0 -0
  35. /package/src/features/{background → replace-background}/presentation/components/ProcessingModal.tsx +0 -0
  36. /package/src/features/{background → replace-background}/presentation/components/PromptInput.tsx +0 -0
  37. /package/src/features/{background → replace-background}/presentation/components/ResultDisplay.tsx +0 -0
  38. /package/src/features/{background → replace-background}/presentation/components/index.ts +0 -0
  39. /package/src/features/{background → replace-background}/presentation/hooks/index.ts +0 -0
  40. /package/src/features/{background → replace-background}/presentation/hooks/useBackgroundFeature.ts +0 -0
  41. /package/src/features/{background → replace-background}/presentation/hooks/useReplaceBackgroundFeature.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.17.9",
3
+ "version": "1.17.11",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1,69 @@
1
+ /**
2
+ * HD Touch Up Feature Types
3
+ * Request, Result, Config types for HD enhancement
4
+ */
5
+
6
+ export interface HDTouchUpOptions {
7
+ enhanceQuality?: boolean;
8
+ upscaleFactor?: 2 | 4;
9
+ sharpen?: boolean;
10
+ }
11
+
12
+ export interface HDTouchUpRequest {
13
+ imageUri: string;
14
+ imageBase64?: string;
15
+ userId: string;
16
+ options?: HDTouchUpOptions;
17
+ }
18
+
19
+ export interface HDTouchUpResult {
20
+ success: boolean;
21
+ imageUrl?: string;
22
+ imageBase64?: string;
23
+ error?: string;
24
+ requestId?: string;
25
+ }
26
+
27
+ export interface HDTouchUpFeatureState {
28
+ imageUri: string | null;
29
+ processedUrl: string | null;
30
+ isProcessing: boolean;
31
+ progress: number;
32
+ error: string | null;
33
+ }
34
+
35
+ export interface HDTouchUpTranslations {
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
+ }
50
+
51
+ export type HDTouchUpInputBuilder = (
52
+ base64: string,
53
+ options?: HDTouchUpOptions,
54
+ ) => Record<string, unknown>;
55
+
56
+ export type HDTouchUpResultExtractor = (result: unknown) => string | undefined;
57
+
58
+ export interface HDTouchUpFeatureConfig {
59
+ providerId?: string;
60
+ creditCost?: number;
61
+ model: string;
62
+ buildInput: HDTouchUpInputBuilder;
63
+ extractResult?: HDTouchUpResultExtractor;
64
+ prepareImage: (imageUri: string) => Promise<string>;
65
+ onImageSelect?: (uri: string) => void;
66
+ onProcessingStart?: () => void;
67
+ onProcessingComplete?: (result: HDTouchUpResult) => void;
68
+ onError?: (error: string) => void;
69
+ }
@@ -0,0 +1,10 @@
1
+ export type {
2
+ HDTouchUpOptions,
3
+ HDTouchUpRequest,
4
+ HDTouchUpResult,
5
+ HDTouchUpFeatureState,
6
+ HDTouchUpTranslations,
7
+ HDTouchUpInputBuilder,
8
+ HDTouchUpResultExtractor,
9
+ HDTouchUpFeatureConfig,
10
+ } from "./hd-touch-up.types";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * HD Touch Up Feature
3
+ * Provider-agnostic HD enhancement feature
4
+ */
5
+
6
+ // Domain Types
7
+ export type {
8
+ HDTouchUpOptions,
9
+ HDTouchUpRequest,
10
+ HDTouchUpResult,
11
+ HDTouchUpFeatureState,
12
+ HDTouchUpTranslations,
13
+ HDTouchUpFeatureConfig,
14
+ HDTouchUpInputBuilder,
15
+ HDTouchUpResultExtractor,
16
+ } from "./domain";
17
+
18
+ // Infrastructure Services
19
+ export { executeHDTouchUp, hasHDTouchUpSupport } from "./infrastructure";
20
+ export type { ExecuteHDTouchUpOptions } from "./infrastructure";
21
+
22
+ // Presentation Hooks
23
+ export { useHDTouchUpFeature } from "./presentation";
24
+ export type {
25
+ UseHDTouchUpFeatureProps,
26
+ UseHDTouchUpFeatureReturn,
27
+ } from "./presentation";
28
+
29
+ // Presentation Components
30
+ export { HDTouchUpFeature } from "./presentation";
31
+ export type { HDTouchUpFeatureProps } from "./presentation";
@@ -0,0 +1 @@
1
+ export * from "./services";
@@ -0,0 +1,97 @@
1
+ /**
2
+ * HD Touch Up Executor
3
+ * Executes HD enhancement using the configured provider
4
+ */
5
+
6
+ import { providerRegistry } from "../../../../infrastructure/services";
7
+ import type {
8
+ HDTouchUpRequest,
9
+ HDTouchUpResult,
10
+ HDTouchUpInputBuilder,
11
+ HDTouchUpResultExtractor,
12
+ } from "../../domain/types";
13
+
14
+ declare const __DEV__: boolean;
15
+
16
+ export interface ExecuteHDTouchUpOptions {
17
+ model: string;
18
+ buildInput: HDTouchUpInputBuilder;
19
+ extractResult?: HDTouchUpResultExtractor;
20
+ onProgress?: (progress: number) => void;
21
+ }
22
+
23
+ export async function executeHDTouchUp(
24
+ request: HDTouchUpRequest,
25
+ options: ExecuteHDTouchUpOptions,
26
+ ): Promise<HDTouchUpResult> {
27
+ const { model, buildInput, extractResult, onProgress } = options;
28
+
29
+ try {
30
+ const provider = providerRegistry.getActiveProvider();
31
+ if (!provider) {
32
+ return {
33
+ success: false,
34
+ error: "No AI provider configured",
35
+ };
36
+ }
37
+
38
+ if (__DEV__) {
39
+ // eslint-disable-next-line no-console
40
+ console.log("[HDTouchUp] Starting HD enhancement with model:", model);
41
+ }
42
+
43
+ onProgress?.(10);
44
+
45
+ const imageBase64 = request.imageBase64;
46
+ if (!imageBase64) {
47
+ return {
48
+ success: false,
49
+ error: "Image base64 is required",
50
+ };
51
+ }
52
+
53
+ const input = buildInput(imageBase64, request.options);
54
+
55
+ onProgress?.(30);
56
+
57
+ const result = await provider.generate(model, input, request.userId);
58
+
59
+ onProgress?.(80);
60
+
61
+ const imageUrl = extractResult
62
+ ? extractResult(result)
63
+ : (result as { imageUrl?: string })?.imageUrl ||
64
+ (result as { image?: string })?.image ||
65
+ (result as { output?: string })?.output;
66
+
67
+ onProgress?.(100);
68
+
69
+ if (imageUrl) {
70
+ return {
71
+ success: true,
72
+ imageUrl,
73
+ requestId: (result as { requestId?: string })?.requestId,
74
+ };
75
+ }
76
+
77
+ return {
78
+ success: false,
79
+ error: "No image URL in response",
80
+ };
81
+ } catch (error) {
82
+ const message = error instanceof Error ? error.message : String(error);
83
+ if (__DEV__) {
84
+ // eslint-disable-next-line no-console
85
+ console.error("[HDTouchUp] Error:", message);
86
+ }
87
+ return {
88
+ success: false,
89
+ error: message,
90
+ };
91
+ }
92
+ }
93
+
94
+ export function hasHDTouchUpSupport(): boolean {
95
+ const provider = providerRegistry.getActiveProvider();
96
+ return !!provider;
97
+ }
@@ -0,0 +1,2 @@
1
+ export { executeHDTouchUp, hasHDTouchUpSupport } from "./hd-touch-up-executor";
2
+ export type { ExecuteHDTouchUpOptions } from "./hd-touch-up-executor";
@@ -0,0 +1,199 @@
1
+ /**
2
+ * HDTouchUpFeature Component
3
+ * Self-contained HD touch up feature UI component
4
+ * Uses hook internally, only requires config and translations
5
+ */
6
+
7
+ import React, { useCallback, useMemo } from "react";
8
+ import { View, ScrollView, StyleSheet, Image, Dimensions } from "react-native";
9
+ import {
10
+ useAppDesignTokens,
11
+ AtomicText,
12
+ AtomicButton,
13
+ } from "@umituz/react-native-design-system";
14
+ import { PhotoUploadCard } from "../../../../presentation/components/PhotoUploadCard";
15
+ import { ErrorDisplay } from "../../../../presentation/components/display/ErrorDisplay";
16
+ import { useHDTouchUpFeature } from "../hooks";
17
+ import type {
18
+ HDTouchUpTranslations,
19
+ HDTouchUpFeatureConfig,
20
+ } from "../../domain/types";
21
+
22
+ export interface HDTouchUpFeatureProps {
23
+ config: HDTouchUpFeatureConfig;
24
+ userId: string;
25
+ translations: HDTouchUpTranslations;
26
+ onSelectImage: () => Promise<string | null>;
27
+ onSaveImage: (imageUrl: string) => Promise<void>;
28
+ renderProcessingModal?: (props: {
29
+ visible: boolean;
30
+ progress: number;
31
+ }) => React.ReactNode;
32
+ }
33
+
34
+ export const HDTouchUpFeature: React.FC<HDTouchUpFeatureProps> = ({
35
+ config,
36
+ userId,
37
+ translations,
38
+ onSelectImage,
39
+ onSaveImage,
40
+ renderProcessingModal,
41
+ }) => {
42
+ const tokens = useAppDesignTokens();
43
+
44
+ const feature = useHDTouchUpFeature({
45
+ config,
46
+ userId,
47
+ onSelectImage,
48
+ onSaveImage,
49
+ });
50
+
51
+ const photoTranslations = useMemo(
52
+ () => ({
53
+ tapToUpload: translations.uploadTitle,
54
+ selectPhoto: translations.uploadSubtitle,
55
+ change: translations.uploadChange,
56
+ analyzing: translations.uploadAnalyzing,
57
+ }),
58
+ [translations],
59
+ );
60
+
61
+ const handleProcess = useCallback(() => {
62
+ void feature.process();
63
+ }, [feature]);
64
+
65
+ const handleSave = useCallback(() => {
66
+ void feature.save();
67
+ }, [feature]);
68
+
69
+ const handleSelectImage = useCallback(() => {
70
+ void feature.selectImage();
71
+ }, [feature]);
72
+
73
+ if (feature.processedUrl) {
74
+ const screenWidth = Dimensions.get("window").width;
75
+ const imageSize = screenWidth - 48;
76
+
77
+ return (
78
+ <ScrollView
79
+ style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}
80
+ contentContainerStyle={styles.content}
81
+ showsVerticalScrollIndicator={false}
82
+ >
83
+ <AtomicText
84
+ type="headlineMedium"
85
+ style={[styles.successText, { color: tokens.colors.success }]}
86
+ >
87
+ {translations.successText}
88
+ </AtomicText>
89
+
90
+ <View style={styles.resultImageContainer}>
91
+ <Image
92
+ source={{ uri: feature.processedUrl }}
93
+ style={[styles.resultImage, { width: imageSize, height: imageSize }]}
94
+ resizeMode="contain"
95
+ />
96
+ </View>
97
+
98
+ <View style={styles.resultActions}>
99
+ <AtomicButton
100
+ title={translations.saveButtonText}
101
+ onPress={handleSave}
102
+ variant="primary"
103
+ size="lg"
104
+ />
105
+ <AtomicButton
106
+ title={translations.tryAnotherText}
107
+ onPress={feature.reset}
108
+ variant="secondary"
109
+ size="lg"
110
+ />
111
+ </View>
112
+ </ScrollView>
113
+ );
114
+ }
115
+
116
+ return (
117
+ <>
118
+ <ScrollView
119
+ style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}
120
+ contentContainerStyle={styles.content}
121
+ showsVerticalScrollIndicator={false}
122
+ >
123
+ <AtomicText
124
+ type="bodyLarge"
125
+ style={[styles.description, { color: tokens.colors.textSecondary }]}
126
+ >
127
+ {translations.description}
128
+ </AtomicText>
129
+
130
+ <PhotoUploadCard
131
+ imageUri={feature.imageUri}
132
+ onPress={handleSelectImage}
133
+ isValidating={feature.isProcessing}
134
+ disabled={feature.isProcessing}
135
+ translations={photoTranslations}
136
+ config={{
137
+ aspectRatio: 1,
138
+ borderRadius: 24,
139
+ showValidationStatus: false,
140
+ allowChange: true,
141
+ }}
142
+ />
143
+
144
+ <ErrorDisplay error={feature.error} />
145
+
146
+ <View style={styles.buttonContainer}>
147
+ <AtomicButton
148
+ title={
149
+ feature.isProcessing
150
+ ? translations.processingText
151
+ : translations.processButtonText
152
+ }
153
+ onPress={handleProcess}
154
+ disabled={!feature.imageUri || feature.isProcessing}
155
+ variant="primary"
156
+ size="lg"
157
+ />
158
+ </View>
159
+ </ScrollView>
160
+
161
+ {renderProcessingModal?.({ visible: feature.isProcessing, progress: feature.progress })}
162
+ </>
163
+ );
164
+ };
165
+
166
+ const styles = StyleSheet.create({
167
+ container: {
168
+ flex: 1,
169
+ },
170
+ content: {
171
+ paddingVertical: 16,
172
+ },
173
+ description: {
174
+ textAlign: "center",
175
+ marginHorizontal: 24,
176
+ marginBottom: 24,
177
+ lineHeight: 24,
178
+ },
179
+ successText: {
180
+ textAlign: "center",
181
+ marginBottom: 24,
182
+ },
183
+ resultImageContainer: {
184
+ alignItems: "center",
185
+ marginHorizontal: 24,
186
+ marginBottom: 24,
187
+ },
188
+ resultImage: {
189
+ borderRadius: 16,
190
+ },
191
+ resultActions: {
192
+ marginHorizontal: 24,
193
+ gap: 12,
194
+ },
195
+ buttonContainer: {
196
+ marginHorizontal: 24,
197
+ marginTop: 8,
198
+ },
199
+ });
@@ -0,0 +1,2 @@
1
+ export { HDTouchUpFeature } from "./HDTouchUpFeature";
2
+ export type { HDTouchUpFeatureProps } from "./HDTouchUpFeature";
@@ -0,0 +1,5 @@
1
+ export { useHDTouchUpFeature } from "./useHDTouchUpFeature";
2
+ export type {
3
+ UseHDTouchUpFeatureProps,
4
+ UseHDTouchUpFeatureReturn,
5
+ } from "./useHDTouchUpFeature";
@@ -0,0 +1,137 @@
1
+ /**
2
+ * useHDTouchUpFeature Hook
3
+ * Manages HD touch up feature state and actions
4
+ */
5
+
6
+ import { useState, useCallback } from "react";
7
+ import { executeHDTouchUp } from "../../infrastructure/services";
8
+ import type {
9
+ HDTouchUpFeatureState,
10
+ HDTouchUpFeatureConfig,
11
+ HDTouchUpResult,
12
+ } from "../../domain/types";
13
+
14
+ declare const __DEV__: boolean;
15
+
16
+ export interface UseHDTouchUpFeatureProps {
17
+ config: HDTouchUpFeatureConfig;
18
+ userId: string;
19
+ onSelectImage: () => Promise<string | null>;
20
+ onSaveImage: (imageUrl: string) => Promise<void>;
21
+ }
22
+
23
+ export interface UseHDTouchUpFeatureReturn extends HDTouchUpFeatureState {
24
+ selectImage: () => Promise<void>;
25
+ process: () => Promise<void>;
26
+ save: () => Promise<void>;
27
+ reset: () => void;
28
+ }
29
+
30
+ const initialState: HDTouchUpFeatureState = {
31
+ imageUri: null,
32
+ processedUrl: null,
33
+ isProcessing: false,
34
+ progress: 0,
35
+ error: null,
36
+ };
37
+
38
+ export function useHDTouchUpFeature(
39
+ props: UseHDTouchUpFeatureProps,
40
+ ): UseHDTouchUpFeatureReturn {
41
+ const { config, userId, onSelectImage, onSaveImage } = props;
42
+ const [state, setState] = useState<HDTouchUpFeatureState>(initialState);
43
+
44
+ const selectImage = useCallback(async () => {
45
+ try {
46
+ const uri = await onSelectImage();
47
+ if (uri) {
48
+ setState((prev) => ({ ...prev, imageUri: uri, error: null }));
49
+ config.onImageSelect?.(uri);
50
+ }
51
+ } catch (error) {
52
+ const message = error instanceof Error ? error.message : String(error);
53
+ setState((prev) => ({ ...prev, error: message }));
54
+ }
55
+ }, [onSelectImage, config]);
56
+
57
+ const handleProgress = useCallback((progress: number) => {
58
+ setState((prev) => ({ ...prev, progress }));
59
+ }, []);
60
+
61
+ const process = useCallback(async () => {
62
+ if (!state.imageUri) return;
63
+
64
+ setState((prev) => ({
65
+ ...prev,
66
+ isProcessing: true,
67
+ progress: 0,
68
+ error: null,
69
+ }));
70
+
71
+ config.onProcessingStart?.();
72
+
73
+ if (__DEV__) {
74
+ // eslint-disable-next-line no-console
75
+ console.log("[useHDTouchUpFeature] Starting HD enhancement");
76
+ }
77
+
78
+ const imageBase64 = await config.prepareImage(state.imageUri);
79
+
80
+ const result: HDTouchUpResult = await executeHDTouchUp(
81
+ {
82
+ imageUri: state.imageUri,
83
+ imageBase64,
84
+ userId,
85
+ },
86
+ {
87
+ model: config.model,
88
+ buildInput: config.buildInput,
89
+ extractResult: config.extractResult,
90
+ onProgress: handleProgress,
91
+ },
92
+ );
93
+
94
+ if (result.success && result.imageUrl) {
95
+ const url = result.imageUrl;
96
+ setState((prev) => ({
97
+ ...prev,
98
+ isProcessing: false,
99
+ processedUrl: url,
100
+ progress: 100,
101
+ }));
102
+ config.onProcessingComplete?.(result);
103
+ } else {
104
+ const errorMessage = result.error || "Processing failed";
105
+ setState((prev) => ({
106
+ ...prev,
107
+ isProcessing: false,
108
+ error: errorMessage,
109
+ progress: 0,
110
+ }));
111
+ config.onError?.(errorMessage);
112
+ }
113
+ }, [state.imageUri, userId, config, handleProgress]);
114
+
115
+ const save = useCallback(async () => {
116
+ if (!state.processedUrl) return;
117
+
118
+ try {
119
+ await onSaveImage(state.processedUrl);
120
+ } catch (error) {
121
+ const message = error instanceof Error ? error.message : String(error);
122
+ setState((prev) => ({ ...prev, error: message }));
123
+ }
124
+ }, [state.processedUrl, onSaveImage]);
125
+
126
+ const reset = useCallback(() => {
127
+ setState(initialState);
128
+ }, []);
129
+
130
+ return {
131
+ ...state,
132
+ selectImage,
133
+ process,
134
+ save,
135
+ reset,
136
+ };
137
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./hooks";
2
+ export * from "./components";
@@ -10,7 +10,7 @@ import {
10
10
  AtomicButton,
11
11
  useAppDesignTokens,
12
12
  } from "@umituz/react-native-design-system";
13
- import { ComparisonSlider } from "../../../background/presentation/components/ComparisonSlider";
13
+ import { ComparisonSlider } from "../../../replace-background/presentation/components/ComparisonSlider";
14
14
  import type { PhotoRestoreTranslations } from "../../domain/types";
15
15
 
16
16
  export interface PhotoRestoreResultViewProps {
package/src/index.ts CHANGED
@@ -329,7 +329,7 @@ export * from "./domains/face-detection";
329
329
  // FEATURES - Background
330
330
  // =============================================================================
331
331
 
332
- export * from "./features/background";
332
+ export * from "./features/replace-background";
333
333
 
334
334
  // =============================================================================
335
335
  // FEATURES - Upscaling
@@ -403,3 +403,9 @@ export * from "./features/image-to-video";
403
403
 
404
404
  export * from "./features/text-to-voice";
405
405
 
406
+ // =============================================================================
407
+ // FEATURES - HD Touch Up
408
+ // =============================================================================
409
+
410
+ export * from "./features/hd-touch-up";
411
+