@umituz/react-native-ai-generation-content 1.17.0 → 1.17.2
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 +13 -14
- package/src/domains/creations/domain/entities/Creation.ts +33 -2
- package/src/domains/creations/domain/entities/index.ts +1 -1
- package/src/domains/creations/domain/types/creation-categories.ts +133 -0
- package/src/domains/creations/domain/types/creation-filter.ts +131 -0
- package/src/domains/creations/domain/types/creation-types.ts +63 -0
- package/src/domains/creations/domain/types/index.ts +44 -0
- package/src/domains/creations/domain/utils/creation-helpers.ts +134 -0
- package/src/domains/creations/domain/utils/index.ts +8 -0
- package/src/domains/creations/domain/utils/preview-helpers.ts +84 -0
- package/src/domains/creations/domain/utils/status-helpers.ts +90 -0
- package/src/domains/creations/index.ts +95 -21
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +14 -1
- package/src/domains/creations/presentation/components/CreationActions.tsx +120 -0
- package/src/domains/creations/presentation/components/CreationBadges.tsx +111 -0
- package/src/domains/creations/presentation/components/CreationCard.tsx +201 -102
- package/src/domains/creations/presentation/components/CreationPreview.tsx +117 -0
- package/src/domains/creations/presentation/components/CreationsFilterBar.tsx +254 -0
- package/src/domains/creations/presentation/components/CreationsGrid.tsx +121 -68
- package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +1 -1
- package/src/domains/creations/presentation/components/index.ts +23 -3
- package/src/domains/creations/presentation/hooks/index.ts +1 -0
- package/src/domains/creations/presentation/hooks/useAdvancedFilter.ts +261 -0
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +8 -6
- package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
- package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +1 -1
- package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +2 -2
- package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -4
- package/src/features/ai-hug/domain/index.ts +5 -0
- package/src/features/ai-hug/domain/types/ai-hug.types.ts +72 -0
- package/src/features/ai-hug/domain/types/index.ts +14 -0
- package/src/features/ai-hug/index.ts +27 -0
- package/src/features/ai-hug/infrastructure/index.ts +5 -0
- package/src/features/ai-hug/infrastructure/services/ai-hug-executor.ts +96 -0
- package/src/features/ai-hug/infrastructure/services/index.ts +6 -0
- package/src/features/ai-hug/presentation/hooks/index.ts +9 -0
- package/src/features/ai-hug/presentation/hooks/useAIHugFeature.ts +157 -0
- package/src/features/ai-hug/presentation/index.ts +5 -0
- package/src/features/ai-kiss/domain/index.ts +5 -0
- package/src/features/ai-kiss/domain/types/ai-kiss.types.ts +72 -0
- package/src/features/ai-kiss/domain/types/index.ts +14 -0
- package/src/features/ai-kiss/index.ts +27 -0
- package/src/features/ai-kiss/infrastructure/index.ts +5 -0
- package/src/features/ai-kiss/infrastructure/services/ai-kiss-executor.ts +96 -0
- package/src/features/ai-kiss/infrastructure/services/index.ts +6 -0
- package/src/features/ai-kiss/presentation/hooks/index.ts +9 -0
- package/src/features/ai-kiss/presentation/hooks/useAIKissFeature.ts +157 -0
- package/src/features/ai-kiss/presentation/index.ts +5 -0
- package/src/features/anime-selfie/domain/index.ts +5 -0
- package/src/features/anime-selfie/domain/types/anime-selfie.types.ts +72 -0
- package/src/features/anime-selfie/domain/types/index.ts +15 -0
- package/src/features/anime-selfie/index.ts +28 -0
- package/src/features/anime-selfie/infrastructure/index.ts +5 -0
- package/src/features/anime-selfie/infrastructure/services/anime-selfie-executor.ts +95 -0
- package/src/features/anime-selfie/infrastructure/services/index.ts +6 -0
- package/src/features/anime-selfie/presentation/hooks/index.ts +9 -0
- package/src/features/anime-selfie/presentation/hooks/useAnimeSelfieFeature.ts +138 -0
- package/src/features/anime-selfie/presentation/index.ts +5 -0
- package/src/features/background/domain/types/index.ts +15 -0
- package/src/features/background/domain/types/replace-background.types.ts +82 -0
- package/src/features/background/index.ts +31 -3
- package/src/features/background/infrastructure/index.ts +5 -0
- package/src/features/background/infrastructure/services/index.ts +6 -0
- package/src/features/background/infrastructure/services/replace-background-executor.ts +95 -0
- package/src/features/background/presentation/hooks/index.ts +6 -1
- package/src/features/background/presentation/hooks/useReplaceBackgroundFeature.ts +160 -0
- package/src/features/face-swap/domain/index.ts +5 -0
- package/src/features/face-swap/domain/types/face-swap.types.ts +72 -0
- package/src/features/face-swap/domain/types/index.ts +14 -0
- package/src/features/face-swap/index.ts +27 -1
- package/src/features/face-swap/infrastructure/index.ts +5 -0
- package/src/features/face-swap/infrastructure/services/face-swap-executor.ts +96 -0
- package/src/features/face-swap/infrastructure/services/index.ts +6 -0
- package/src/features/face-swap/presentation/hooks/index.ts +9 -0
- package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +157 -0
- package/src/features/face-swap/presentation/index.ts +5 -0
- package/src/features/image-to-video/domain/index.ts +1 -0
- package/src/features/image-to-video/domain/types/image-to-video.types.ts +71 -0
- package/src/features/image-to-video/domain/types/index.ts +10 -0
- package/src/features/image-to-video/index.ts +27 -0
- package/src/features/image-to-video/infrastructure/index.ts +1 -0
- package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +112 -0
- package/src/features/image-to-video/infrastructure/services/index.ts +5 -0
- package/src/features/image-to-video/presentation/hooks/index.ts +5 -0
- package/src/features/image-to-video/presentation/hooks/useImageToVideoFeature.ts +121 -0
- package/src/features/image-to-video/presentation/index.ts +1 -0
- package/src/features/photo-restoration/domain/types/index.ts +2 -5
- package/src/features/photo-restoration/domain/types/photo-restore.types.ts +14 -0
- package/src/features/photo-restoration/index.ts +3 -8
- package/src/features/photo-restoration/infrastructure/services/index.ts +1 -6
- package/src/features/photo-restoration/infrastructure/services/photo-restore-executor.ts +64 -30
- package/src/features/photo-restoration/presentation/hooks/usePhotoRestoreFeature.ts +11 -6
- package/src/features/remove-background/domain/index.ts +5 -0
- package/src/features/remove-background/domain/types/index.ts +14 -0
- package/src/features/remove-background/domain/types/remove-background.types.ts +69 -0
- package/src/features/remove-background/index.ts +27 -0
- package/src/features/remove-background/infrastructure/index.ts +5 -0
- package/src/features/remove-background/infrastructure/services/index.ts +6 -0
- package/src/features/remove-background/infrastructure/services/remove-background-executor.ts +95 -0
- package/src/features/remove-background/presentation/hooks/index.ts +9 -0
- package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +137 -0
- package/src/features/remove-background/presentation/index.ts +5 -0
- package/src/features/remove-object/domain/index.ts +5 -0
- package/src/features/remove-object/domain/types/index.ts +14 -0
- package/src/features/remove-object/domain/types/remove-object.types.ts +77 -0
- package/src/features/remove-object/index.ts +27 -0
- package/src/features/remove-object/infrastructure/index.ts +5 -0
- package/src/features/remove-object/infrastructure/services/index.ts +6 -0
- package/src/features/remove-object/infrastructure/services/remove-object-executor.ts +99 -0
- package/src/features/remove-object/presentation/hooks/index.ts +9 -0
- package/src/features/remove-object/presentation/hooks/useRemoveObjectFeature.ts +168 -0
- package/src/features/remove-object/presentation/index.ts +5 -0
- package/src/features/text-to-image/domain/index.ts +1 -0
- package/src/features/text-to-image/domain/types/index.ts +10 -0
- package/src/features/text-to-image/domain/types/text-to-image.types.ts +66 -0
- package/src/features/text-to-image/index.ts +27 -1
- package/src/features/text-to-image/infrastructure/index.ts +1 -0
- package/src/features/text-to-image/infrastructure/services/index.ts +5 -0
- package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +113 -0
- package/src/features/text-to-image/presentation/hooks/index.ts +5 -0
- package/src/features/text-to-image/presentation/hooks/useTextToImageFeature.ts +111 -0
- package/src/features/text-to-image/presentation/index.ts +1 -0
- package/src/features/text-to-video/domain/index.ts +1 -0
- package/src/features/text-to-video/domain/types/index.ts +10 -0
- package/src/features/text-to-video/domain/types/text-to-video.types.ts +65 -0
- package/src/features/text-to-video/index.ts +27 -1
- package/src/features/text-to-video/infrastructure/index.ts +1 -0
- package/src/features/text-to-video/infrastructure/services/index.ts +5 -0
- package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +108 -0
- package/src/features/text-to-video/presentation/hooks/index.ts +5 -0
- package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +111 -0
- package/src/features/text-to-video/presentation/index.ts +1 -0
- package/src/features/text-to-voice/domain/index.ts +1 -0
- package/src/features/text-to-voice/domain/types/index.ts +10 -0
- package/src/features/text-to-voice/domain/types/text-to-voice.types.ts +65 -0
- package/src/features/text-to-voice/index.ts +27 -0
- package/src/features/text-to-voice/infrastructure/index.ts +1 -0
- package/src/features/text-to-voice/infrastructure/services/index.ts +5 -0
- package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +111 -0
- package/src/features/text-to-voice/presentation/hooks/index.ts +5 -0
- package/src/features/text-to-voice/presentation/hooks/useTextToVoiceFeature.ts +105 -0
- package/src/features/text-to-voice/presentation/index.ts +1 -0
- package/src/features/upscaling/domain/types/index.ts +0 -1
- package/src/features/upscaling/domain/types/upscale.types.ts +14 -0
- package/src/features/upscaling/index.ts +3 -11
- package/src/features/upscaling/infrastructure/services/index.ts +1 -6
- package/src/features/upscaling/infrastructure/services/upscale-executor.ts +64 -30
- package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +12 -7
- package/src/index.ts +63 -0
- package/src/features/face-swap/domain/entities.ts +0 -48
- package/src/features/photo-restoration/domain/types/provider.types.ts +0 -23
- package/src/features/photo-restoration/infrastructure/services/photo-restore-provider-registry.ts +0 -77
- package/src/features/text-to-image/domain/entities.ts +0 -58
- package/src/features/text-to-video/domain/entities.ts +0 -52
- package/src/features/upscaling/domain/types/provider.types.ts +0 -23
- package/src/features/upscaling/infrastructure/services/upscale-provider-registry.ts +0 -77
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Feature Types
|
|
3
|
+
* Request, Result, Config types for text-to-voice generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface TextToVoiceOptions {
|
|
7
|
+
voice?: string;
|
|
8
|
+
speed?: number;
|
|
9
|
+
pitch?: number;
|
|
10
|
+
stability?: number;
|
|
11
|
+
similarityBoost?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TextToVoiceRequest {
|
|
15
|
+
text: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
options?: TextToVoiceOptions;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TextToVoiceResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
audioUrl?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
requestId?: string;
|
|
25
|
+
duration?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TextToVoiceFeatureState {
|
|
29
|
+
text: string;
|
|
30
|
+
audioUrl: string | null;
|
|
31
|
+
isProcessing: boolean;
|
|
32
|
+
progress: number;
|
|
33
|
+
error: string | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TextToVoiceTranslations {
|
|
37
|
+
textPlaceholder: string;
|
|
38
|
+
generateButtonText: string;
|
|
39
|
+
processingText: string;
|
|
40
|
+
successText: string;
|
|
41
|
+
playButtonText: string;
|
|
42
|
+
saveButtonText: string;
|
|
43
|
+
tryAnotherText: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type TextToVoiceInputBuilder = (
|
|
47
|
+
text: string,
|
|
48
|
+
options?: TextToVoiceOptions,
|
|
49
|
+
) => Record<string, unknown>;
|
|
50
|
+
|
|
51
|
+
export type TextToVoiceResultExtractor = (
|
|
52
|
+
result: unknown,
|
|
53
|
+
) => { audioUrl?: string; duration?: number } | undefined;
|
|
54
|
+
|
|
55
|
+
export interface TextToVoiceFeatureConfig {
|
|
56
|
+
providerId?: string;
|
|
57
|
+
creditCost?: number;
|
|
58
|
+
model: string;
|
|
59
|
+
buildInput: TextToVoiceInputBuilder;
|
|
60
|
+
extractResult?: TextToVoiceResultExtractor;
|
|
61
|
+
onTextChange?: (text: string) => void;
|
|
62
|
+
onProcessingStart?: () => void;
|
|
63
|
+
onProcessingComplete?: (result: TextToVoiceResult) => void;
|
|
64
|
+
onError?: (error: string) => void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Feature
|
|
3
|
+
* Provider-agnostic text-to-voice generation feature
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Domain Types
|
|
7
|
+
export type {
|
|
8
|
+
TextToVoiceOptions,
|
|
9
|
+
TextToVoiceRequest,
|
|
10
|
+
TextToVoiceResult,
|
|
11
|
+
TextToVoiceFeatureState,
|
|
12
|
+
TextToVoiceTranslations,
|
|
13
|
+
TextToVoiceInputBuilder,
|
|
14
|
+
TextToVoiceResultExtractor,
|
|
15
|
+
TextToVoiceFeatureConfig,
|
|
16
|
+
} from "./domain";
|
|
17
|
+
|
|
18
|
+
// Infrastructure Services
|
|
19
|
+
export { executeTextToVoice, hasTextToVoiceSupport } from "./infrastructure";
|
|
20
|
+
export type { ExecuteTextToVoiceOptions } from "./infrastructure";
|
|
21
|
+
|
|
22
|
+
// Presentation Hooks
|
|
23
|
+
export { useTextToVoiceFeature } from "./presentation";
|
|
24
|
+
export type {
|
|
25
|
+
UseTextToVoiceFeatureProps,
|
|
26
|
+
UseTextToVoiceFeatureReturn,
|
|
27
|
+
} from "./presentation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./services";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Executor
|
|
3
|
+
* Provider-agnostic text-to-voice execution using active AI provider
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { providerRegistry } from "../../../../infrastructure/services";
|
|
7
|
+
import type {
|
|
8
|
+
TextToVoiceRequest,
|
|
9
|
+
TextToVoiceResult,
|
|
10
|
+
TextToVoiceInputBuilder,
|
|
11
|
+
TextToVoiceResultExtractor,
|
|
12
|
+
} from "../../domain/types";
|
|
13
|
+
|
|
14
|
+
declare const __DEV__: boolean;
|
|
15
|
+
|
|
16
|
+
export interface ExecuteTextToVoiceOptions {
|
|
17
|
+
model: string;
|
|
18
|
+
buildInput: TextToVoiceInputBuilder;
|
|
19
|
+
extractResult?: TextToVoiceResultExtractor;
|
|
20
|
+
onProgress?: (progress: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function defaultExtractResult(
|
|
24
|
+
result: unknown,
|
|
25
|
+
): { audioUrl?: string; duration?: number } | undefined {
|
|
26
|
+
if (typeof result !== "object" || result === null) return undefined;
|
|
27
|
+
|
|
28
|
+
const r = result as Record<string, unknown>;
|
|
29
|
+
|
|
30
|
+
if (typeof r.audio === "string") {
|
|
31
|
+
return { audioUrl: r.audio };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof r.audio_url === "string") {
|
|
35
|
+
return { audioUrl: r.audio_url };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (r.audio && typeof r.audio === "object") {
|
|
39
|
+
const audio = r.audio as Record<string, unknown>;
|
|
40
|
+
if (typeof audio.url === "string") {
|
|
41
|
+
return {
|
|
42
|
+
audioUrl: audio.url,
|
|
43
|
+
duration: typeof audio.duration === "number" ? audio.duration : undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function executeTextToVoice(
|
|
52
|
+
request: TextToVoiceRequest,
|
|
53
|
+
options: ExecuteTextToVoiceOptions,
|
|
54
|
+
): Promise<TextToVoiceResult> {
|
|
55
|
+
const provider = providerRegistry.getActiveProvider();
|
|
56
|
+
|
|
57
|
+
if (!provider) {
|
|
58
|
+
return { success: false, error: "No AI provider configured" };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!provider.isInitialized()) {
|
|
62
|
+
return { success: false, error: "AI provider not initialized" };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!request.text) {
|
|
66
|
+
return { success: false, error: "Text is required" };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { model, buildInput, extractResult, onProgress } = options;
|
|
70
|
+
|
|
71
|
+
if (__DEV__) {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log(`[TextToVoice] Provider: ${provider.providerId}, Model: ${model}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
onProgress?.(10);
|
|
78
|
+
|
|
79
|
+
const input = buildInput(request.text, request.options);
|
|
80
|
+
onProgress?.(20);
|
|
81
|
+
|
|
82
|
+
const result = await provider.run(model, input);
|
|
83
|
+
onProgress?.(90);
|
|
84
|
+
|
|
85
|
+
const extractor = extractResult || defaultExtractResult;
|
|
86
|
+
const extracted = extractor(result);
|
|
87
|
+
onProgress?.(100);
|
|
88
|
+
|
|
89
|
+
if (!extracted?.audioUrl) {
|
|
90
|
+
return { success: false, error: "No audio in response" };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
audioUrl: extracted.audioUrl,
|
|
96
|
+
duration: extracted.duration,
|
|
97
|
+
};
|
|
98
|
+
} catch (error) {
|
|
99
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
+
if (__DEV__) {
|
|
101
|
+
// eslint-disable-next-line no-console
|
|
102
|
+
console.error("[TextToVoice] Error:", message);
|
|
103
|
+
}
|
|
104
|
+
return { success: false, error: message };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function hasTextToVoiceSupport(): boolean {
|
|
109
|
+
const provider = providerRegistry.getActiveProvider();
|
|
110
|
+
return provider !== null && provider.isInitialized();
|
|
111
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Feature Hook
|
|
3
|
+
* Provider-agnostic hook for text-to-voice generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useCallback } from "react";
|
|
7
|
+
import { executeTextToVoice } from "../../infrastructure/services";
|
|
8
|
+
import type {
|
|
9
|
+
TextToVoiceFeatureState,
|
|
10
|
+
TextToVoiceFeatureConfig,
|
|
11
|
+
TextToVoiceResult,
|
|
12
|
+
TextToVoiceOptions,
|
|
13
|
+
} from "../../domain/types";
|
|
14
|
+
|
|
15
|
+
export interface UseTextToVoiceFeatureProps {
|
|
16
|
+
config: TextToVoiceFeatureConfig;
|
|
17
|
+
userId: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface UseTextToVoiceFeatureReturn {
|
|
21
|
+
state: TextToVoiceFeatureState;
|
|
22
|
+
setText: (text: string) => void;
|
|
23
|
+
generate: (options?: TextToVoiceOptions) => Promise<TextToVoiceResult>;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
isReady: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const initialState: TextToVoiceFeatureState = {
|
|
29
|
+
text: "",
|
|
30
|
+
audioUrl: null,
|
|
31
|
+
isProcessing: false,
|
|
32
|
+
progress: 0,
|
|
33
|
+
error: null,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function useTextToVoiceFeature(
|
|
37
|
+
props: UseTextToVoiceFeatureProps,
|
|
38
|
+
): UseTextToVoiceFeatureReturn {
|
|
39
|
+
const { config, userId } = props;
|
|
40
|
+
const [state, setState] = useState<TextToVoiceFeatureState>(initialState);
|
|
41
|
+
|
|
42
|
+
const setText = useCallback(
|
|
43
|
+
(text: string) => {
|
|
44
|
+
setState((prev) => ({ ...prev, text, error: null }));
|
|
45
|
+
config.onTextChange?.(text);
|
|
46
|
+
},
|
|
47
|
+
[config],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const generate = useCallback(
|
|
51
|
+
async (options?: TextToVoiceOptions): Promise<TextToVoiceResult> => {
|
|
52
|
+
if (!state.text) {
|
|
53
|
+
const error = "Text is required";
|
|
54
|
+
setState((prev) => ({ ...prev, error }));
|
|
55
|
+
return { success: false, error };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setState((prev) => ({
|
|
59
|
+
...prev,
|
|
60
|
+
isProcessing: true,
|
|
61
|
+
progress: 0,
|
|
62
|
+
error: null,
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
config.onProcessingStart?.();
|
|
66
|
+
|
|
67
|
+
const result = await executeTextToVoice(
|
|
68
|
+
{ text: state.text, userId, options },
|
|
69
|
+
{
|
|
70
|
+
model: config.model,
|
|
71
|
+
buildInput: config.buildInput,
|
|
72
|
+
extractResult: config.extractResult,
|
|
73
|
+
onProgress: (progress) => {
|
|
74
|
+
setState((prev) => ({ ...prev, progress }));
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (result.success && result.audioUrl) {
|
|
80
|
+
setState((prev) => ({
|
|
81
|
+
...prev,
|
|
82
|
+
audioUrl: result.audioUrl ?? null,
|
|
83
|
+
isProcessing: false,
|
|
84
|
+
progress: 100,
|
|
85
|
+
}));
|
|
86
|
+
} else {
|
|
87
|
+
const error = result.error || "Generation failed";
|
|
88
|
+
setState((prev) => ({ ...prev, isProcessing: false, error }));
|
|
89
|
+
config.onError?.(error);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
config.onProcessingComplete?.(result);
|
|
93
|
+
return result;
|
|
94
|
+
},
|
|
95
|
+
[state.text, userId, config],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const reset = useCallback(() => {
|
|
99
|
+
setState(initialState);
|
|
100
|
+
}, []);
|
|
101
|
+
|
|
102
|
+
const isReady = state.text.length > 0 && !state.isProcessing;
|
|
103
|
+
|
|
104
|
+
return { state, setText, generate, reset, isReady };
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./hooks";
|
|
@@ -12,6 +12,7 @@ export interface UpscaleOptions {
|
|
|
12
12
|
|
|
13
13
|
export interface UpscaleRequest {
|
|
14
14
|
imageUri: string;
|
|
15
|
+
imageBase64?: string;
|
|
15
16
|
userId: string;
|
|
16
17
|
options?: UpscaleOptions;
|
|
17
18
|
}
|
|
@@ -48,10 +49,23 @@ export interface UpscaleTranslations {
|
|
|
48
49
|
compareHint?: string;
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
export type UpscaleInputBuilder = (
|
|
53
|
+
base64: string,
|
|
54
|
+
options?: UpscaleOptions,
|
|
55
|
+
) => Record<string, unknown>;
|
|
56
|
+
|
|
57
|
+
export type UpscaleResultExtractor = (
|
|
58
|
+
result: unknown,
|
|
59
|
+
) => string | undefined;
|
|
60
|
+
|
|
51
61
|
export interface UpscaleFeatureConfig {
|
|
52
62
|
providerId?: string;
|
|
53
63
|
defaultScaleFactor?: UpscaleScaleFactor;
|
|
54
64
|
creditCost?: number;
|
|
65
|
+
model: string;
|
|
66
|
+
buildInput: UpscaleInputBuilder;
|
|
67
|
+
extractResult?: UpscaleResultExtractor;
|
|
68
|
+
prepareImage: (imageUri: string) => Promise<string>;
|
|
55
69
|
onImageSelect?: (uri: string) => void;
|
|
56
70
|
onProcessingStart?: () => void;
|
|
57
71
|
onProcessingComplete?: (result: UpscaleResult) => void;
|
|
@@ -12,17 +12,12 @@ export type {
|
|
|
12
12
|
UpscaleFeatureState,
|
|
13
13
|
UpscaleTranslations,
|
|
14
14
|
UpscaleFeatureConfig,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
UpscaleInputBuilder,
|
|
16
|
+
UpscaleResultExtractor,
|
|
17
17
|
} from "./domain";
|
|
18
18
|
|
|
19
19
|
// Infrastructure Services
|
|
20
|
-
export {
|
|
21
|
-
upscaleProviderRegistry,
|
|
22
|
-
executeUpscale,
|
|
23
|
-
getAvailableProvider,
|
|
24
|
-
hasUpscaleProvider,
|
|
25
|
-
} from "./infrastructure";
|
|
20
|
+
export { executeUpscale, hasUpscaleSupport } from "./infrastructure";
|
|
26
21
|
export type { ExecuteUpscaleOptions } from "./infrastructure";
|
|
27
22
|
|
|
28
23
|
// Presentation Hooks
|
|
@@ -38,6 +33,3 @@ export type {
|
|
|
38
33
|
UpscaleFeatureProps,
|
|
39
34
|
UpscaleResultViewProps,
|
|
40
35
|
} from "./presentation";
|
|
41
|
-
|
|
42
|
-
// ComparisonSlider is available from ./presentation/components if needed directly
|
|
43
|
-
// but not re-exported to avoid conflict with background feature's ComparisonSlider
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
executeUpscale,
|
|
4
|
-
getAvailableProvider,
|
|
5
|
-
hasUpscaleProvider,
|
|
6
|
-
} from "./upscale-executor";
|
|
1
|
+
export { executeUpscale, hasUpscaleSupport } from "./upscale-executor";
|
|
7
2
|
export type { ExecuteUpscaleOptions } from "./upscale-executor";
|
|
@@ -1,64 +1,98 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Upscale Executor
|
|
3
|
-
*
|
|
3
|
+
* Provider-agnostic upscale execution using active AI provider
|
|
4
|
+
* Model and input format are provided via options from app level
|
|
5
|
+
*
|
|
6
|
+
* Note: imageBase64 must be provided in the request. Image URI to base64
|
|
7
|
+
* conversion should be handled at the app level before calling this executor.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
10
|
+
import { providerRegistry } from "../../../../infrastructure/services";
|
|
11
|
+
import { cleanBase64 } from "../../../../infrastructure/utils";
|
|
12
|
+
import type {
|
|
13
|
+
UpscaleRequest,
|
|
14
|
+
UpscaleResult,
|
|
15
|
+
UpscaleInputBuilder,
|
|
16
|
+
UpscaleResultExtractor,
|
|
17
|
+
} from "../../domain/types";
|
|
8
18
|
|
|
9
19
|
declare const __DEV__: boolean;
|
|
10
20
|
|
|
11
21
|
export interface ExecuteUpscaleOptions {
|
|
12
|
-
|
|
22
|
+
model: string;
|
|
23
|
+
buildInput: UpscaleInputBuilder;
|
|
24
|
+
extractResult?: UpscaleResultExtractor;
|
|
13
25
|
onProgress?: (progress: number) => void;
|
|
14
26
|
}
|
|
15
27
|
|
|
28
|
+
function defaultExtractResult(result: unknown): string | undefined {
|
|
29
|
+
if (typeof result !== "object" || result === null) return undefined;
|
|
30
|
+
|
|
31
|
+
const r = result as Record<string, unknown>;
|
|
32
|
+
|
|
33
|
+
if (typeof r.image === "string") return r.image;
|
|
34
|
+
if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
|
|
35
|
+
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
16
39
|
export async function executeUpscale(
|
|
17
40
|
request: UpscaleRequest,
|
|
18
|
-
options
|
|
41
|
+
options: ExecuteUpscaleOptions,
|
|
19
42
|
): Promise<UpscaleResult> {
|
|
20
|
-
const provider =
|
|
43
|
+
const provider = providerRegistry.getActiveProvider();
|
|
21
44
|
|
|
22
45
|
if (!provider) {
|
|
23
|
-
return {
|
|
24
|
-
success: false,
|
|
25
|
-
error: "No upscale provider available",
|
|
26
|
-
};
|
|
46
|
+
return { success: false, error: "No AI provider configured" };
|
|
27
47
|
}
|
|
28
48
|
|
|
29
|
-
if (!provider.
|
|
30
|
-
return {
|
|
31
|
-
success: false,
|
|
32
|
-
error: `Provider ${provider.providerId} is not available`,
|
|
33
|
-
};
|
|
49
|
+
if (!provider.isInitialized()) {
|
|
50
|
+
return { success: false, error: "AI provider not initialized" };
|
|
34
51
|
}
|
|
35
52
|
|
|
53
|
+
if (!request.imageBase64) {
|
|
54
|
+
return { success: false, error: "Image base64 is required" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { model, buildInput, extractResult, onProgress } = options;
|
|
58
|
+
|
|
36
59
|
if (__DEV__) {
|
|
37
60
|
// eslint-disable-next-line no-console
|
|
38
|
-
console.log(`[
|
|
61
|
+
console.log(`[Upscale] Provider: ${provider.providerId}, Model: ${model}`);
|
|
39
62
|
}
|
|
40
63
|
|
|
41
64
|
try {
|
|
42
|
-
|
|
65
|
+
onProgress?.(10);
|
|
66
|
+
|
|
67
|
+
const base64 = cleanBase64(request.imageBase64);
|
|
68
|
+
onProgress?.(30);
|
|
69
|
+
|
|
70
|
+
const input = buildInput(base64, request.options);
|
|
71
|
+
onProgress?.(40);
|
|
72
|
+
|
|
73
|
+
const result = await provider.run(model, input);
|
|
74
|
+
onProgress?.(90);
|
|
75
|
+
|
|
76
|
+
const extractor = extractResult || defaultExtractResult;
|
|
77
|
+
const imageUrl = extractor(result);
|
|
78
|
+
onProgress?.(100);
|
|
79
|
+
|
|
80
|
+
if (!imageUrl) {
|
|
81
|
+
return { success: false, error: "No image in response" };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return { success: true, imageUrl };
|
|
43
85
|
} catch (error) {
|
|
44
86
|
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
-
|
|
46
87
|
if (__DEV__) {
|
|
47
88
|
// eslint-disable-next-line no-console
|
|
48
|
-
console.error("[
|
|
89
|
+
console.error("[Upscale] Error:", message);
|
|
49
90
|
}
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
success: false,
|
|
53
|
-
error: message,
|
|
54
|
-
};
|
|
91
|
+
return { success: false, error: message };
|
|
55
92
|
}
|
|
56
93
|
}
|
|
57
94
|
|
|
58
|
-
export function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export function hasUpscaleProvider(providerId: string): boolean {
|
|
63
|
-
return upscaleProviderRegistry.hasProvider(providerId);
|
|
95
|
+
export function hasUpscaleSupport(): boolean {
|
|
96
|
+
const provider = providerRegistry.getActiveProvider();
|
|
97
|
+
return provider !== null && provider.isInitialized();
|
|
64
98
|
}
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
declare const __DEV__: boolean;
|
|
15
15
|
|
|
16
16
|
export interface UseUpscaleFeatureProps {
|
|
17
|
-
config
|
|
17
|
+
config: UpscaleFeatureConfig;
|
|
18
18
|
userId: string;
|
|
19
19
|
onSelectImage: () => Promise<string | null>;
|
|
20
20
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
@@ -46,7 +46,7 @@ export function useUpscaleFeature(
|
|
|
46
46
|
const uri = await onSelectImage();
|
|
47
47
|
if (uri) {
|
|
48
48
|
setState((prev) => ({ ...prev, imageUri: uri, error: null }));
|
|
49
|
-
config
|
|
49
|
+
config.onImageSelect?.(uri);
|
|
50
50
|
}
|
|
51
51
|
} catch (error) {
|
|
52
52
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -68,21 +68,26 @@ export function useUpscaleFeature(
|
|
|
68
68
|
error: null,
|
|
69
69
|
}));
|
|
70
70
|
|
|
71
|
-
config
|
|
71
|
+
config.onProcessingStart?.();
|
|
72
72
|
|
|
73
73
|
if (__DEV__) {
|
|
74
74
|
// eslint-disable-next-line no-console
|
|
75
75
|
console.log("[useUpscaleFeature] Starting upscale process");
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
79
|
+
|
|
78
80
|
const result: UpscaleResult = await executeUpscale(
|
|
79
81
|
{
|
|
80
82
|
imageUri: state.imageUri,
|
|
83
|
+
imageBase64,
|
|
81
84
|
userId,
|
|
82
|
-
options: { scaleFactor: config
|
|
85
|
+
options: { scaleFactor: config.defaultScaleFactor || 2 },
|
|
83
86
|
},
|
|
84
87
|
{
|
|
85
|
-
|
|
88
|
+
model: config.model,
|
|
89
|
+
buildInput: config.buildInput,
|
|
90
|
+
extractResult: config.extractResult,
|
|
86
91
|
onProgress: handleProgress,
|
|
87
92
|
},
|
|
88
93
|
);
|
|
@@ -95,7 +100,7 @@ export function useUpscaleFeature(
|
|
|
95
100
|
processedUrl: url,
|
|
96
101
|
progress: 100,
|
|
97
102
|
}));
|
|
98
|
-
config
|
|
103
|
+
config.onProcessingComplete?.(result);
|
|
99
104
|
} else {
|
|
100
105
|
const errorMessage = result.error || "Processing failed";
|
|
101
106
|
setState((prev) => ({
|
|
@@ -104,7 +109,7 @@ export function useUpscaleFeature(
|
|
|
104
109
|
error: errorMessage,
|
|
105
110
|
progress: 0,
|
|
106
111
|
}));
|
|
107
|
-
config
|
|
112
|
+
config.onError?.(errorMessage);
|
|
108
113
|
}
|
|
109
114
|
}, [state.imageUri, userId, config, handleProgress]);
|
|
110
115
|
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* } from '@umituz/react-native-ai-generation-content';
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) console.log("📍 [LIFECYCLE] @umituz/react-native-ai-generation-content/index.ts - Module loading");
|
|
15
|
+
|
|
13
16
|
// =============================================================================
|
|
14
17
|
// DOMAIN LAYER - Types & Interfaces
|
|
15
18
|
// =============================================================================
|
|
@@ -314,3 +317,63 @@ export * from "./features/upscaling";
|
|
|
314
317
|
|
|
315
318
|
export * from "./features/photo-restoration";
|
|
316
319
|
|
|
320
|
+
// =============================================================================
|
|
321
|
+
// FEATURES - AI Hug
|
|
322
|
+
// =============================================================================
|
|
323
|
+
|
|
324
|
+
export * from "./features/ai-hug";
|
|
325
|
+
|
|
326
|
+
// =============================================================================
|
|
327
|
+
// FEATURES - AI Kiss
|
|
328
|
+
// =============================================================================
|
|
329
|
+
|
|
330
|
+
export * from "./features/ai-kiss";
|
|
331
|
+
|
|
332
|
+
// =============================================================================
|
|
333
|
+
// FEATURES - Face Swap
|
|
334
|
+
// =============================================================================
|
|
335
|
+
|
|
336
|
+
export * from "./features/face-swap";
|
|
337
|
+
|
|
338
|
+
// =============================================================================
|
|
339
|
+
// FEATURES - Anime Selfie
|
|
340
|
+
// =============================================================================
|
|
341
|
+
|
|
342
|
+
export * from "./features/anime-selfie";
|
|
343
|
+
|
|
344
|
+
// =============================================================================
|
|
345
|
+
// FEATURES - Remove Background
|
|
346
|
+
// =============================================================================
|
|
347
|
+
|
|
348
|
+
export * from "./features/remove-background";
|
|
349
|
+
|
|
350
|
+
// =============================================================================
|
|
351
|
+
// FEATURES - Remove Object
|
|
352
|
+
// =============================================================================
|
|
353
|
+
|
|
354
|
+
export * from "./features/remove-object";
|
|
355
|
+
|
|
356
|
+
// =============================================================================
|
|
357
|
+
// FEATURES - Text-to-Video
|
|
358
|
+
// =============================================================================
|
|
359
|
+
|
|
360
|
+
export * from "./features/text-to-video";
|
|
361
|
+
|
|
362
|
+
// =============================================================================
|
|
363
|
+
// FEATURES - Text-to-Image
|
|
364
|
+
// =============================================================================
|
|
365
|
+
|
|
366
|
+
export * from "./features/text-to-image";
|
|
367
|
+
|
|
368
|
+
// =============================================================================
|
|
369
|
+
// FEATURES - Image-to-Video
|
|
370
|
+
// =============================================================================
|
|
371
|
+
|
|
372
|
+
export * from "./features/image-to-video";
|
|
373
|
+
|
|
374
|
+
// =============================================================================
|
|
375
|
+
// FEATURES - Text-to-Voice
|
|
376
|
+
// =============================================================================
|
|
377
|
+
|
|
378
|
+
export * from "./features/text-to-voice";
|
|
379
|
+
|