@umituz/react-native-ai-generation-content 1.12.23 → 1.12.24

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 (60) hide show
  1. package/package.json +1 -1
  2. package/src/features/audio-generation/domain/entities.ts +39 -0
  3. package/src/features/audio-generation/index.ts +2 -0
  4. package/src/features/audio-generation/presentation/hooks.ts +39 -0
  5. package/src/features/colorization/domain/entities.ts +46 -0
  6. package/src/features/colorization/index.ts +2 -0
  7. package/src/features/colorization/presentation/hooks.ts +39 -0
  8. package/src/features/face-swap/domain/entities.ts +48 -0
  9. package/src/features/face-swap/index.ts +2 -0
  10. package/src/features/face-swap/presentation/hooks.ts +41 -0
  11. package/src/features/future-prediction/domain/entities.ts +45 -0
  12. package/src/features/future-prediction/index.ts +2 -0
  13. package/src/features/future-prediction/presentation/hooks.ts +39 -0
  14. package/src/features/image-captioning/domain/entities.ts +47 -0
  15. package/src/features/image-captioning/index.ts +2 -0
  16. package/src/features/image-captioning/presentation/hooks.ts +39 -0
  17. package/src/features/inpainting/domain/entities.ts +58 -0
  18. package/src/features/inpainting/index.ts +2 -0
  19. package/src/features/inpainting/presentation/hooks.ts +39 -0
  20. package/src/features/photo-restoration/domain/entities.ts +48 -0
  21. package/src/features/photo-restoration/index.ts +2 -0
  22. package/src/features/photo-restoration/presentation/hooks.ts +39 -0
  23. package/src/features/sketch-to-image/domain/entities.ts +47 -0
  24. package/src/features/sketch-to-image/index.ts +2 -0
  25. package/src/features/sketch-to-image/presentation/hooks.ts +39 -0
  26. package/src/features/style-transfer/domain/entities.ts +52 -0
  27. package/src/features/style-transfer/index.ts +2 -0
  28. package/src/features/style-transfer/presentation/hooks.ts +39 -0
  29. package/src/features/text-to-image/domain/entities.ts +58 -0
  30. package/src/features/text-to-image/index.ts +2 -0
  31. package/src/features/text-to-image/presentation/hooks.ts +39 -0
  32. package/src/features/text-to-video/domain/entities.ts +52 -0
  33. package/src/features/text-to-video/index.ts +2 -0
  34. package/src/features/text-to-video/presentation/hooks.ts +39 -0
  35. package/src/features/upscaling/domain/entities.ts +42 -0
  36. package/src/features/upscaling/index.ts +2 -0
  37. package/src/features/upscaling/presentation/hooks.ts +39 -0
  38. package/src/index.ts +3 -1
  39. package/src/presentation/hooks/photo-generation.types.ts +9 -0
  40. package/src/presentation/hooks/usePhotoGeneration.ts +12 -0
  41. /package/src/{domains/feature-background → features/background}/domain/entities/background.types.ts +0 -0
  42. /package/src/{domains/feature-background → features/background}/domain/entities/component.types.ts +0 -0
  43. /package/src/{domains/feature-background → features/background}/domain/entities/config.types.ts +0 -0
  44. /package/src/{domains/feature-background → features/background}/domain/entities/index.ts +0 -0
  45. /package/src/{domains/feature-background → features/background}/index.ts +0 -0
  46. /package/src/{domains/feature-background → features/background}/infrastructure/constants/index.ts +0 -0
  47. /package/src/{domains/feature-background → features/background}/infrastructure/constants/prompts.constants.ts +0 -0
  48. /package/src/{domains/feature-background → features/background}/presentation/components/BackgroundFeature.tsx +0 -0
  49. /package/src/{domains/feature-background → features/background}/presentation/components/ComparisonSlider.tsx +0 -0
  50. /package/src/{domains/feature-background → features/background}/presentation/components/ErrorDisplay.tsx +0 -0
  51. /package/src/{domains/feature-background → features/background}/presentation/components/FeatureHeader.tsx +0 -0
  52. /package/src/{domains/feature-background → features/background}/presentation/components/GenerateButton.tsx +0 -0
  53. /package/src/{domains/feature-background → features/background}/presentation/components/ImagePicker.tsx +0 -0
  54. /package/src/{domains/feature-background → features/background}/presentation/components/ModeSelector.tsx +0 -0
  55. /package/src/{domains/feature-background → features/background}/presentation/components/ProcessingModal.tsx +0 -0
  56. /package/src/{domains/feature-background → features/background}/presentation/components/PromptInput.tsx +0 -0
  57. /package/src/{domains/feature-background → features/background}/presentation/components/ResultDisplay.tsx +0 -0
  58. /package/src/{domains/feature-background → features/background}/presentation/components/index.ts +0 -0
  59. /package/src/{domains/feature-background → features/background}/presentation/hooks/index.ts +0 -0
  60. /package/src/{domains/feature-background → features/background}/presentation/hooks/useBackgroundFeature.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.12.23",
3
+ "version": "1.12.24",
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,39 @@
1
+ /**
2
+ * Audio Generation Domain Entities
3
+ */
4
+
5
+ export interface AudioGenerationConfig {
6
+ /**
7
+ * Duration of the audio in seconds
8
+ */
9
+ duration?: number;
10
+
11
+ /**
12
+ * Voice ID or style
13
+ */
14
+ voiceId?: string;
15
+ }
16
+
17
+ export interface AudioGenerationRequest {
18
+ /**
19
+ * The text prompt or description for audio generation
20
+ */
21
+ prompt: string;
22
+
23
+ /**
24
+ * Optional configuration
25
+ */
26
+ options?: AudioGenerationConfig;
27
+ }
28
+
29
+ export interface AudioGenerationResult {
30
+ /**
31
+ * The generated audio file URL
32
+ */
33
+ audioUrl: string;
34
+
35
+ /**
36
+ * Metadata about the generation
37
+ */
38
+ metadata?: Record<string, unknown>;
39
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { AudioGenerationRequest, AudioGenerationResult } from '../domain/entities';
10
+
11
+ export interface UseAudioGenerationReturn {
12
+ generateAudio: (request: AudioGenerationRequest) => Promise<AudioGenerationResult>;
13
+ isGenerating: boolean;
14
+ result: AudioGenerationResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useAudioGeneration = (): UseAudioGenerationReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<AudioGenerationResult | null>(null);
21
+
22
+ const generateAudio = useCallback(async (request: AudioGenerationRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as AudioGenerationResult);
27
+ return genResult.data as AudioGenerationResult;
28
+ }
29
+
30
+ throw new Error('Audio generation failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ generateAudio,
35
+ isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Colorization Domain Entities
3
+ */
4
+
5
+ export interface ColorizationConfig {
6
+ /**
7
+ * Guidance for color palette (e.g., "vintage", "modern", "warm")
8
+ */
9
+ palette?: string;
10
+
11
+ /**
12
+ * Saturation boost factor
13
+ * @default 1.0
14
+ */
15
+ saturation?: number;
16
+ }
17
+
18
+ export interface ColorizationRequest {
19
+ /**
20
+ * The black and white image to colorize.
21
+ * Can be a Base64 string or a remote URL.
22
+ */
23
+ image: string;
24
+
25
+ /**
26
+ * Optional prompt to guide colorization (e.g. "sunny day")
27
+ */
28
+ prompt?: string;
29
+
30
+ /**
31
+ * Optional configuration
32
+ */
33
+ options?: ColorizationConfig;
34
+ }
35
+
36
+ export interface ColorizationResult {
37
+ /**
38
+ * The colorized image URL or Base64
39
+ */
40
+ imageUrl: string;
41
+
42
+ /**
43
+ * Metadata about the generation
44
+ */
45
+ metadata?: Record<string, unknown>;
46
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { ColorizationRequest, ColorizationResult } from '../domain/entities';
10
+
11
+ export interface UseColorizationReturn {
12
+ colorize: (request: ColorizationRequest) => Promise<ColorizationResult>;
13
+ isColorizing: boolean;
14
+ result: ColorizationResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useColorization = (): UseColorizationReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<ColorizationResult | null>(null);
21
+
22
+ const colorize = useCallback(async (request: ColorizationRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as ColorizationResult);
27
+ return genResult.data as ColorizationResult;
28
+ }
29
+
30
+ throw new Error('Colorization failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ colorize,
35
+ isColorizing: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Face Swap Domain Entities
3
+ */
4
+
5
+ export interface FaceSwapConfig {
6
+ /**
7
+ * Enhance the face details after swapping
8
+ * @default true
9
+ */
10
+ enhanceFace?: boolean;
11
+
12
+ /**
13
+ * Preserve the skin tone of the target image
14
+ * @default true
15
+ */
16
+ preserveSkinTone?: boolean;
17
+ }
18
+
19
+ export interface FaceSwapRequest {
20
+ /**
21
+ * The target image where the face will be swapped TO.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ targetImage: string;
25
+
26
+ /**
27
+ * The source image containing the face to swap FROM.
28
+ * Can be a Base64 string or a remote URL.
29
+ */
30
+ sourceImage: string;
31
+
32
+ /**
33
+ * Optional configuration for the swap process
34
+ */
35
+ options?: FaceSwapConfig;
36
+ }
37
+
38
+ export interface FaceSwapResult {
39
+ /**
40
+ * URL or Base64 of the resulting image
41
+ */
42
+ imageUrl: string;
43
+
44
+ /**
45
+ * Metadata about the generation
46
+ */
47
+ metadata?: Record<string, unknown>;
48
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,41 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { FaceSwapRequest, FaceSwapResult } from '../domain/entities';
10
+
11
+ export interface UseFaceSwapReturn {
12
+ swapFace: (request: FaceSwapRequest) => Promise<FaceSwapResult>;
13
+ isSwapping: boolean;
14
+ result: FaceSwapResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useFaceSwap = (): UseFaceSwapReturn => {
19
+ // @ts-ignore - Deprecated feature, kept for backward compatibility
20
+ const { generate, isGenerating, error, result: genResult } = useGeneration<FaceSwapResult>({ model: 'face-swap' });
21
+ const [result, setResult] = useState<FaceSwapResult | null>(null);
22
+
23
+ const swapFace = useCallback(async (request: FaceSwapRequest) => {
24
+ // @ts-ignore - Deprecated feature
25
+ await generate(request);
26
+
27
+ if (genResult?.data) {
28
+ setResult(genResult.data as FaceSwapResult);
29
+ return genResult.data as FaceSwapResult;
30
+ }
31
+
32
+ throw new Error('Face swap failed to return a result');
33
+ }, [generate, genResult]);
34
+
35
+ return {
36
+ swapFace,
37
+ isSwapping: isGenerating,
38
+ result,
39
+ error: error as any,
40
+ };
41
+ };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Future Prediction Domain Entities
3
+ */
4
+
5
+ export interface FuturePredictionConfig {
6
+ /**
7
+ * Target age or years to add
8
+ */
9
+ targetAge?: number;
10
+
11
+ /**
12
+ * Years to add to current age
13
+ */
14
+ yearsToAdd?: number;
15
+
16
+ /**
17
+ * Gender (optional, if automatic detection fails)
18
+ */
19
+ gender?: 'male' | 'female';
20
+ }
21
+
22
+ export interface FuturePredictionRequest {
23
+ /**
24
+ * The image to process.
25
+ * Can be a Base64 string or a remote URL.
26
+ */
27
+ image: string;
28
+
29
+ /**
30
+ * Optional configuration
31
+ */
32
+ options?: FuturePredictionConfig;
33
+ }
34
+
35
+ export interface FuturePredictionResult {
36
+ /**
37
+ * The processed image URL or Base64
38
+ */
39
+ imageUrl: string;
40
+
41
+ /**
42
+ * Metadata about the generation
43
+ */
44
+ metadata?: Record<string, unknown>;
45
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { FuturePredictionRequest, FuturePredictionResult } from '../domain/entities';
10
+
11
+ export interface UseFuturePredictionReturn {
12
+ predictFuture: (request: FuturePredictionRequest) => Promise<FuturePredictionResult>;
13
+ isPredicting: boolean;
14
+ result: FuturePredictionResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useFuturePrediction = (): UseFuturePredictionReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<FuturePredictionResult | null>(null);
21
+
22
+ const predictFuture = useCallback(async (request: FuturePredictionRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as FuturePredictionResult);
27
+ return genResult.data as FuturePredictionResult;
28
+ }
29
+
30
+ throw new Error('Future prediction failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ predictFuture,
35
+ isPredicting: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Image Captioning Domain Entities
3
+ */
4
+
5
+ export interface ImageCaptioningConfig {
6
+ /**
7
+ * Detail level of the caption
8
+ * @default 'standard'
9
+ */
10
+ detailLevel?: 'brief' | 'standard' | 'detailed';
11
+
12
+ /**
13
+ * Language for the caption
14
+ * @default 'en'
15
+ */
16
+ language?: string;
17
+ }
18
+
19
+ export interface ImageCaptioningRequest {
20
+ /**
21
+ * The image to be captioned.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ image: string;
25
+
26
+ /**
27
+ * Optional context or question to guide the captioning
28
+ */
29
+ prompt?: string;
30
+
31
+ /**
32
+ * Optional configuration
33
+ */
34
+ options?: ImageCaptioningConfig;
35
+ }
36
+
37
+ export interface ImageCaptioningResult {
38
+ /**
39
+ * The generated caption text
40
+ */
41
+ text: string;
42
+
43
+ /**
44
+ * Metadata about the generation
45
+ */
46
+ metadata?: Record<string, unknown>;
47
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { ImageCaptioningRequest, ImageCaptioningResult } from '../domain/entities';
10
+
11
+ export interface UseImageCaptioningReturn {
12
+ generateCaption: (request: ImageCaptioningRequest) => Promise<ImageCaptioningResult>;
13
+ isGenerating: boolean;
14
+ result: ImageCaptioningResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useImageCaptioning = (): UseImageCaptioningReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<ImageCaptioningResult | null>(null);
21
+
22
+ const generateCaption = useCallback(async (request: ImageCaptioningRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as ImageCaptioningResult);
27
+ return genResult.data as ImageCaptioningResult;
28
+ }
29
+
30
+ throw new Error('Caption generation failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ generateCaption,
35
+ isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Inpainting Domain Entities
3
+ */
4
+
5
+ export interface InpaintingConfig {
6
+ /**
7
+ * Strength of the inpainting effect (0.0 to 1.0)
8
+ * @default 0.75
9
+ */
10
+ strength?: number;
11
+
12
+ /**
13
+ * Guidance scale for prompt adherence
14
+ * @default 7.5
15
+ */
16
+ guidanceScale?: number;
17
+ }
18
+
19
+ export interface InpaintingRequest {
20
+ /**
21
+ * The original image.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ image: string;
25
+
26
+ /**
27
+ * The mask image indicating areas to inpaint (white) vs keep (black).
28
+ * Can be a Base64 string or a remote URL.
29
+ */
30
+ mask: string;
31
+
32
+ /**
33
+ * Description of what to fill in the masked area
34
+ */
35
+ prompt: string;
36
+
37
+ /**
38
+ * Negative prompt for what to avoid
39
+ */
40
+ negativePrompt?: string;
41
+
42
+ /**
43
+ * Optional configuration
44
+ */
45
+ options?: InpaintingConfig;
46
+ }
47
+
48
+ export interface InpaintingResult {
49
+ /**
50
+ * The resulting image with inpainting applied
51
+ */
52
+ imageUrl: string;
53
+
54
+ /**
55
+ * Metadata about the generation
56
+ */
57
+ metadata?: Record<string, unknown>;
58
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { InpaintingRequest, InpaintingResult } from '../domain/entities';
10
+
11
+ export interface UseInpaintingReturn {
12
+ inpaint: (request: InpaintingRequest) => Promise<InpaintingResult>;
13
+ isInpainting: boolean;
14
+ result: InpaintingResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useInpainting = (): UseInpaintingReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<InpaintingResult | null>(null);
21
+
22
+ const inpaint = useCallback(async (request: InpaintingRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as InpaintingResult);
27
+ return genResult.data as InpaintingResult;
28
+ }
29
+
30
+ throw new Error('Inpainting failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ inpaint,
35
+ isInpainting: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Photo Restoration Domain Entities
3
+ */
4
+
5
+ export interface PhotoRestorationConfig {
6
+ /**
7
+ * Whether to fix scratches and creases
8
+ * @default true
9
+ */
10
+ fixScratches?: boolean;
11
+
12
+ /**
13
+ * Whether to enhance faces in the photo
14
+ * @default true
15
+ */
16
+ enhanceFaces?: boolean;
17
+
18
+ /**
19
+ * Upscale factor for the result
20
+ * @default 2
21
+ */
22
+ upscaleFactor?: 1 | 2 | 4;
23
+ }
24
+
25
+ export interface PhotoRestorationRequest {
26
+ /**
27
+ * The image to restore.
28
+ * Can be a Base64 string or a remote URL.
29
+ */
30
+ image: string;
31
+
32
+ /**
33
+ * Optional configuration
34
+ */
35
+ options?: PhotoRestorationConfig;
36
+ }
37
+
38
+ export interface PhotoRestorationResult {
39
+ /**
40
+ * The restored image URL or Base64
41
+ */
42
+ imageUrl: string;
43
+
44
+ /**
45
+ * Metadata about the generation
46
+ */
47
+ metadata?: Record<string, unknown>;
48
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { PhotoRestorationRequest, PhotoRestorationResult } from '../domain/entities';
10
+
11
+ export interface UsePhotoRestorationReturn {
12
+ restorePhoto: (request: PhotoRestorationRequest) => Promise<PhotoRestorationResult>;
13
+ isRestoring: boolean;
14
+ result: PhotoRestorationResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const usePhotoRestoration = (): UsePhotoRestorationReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<PhotoRestorationResult | null>(null);
21
+
22
+ const restorePhoto = useCallback(async (request: PhotoRestorationRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as PhotoRestorationResult);
27
+ return genResult.data as PhotoRestorationResult;
28
+ }
29
+
30
+ throw new Error('Photo restoration failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ restorePhoto,
35
+ isRestoring: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Sketch to Image Domain Entities
3
+ */
4
+
5
+ export interface SketchToImageConfig {
6
+ /**
7
+ * Strength of the prompt influence vs sketch influence (0.0 to 1.0)
8
+ * @default 0.7
9
+ */
10
+ strength?: number;
11
+
12
+ /**
13
+ * Steps for generation
14
+ * @default 20
15
+ */
16
+ steps?: number;
17
+ }
18
+
19
+ export interface SketchToImageRequest {
20
+ /**
21
+ * The sketch image.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ sketchImage: string;
25
+
26
+ /**
27
+ * Description of the desired output
28
+ */
29
+ prompt: string;
30
+
31
+ /**
32
+ * Optional configuration
33
+ */
34
+ options?: SketchToImageConfig;
35
+ }
36
+
37
+ export interface SketchToImageResult {
38
+ /**
39
+ * The generated realistic image URL
40
+ */
41
+ imageUrl: string;
42
+
43
+ /**
44
+ * Metadata about the generation
45
+ */
46
+ metadata?: Record<string, unknown>;
47
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { SketchToImageRequest, SketchToImageResult } from '../domain/entities';
10
+
11
+ export interface UseSketchToImageReturn {
12
+ generateFromSketch: (request: SketchToImageRequest) => Promise<SketchToImageResult>;
13
+ isGenerating: boolean;
14
+ result: SketchToImageResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useSketchToImage = (): UseSketchToImageReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<SketchToImageResult | null>(null);
21
+
22
+ const generateFromSketch = useCallback(async (request: SketchToImageRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as SketchToImageResult);
27
+ return genResult.data as SketchToImageResult;
28
+ }
29
+
30
+ throw new Error('Sketch to image generation failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ generateFromSketch,
35
+ isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Style Transfer Domain Entities
3
+ */
4
+
5
+ export interface StyleTransferConfig {
6
+ /**
7
+ * Strength of the style application (0.0 to 1.0)
8
+ * @default 1.0
9
+ */
10
+ strength?: number;
11
+
12
+ /**
13
+ * Preserve original colors
14
+ * @default false
15
+ */
16
+ preserveColor?: boolean;
17
+ }
18
+
19
+ export interface StyleTransferRequest {
20
+ /**
21
+ * The content image to apply style TO.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ contentImage: string;
25
+
26
+ /**
27
+ * The style image references (Base64 or URL)
28
+ */
29
+ styleImage?: string;
30
+
31
+ /**
32
+ * Or a preset style ID (e.g. "van_gogh_starry_night")
33
+ */
34
+ stylePreset?: string;
35
+
36
+ /**
37
+ * Optional configuration
38
+ */
39
+ options?: StyleTransferConfig;
40
+ }
41
+
42
+ export interface StyleTransferResult {
43
+ /**
44
+ * The stylized image URL or Base64
45
+ */
46
+ imageUrl: string;
47
+
48
+ /**
49
+ * Metadata about the generation
50
+ */
51
+ metadata?: Record<string, unknown>;
52
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { StyleTransferRequest, StyleTransferResult } from '../domain/entities';
10
+
11
+ export interface UseStyleTransferReturn {
12
+ transferStyle: (request: StyleTransferRequest) => Promise<StyleTransferResult>;
13
+ isTransferring: boolean;
14
+ result: StyleTransferResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useStyleTransfer = (): UseStyleTransferReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<StyleTransferResult | null>(null);
21
+
22
+ const transferStyle = useCallback(async (request: StyleTransferRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as StyleTransferResult);
27
+ return genResult.data as StyleTransferResult;
28
+ }
29
+
30
+ throw new Error('Style transfer failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ transferStyle,
35
+ isTransferring: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Text-to-Image Domain Entities
3
+ */
4
+
5
+ export interface TextToImageConfig {
6
+ /**
7
+ * Width of the generated image
8
+ * @default 1024
9
+ */
10
+ width?: number;
11
+
12
+ /**
13
+ * Height of the generated image
14
+ * @default 1024
15
+ */
16
+ height?: number;
17
+
18
+ /**
19
+ * Number of inference steps
20
+ * @default 30
21
+ */
22
+ steps?: number;
23
+
24
+ /**
25
+ * Guidance scale
26
+ * @default 7.5
27
+ */
28
+ guidanceScale?: number;
29
+ }
30
+
31
+ export interface TextToImageRequest {
32
+ /**
33
+ * The description of the image to generate
34
+ */
35
+ prompt: string;
36
+
37
+ /**
38
+ * Negative prompt for what to avoid
39
+ */
40
+ negativePrompt?: string;
41
+
42
+ /**
43
+ * Optional configuration
44
+ */
45
+ options?: TextToImageConfig;
46
+ }
47
+
48
+ export interface TextToImageResult {
49
+ /**
50
+ * The generated image URL or Base64
51
+ */
52
+ imageUrl: string;
53
+
54
+ /**
55
+ * Metadata about the generation
56
+ */
57
+ metadata?: Record<string, unknown>;
58
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { TextToImageRequest, TextToImageResult } from '../domain/entities';
10
+
11
+ export interface UseTextToImageReturn {
12
+ generateImage: (request: TextToImageRequest) => Promise<TextToImageResult>;
13
+ isGenerating: boolean;
14
+ result: TextToImageResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useTextToImage = (): UseTextToImageReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<TextToImageResult | null>(null);
21
+
22
+ const generateImage = useCallback(async (request: TextToImageRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as TextToImageResult);
27
+ return genResult.data as TextToImageResult;
28
+ }
29
+
30
+ throw new Error('Image generation failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ generateImage,
35
+ isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Text to Video Domain Entities
3
+ */
4
+
5
+ export interface TextToVideoConfig {
6
+ /**
7
+ * Duration of the video in seconds
8
+ * @default 4
9
+ */
10
+ duration?: number;
11
+
12
+ /**
13
+ * FPS of the generated video
14
+ * @default 24
15
+ */
16
+ fps?: number;
17
+
18
+ /**
19
+ * Guidance scale
20
+ * @default 7.5
21
+ */
22
+ guidanceScale?: number;
23
+ }
24
+
25
+ export interface TextToVideoRequest {
26
+ /**
27
+ * The text prompt to generate video from
28
+ */
29
+ prompt: string;
30
+
31
+ /**
32
+ * Negative prompt
33
+ */
34
+ negativePrompt?: string;
35
+
36
+ /**
37
+ * Optional configuration
38
+ */
39
+ options?: TextToVideoConfig;
40
+ }
41
+
42
+ export interface TextToVideoResult {
43
+ /**
44
+ * The generated video URL
45
+ */
46
+ videoUrl: string;
47
+
48
+ /**
49
+ * Metadata about the generation
50
+ */
51
+ metadata?: Record<string, unknown>;
52
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { TextToVideoRequest, TextToVideoResult } from '../domain/entities';
10
+
11
+ export interface UseTextToVideoReturn {
12
+ generateVideo: (request: TextToVideoRequest) => Promise<TextToVideoResult>;
13
+ isGenerating: boolean;
14
+ result: TextToVideoResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useTextToVideo = (): UseTextToVideoReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<TextToVideoResult | null>(null);
21
+
22
+ const generateVideo = useCallback(async (request: TextToVideoRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as TextToVideoResult);
27
+ return genResult.data as TextToVideoResult;
28
+ }
29
+
30
+ throw new Error('Video generation failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ generateVideo,
35
+ isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Upscaling Domain Entities
3
+ */
4
+
5
+ export interface UpscaleConfig {
6
+ /**
7
+ * The factor to upscale the image by
8
+ * @default 2
9
+ */
10
+ scaleFactor?: 2 | 4;
11
+
12
+ /**
13
+ * Whether to enhance faces during upscaling
14
+ * @default false
15
+ */
16
+ enhanceFaces?: boolean;
17
+ }
18
+
19
+ export interface UpscaleRequest {
20
+ /**
21
+ * The image to upscale.
22
+ * Can be a Base64 string or a remote URL.
23
+ */
24
+ image: string;
25
+
26
+ /**
27
+ * Optional configuration
28
+ */
29
+ options?: UpscaleConfig;
30
+ }
31
+
32
+ export interface UpscaleResult {
33
+ /**
34
+ * The upscaled image URL or Base64
35
+ */
36
+ imageUrl: string;
37
+
38
+ /**
39
+ * Metadata about the generation
40
+ */
41
+ metadata?: Record<string, unknown>;
42
+ }
@@ -0,0 +1,2 @@
1
+ export * from './domain/entities';
2
+ export * from './presentation/hooks';
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
3
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { useState, useCallback } from 'react';
8
+ import { useGeneration } from '../../../presentation/hooks/use-generation';
9
+ import { UpscaleRequest, UpscaleResult } from '../domain/entities';
10
+
11
+ export interface UseUpscalingReturn {
12
+ upscale: (request: UpscaleRequest) => Promise<UpscaleResult>;
13
+ isUpscaling: boolean;
14
+ result: UpscaleResult | null;
15
+ error: Error | null;
16
+ }
17
+
18
+ export const useUpscaling = (): UseUpscalingReturn => {
19
+ const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
+ const [result, setResult] = useState<UpscaleResult | null>(null);
21
+
22
+ const upscale = useCallback(async (request: UpscaleRequest) => {
23
+ await generate(request as any);
24
+
25
+ if (genResult?.data) {
26
+ setResult(genResult.data as UpscaleResult);
27
+ return genResult.data as UpscaleResult;
28
+ }
29
+
30
+ throw new Error('Upscaling failed to return a result');
31
+ }, [generate, genResult]);
32
+
33
+ return {
34
+ upscale,
35
+ isUpscaling: isGenerating,
36
+ result,
37
+ error: error as any,
38
+ };
39
+ };
package/src/index.ts CHANGED
@@ -245,4 +245,6 @@ export * from "./domains/face-detection";
245
245
  // DOMAINS - Feature Background
246
246
  // =============================================================================
247
247
 
248
- export * from "./domains/feature-background";
248
+ export * from "./features/background";
249
+
250
+
@@ -20,6 +20,14 @@ export interface PhotoGenerationError {
20
20
  originalError?: Error;
21
21
  }
22
22
 
23
+ export interface AlertMessages {
24
+ networkError: string;
25
+ policyViolation: string;
26
+ saveFailed: string;
27
+ creditFailed: string;
28
+ unknown: string;
29
+ }
30
+
23
31
  export interface PhotoGenerationConfig<TInput, TResult, TSaveInput> {
24
32
  generate: (input: TInput) => Promise<TResult>;
25
33
  save?: (result: TResult, input: TInput) => Promise<TSaveInput>;
@@ -29,6 +37,7 @@ export interface PhotoGenerationConfig<TInput, TResult, TSaveInput> {
29
37
  onSuccess?: (result: TResult) => void;
30
38
  onError?: (error: PhotoGenerationError) => void;
31
39
  onSaveComplete?: (saveResult: TSaveInput) => void;
40
+ alertMessages: AlertMessages;
32
41
  }
33
42
 
34
43
  export interface PhotoGenerationState<TResult = unknown> {
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { useState, useCallback, useRef } from "react";
7
7
  import { useOfflineStore } from "@umituz/react-native-offline";
8
+ import { useAlert } from "@umituz/react-native-design-system";
8
9
  import type {
9
10
  PhotoGenerationConfig,
10
11
  PhotoGenerationState,
@@ -29,6 +30,7 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = unknown>(
29
30
  onSuccess,
30
31
  onError,
31
32
  onSaveComplete,
33
+ alertMessages,
32
34
  } = config;
33
35
 
34
36
  const [state, setState] = useState<PhotoGenerationState<TResult>>({
@@ -41,6 +43,7 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = unknown>(
41
43
  const [status, setStatus] = useState<PhotoGenerationStatus>("idle");
42
44
  const isGeneratingRef = useRef(false);
43
45
  const offlineStore = useOfflineStore();
46
+ const { showError } = useAlert();
44
47
 
45
48
  const createError = useCallback(
46
49
  (
@@ -143,6 +146,15 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = unknown>(
143
146
  progress: 0,
144
147
  });
145
148
  setStatus("error");
149
+
150
+ const errorMessage =
151
+ generationError.type === "network_error" ? alertMessages.networkError :
152
+ generationError.type === "policy_violation" ? alertMessages.policyViolation :
153
+ generationError.type === "save_failed" ? alertMessages.saveFailed :
154
+ generationError.type === "credit_failed" ? alertMessages.creditFailed :
155
+ alertMessages.unknown;
156
+
157
+ showError("Error", errorMessage);
146
158
  onError?.(generationError);
147
159
  } finally {
148
160
  isGeneratingRef.current = false;