@umituz/react-native-ai-generation-content 1.17.16 → 1.17.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -4
- package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +14 -14
- package/src/domains/creations/presentation/components/CreationDetail/DetailVideo.tsx +51 -58
- package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +36 -29
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +98 -69
- package/src/features/text-to-image/index.ts +92 -4
- package/src/features/text-to-image/presentation/components/AspectRatioSelector.tsx +98 -0
- package/src/features/text-to-image/presentation/components/ExamplePrompts.tsx +88 -0
- package/src/features/text-to-image/presentation/components/ImageSizeSelector.tsx +98 -0
- package/src/features/text-to-image/presentation/components/NumImagesSelector.tsx +93 -0
- package/src/features/text-to-image/presentation/components/OutputFormatSelector.tsx +98 -0
- package/src/features/text-to-image/presentation/components/SettingsSheet.tsx +139 -0
- package/src/features/text-to-image/presentation/components/StyleSelector.tsx +110 -0
- package/src/features/text-to-image/presentation/components/TextToImageGenerateButton.tsx +84 -0
- package/src/features/text-to-image/presentation/components/TextToImagePromptInput.tsx +90 -0
- package/src/features/text-to-image/presentation/components/index.ts +44 -0
- package/src/features/text-to-image/presentation/hooks/index.ts +25 -0
- package/src/features/text-to-image/presentation/hooks/useFormState.ts +103 -0
- package/src/features/text-to-image/presentation/hooks/useGeneration.ts +98 -0
- package/src/features/text-to-image/presentation/hooks/useTextToImageForm.ts +58 -0
- package/src/features/text-to-image/presentation/index.ts +6 -0
- package/src/features/text-to-voice/domain/types/component.types.ts +91 -0
- package/src/features/text-to-voice/domain/types/config.types.ts +34 -0
- package/src/features/text-to-voice/domain/types/form.types.ts +39 -0
- package/src/features/text-to-voice/domain/types/generation.types.ts +43 -0
- package/src/features/text-to-voice/domain/types/index.ts +31 -3
- package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +2 -10
- package/src/features/text-to-voice/domain/types/text-to-voice.types.ts +0 -65
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Image Form Hook
|
|
3
|
+
* Composes form state and generation for complete form management
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { useFormState, type UseFormStateOptions } from "./useFormState";
|
|
8
|
+
import { useGeneration, type GenerationState } from "./useGeneration";
|
|
9
|
+
import type {
|
|
10
|
+
TextToImageFormState,
|
|
11
|
+
TextToImageFormActions,
|
|
12
|
+
TextToImageCallbacks,
|
|
13
|
+
} from "../../domain/types";
|
|
14
|
+
|
|
15
|
+
export interface UseTextToImageFormOptions extends UseFormStateOptions {
|
|
16
|
+
callbacks: TextToImageCallbacks;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UseTextToImageFormReturn {
|
|
20
|
+
state: TextToImageFormState;
|
|
21
|
+
actions: TextToImageFormActions;
|
|
22
|
+
generationState: GenerationState;
|
|
23
|
+
totalCost: number;
|
|
24
|
+
handleGenerate: () => Promise<void>;
|
|
25
|
+
isReady: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useTextToImageForm(
|
|
29
|
+
options: UseTextToImageFormOptions
|
|
30
|
+
): UseTextToImageFormReturn {
|
|
31
|
+
const { callbacks, defaults } = options;
|
|
32
|
+
|
|
33
|
+
const { state, actions } = useFormState({ defaults });
|
|
34
|
+
|
|
35
|
+
const { generationState, totalCost, handleGenerate } = useGeneration({
|
|
36
|
+
formState: state,
|
|
37
|
+
callbacks,
|
|
38
|
+
onPromptCleared: actions.reset,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const isReady = useMemo(
|
|
42
|
+
() => state.prompt.trim().length > 0 && !generationState.isGenerating,
|
|
43
|
+
[state.prompt, generationState.isGenerating]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const wrappedHandleGenerate = async () => {
|
|
47
|
+
await handleGenerate();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
state,
|
|
52
|
+
actions,
|
|
53
|
+
generationState,
|
|
54
|
+
totalCost,
|
|
55
|
+
handleGenerate: wrappedHandleGenerate,
|
|
56
|
+
isReady,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Component Types
|
|
3
|
+
* Props types for UI components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
8
|
+
|
|
9
|
+
export interface TextToVoiceTextInputProps {
|
|
10
|
+
value: string;
|
|
11
|
+
onChangeText: (text: string) => void;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
labelKey: string;
|
|
14
|
+
placeholderKey: string;
|
|
15
|
+
characterCountKey: string;
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TextToVoiceOptionalInputProps {
|
|
20
|
+
title: string;
|
|
21
|
+
value: string;
|
|
22
|
+
onChangeText: (text: string) => void;
|
|
23
|
+
placeholder: string;
|
|
24
|
+
hint: string;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TextToVoiceExamplePromptsProps {
|
|
29
|
+
prompts: string[];
|
|
30
|
+
onSelectPrompt: (prompt: string) => void;
|
|
31
|
+
labelKey: string;
|
|
32
|
+
style?: StyleProp<ViewStyle>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TextToVoiceGenerateButtonProps {
|
|
36
|
+
isGenerating: boolean;
|
|
37
|
+
progress: number;
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
onPress: () => void;
|
|
40
|
+
buttonTextKey: string;
|
|
41
|
+
generatingTextKey: string;
|
|
42
|
+
style?: StyleProp<ViewStyle>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TextToVoiceAudioPlayerProps {
|
|
46
|
+
audioUrl: string;
|
|
47
|
+
onPlay: () => void;
|
|
48
|
+
successTextKey: string;
|
|
49
|
+
playButtonTextKey: string;
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TextToVoiceErrorMessageProps {
|
|
54
|
+
message: string;
|
|
55
|
+
style?: StyleProp<ViewStyle>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TextToVoiceHeaderProps {
|
|
59
|
+
titleKey: string;
|
|
60
|
+
descriptionKey: string;
|
|
61
|
+
iconName: string;
|
|
62
|
+
navigationType?: "back" | "close";
|
|
63
|
+
headerContent?: ReactNode;
|
|
64
|
+
style?: StyleProp<ViewStyle>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface TextToVoiceScreenConfig {
|
|
68
|
+
maxTextLength: number;
|
|
69
|
+
creditCost: number;
|
|
70
|
+
defaultModel?: string;
|
|
71
|
+
defaultVoice?: string;
|
|
72
|
+
defaultSpeed?: number;
|
|
73
|
+
defaultStability?: number;
|
|
74
|
+
defaultSimilarityBoost?: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface TextToVoiceTranslationKeys {
|
|
78
|
+
title: string;
|
|
79
|
+
description: string;
|
|
80
|
+
textInputLabel: string;
|
|
81
|
+
textInputPlaceholder: string;
|
|
82
|
+
characterCount: string;
|
|
83
|
+
voiceLabel: string;
|
|
84
|
+
voicePlaceholder: string;
|
|
85
|
+
voiceHint: string;
|
|
86
|
+
examplesLabel: string;
|
|
87
|
+
generateButton: string;
|
|
88
|
+
generatingText: string;
|
|
89
|
+
successText: string;
|
|
90
|
+
playButton: string;
|
|
91
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Config Types
|
|
3
|
+
* Feature configuration types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { TextToVoiceOptions, TextToVoiceResult } from "./generation.types";
|
|
7
|
+
|
|
8
|
+
export type TextToVoiceInputBuilder = (
|
|
9
|
+
text: string,
|
|
10
|
+
options?: TextToVoiceOptions,
|
|
11
|
+
) => Record<string, unknown>;
|
|
12
|
+
|
|
13
|
+
export type TextToVoiceResultExtractor = (
|
|
14
|
+
result: unknown,
|
|
15
|
+
) => { audioUrl?: string; duration?: number } | undefined;
|
|
16
|
+
|
|
17
|
+
export interface TextToVoiceFeatureConfig {
|
|
18
|
+
providerId?: string;
|
|
19
|
+
creditCost?: number;
|
|
20
|
+
model: string;
|
|
21
|
+
buildInput: TextToVoiceInputBuilder;
|
|
22
|
+
extractResult?: TextToVoiceResultExtractor;
|
|
23
|
+
onTextChange?: (text: string) => void;
|
|
24
|
+
onProcessingStart?: () => void;
|
|
25
|
+
onProcessingComplete?: (result: TextToVoiceResult) => void;
|
|
26
|
+
onError?: (error: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TextToVoiceExecuteOptions {
|
|
30
|
+
model: string;
|
|
31
|
+
buildInput: TextToVoiceInputBuilder;
|
|
32
|
+
extractResult?: TextToVoiceResultExtractor;
|
|
33
|
+
onProgress?: (progress: number) => void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Form Types
|
|
3
|
+
* Form state and setter types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { TextToVoiceRequest } from "./generation.types";
|
|
7
|
+
|
|
8
|
+
export interface TextToVoiceFormState {
|
|
9
|
+
text: string;
|
|
10
|
+
model: string;
|
|
11
|
+
voice: string;
|
|
12
|
+
speed: number;
|
|
13
|
+
stability: number;
|
|
14
|
+
similarityBoost: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TextToVoiceFormSetters {
|
|
18
|
+
setText: (text: string) => void;
|
|
19
|
+
setModel: (model: string) => void;
|
|
20
|
+
setVoice: (voice: string) => void;
|
|
21
|
+
setSpeed: (speed: number) => void;
|
|
22
|
+
setStability: (stability: number) => void;
|
|
23
|
+
setSimilarityBoost: (similarityBoost: number) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TextToVoiceFormReturn extends TextToVoiceFormSetters {
|
|
27
|
+
formState: TextToVoiceFormState;
|
|
28
|
+
buildRequest: () => TextToVoiceRequest;
|
|
29
|
+
resetForm: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TextToVoiceFormConfig {
|
|
33
|
+
initialText?: string;
|
|
34
|
+
initialModel?: string;
|
|
35
|
+
initialVoice?: string;
|
|
36
|
+
initialSpeed?: number;
|
|
37
|
+
initialStability?: number;
|
|
38
|
+
initialSimilarityBoost?: number;
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Generation Types
|
|
3
|
+
* Request, result, and state types for 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
|
+
model?: string;
|
|
18
|
+
options?: TextToVoiceOptions;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TextToVoiceResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
audioUrl?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
requestId?: string;
|
|
26
|
+
duration?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TextToVoiceGenerationState {
|
|
30
|
+
isGenerating: boolean;
|
|
31
|
+
progress: number;
|
|
32
|
+
audioUrl: string | null;
|
|
33
|
+
error: string | null;
|
|
34
|
+
requestId: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface VoiceGeneration {
|
|
38
|
+
id: string;
|
|
39
|
+
text: string;
|
|
40
|
+
audioUrl: string;
|
|
41
|
+
provider: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
}
|
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-to-Voice Domain Types
|
|
3
|
+
* Barrel export for all types
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
export type {
|
|
2
7
|
TextToVoiceOptions,
|
|
3
8
|
TextToVoiceRequest,
|
|
4
9
|
TextToVoiceResult,
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
TextToVoiceGenerationState,
|
|
11
|
+
VoiceGeneration,
|
|
12
|
+
} from "./generation.types";
|
|
13
|
+
|
|
14
|
+
export type {
|
|
15
|
+
TextToVoiceFormState,
|
|
16
|
+
TextToVoiceFormSetters,
|
|
17
|
+
TextToVoiceFormReturn,
|
|
18
|
+
TextToVoiceFormConfig,
|
|
19
|
+
} from "./form.types";
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
TextToVoiceTextInputProps,
|
|
23
|
+
TextToVoiceOptionalInputProps,
|
|
24
|
+
TextToVoiceExamplePromptsProps,
|
|
25
|
+
TextToVoiceGenerateButtonProps,
|
|
26
|
+
TextToVoiceAudioPlayerProps,
|
|
27
|
+
TextToVoiceErrorMessageProps,
|
|
28
|
+
TextToVoiceHeaderProps,
|
|
29
|
+
TextToVoiceScreenConfig,
|
|
30
|
+
TextToVoiceTranslationKeys,
|
|
31
|
+
} from "./component.types";
|
|
32
|
+
|
|
33
|
+
export type {
|
|
7
34
|
TextToVoiceInputBuilder,
|
|
8
35
|
TextToVoiceResultExtractor,
|
|
9
36
|
TextToVoiceFeatureConfig,
|
|
10
|
-
|
|
37
|
+
TextToVoiceExecuteOptions,
|
|
38
|
+
} from "./config.types";
|
|
@@ -7,19 +7,11 @@ import { providerRegistry } from "../../../../infrastructure/services";
|
|
|
7
7
|
import type {
|
|
8
8
|
TextToVoiceRequest,
|
|
9
9
|
TextToVoiceResult,
|
|
10
|
-
|
|
11
|
-
TextToVoiceResultExtractor,
|
|
10
|
+
TextToVoiceExecuteOptions,
|
|
12
11
|
} from "../../domain/types";
|
|
13
12
|
|
|
14
13
|
declare const __DEV__: boolean;
|
|
15
14
|
|
|
16
|
-
export interface ExecuteTextToVoiceOptions {
|
|
17
|
-
model: string;
|
|
18
|
-
buildInput: TextToVoiceInputBuilder;
|
|
19
|
-
extractResult?: TextToVoiceResultExtractor;
|
|
20
|
-
onProgress?: (progress: number) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
15
|
function defaultExtractResult(
|
|
24
16
|
result: unknown,
|
|
25
17
|
): { audioUrl?: string; duration?: number } | undefined {
|
|
@@ -50,7 +42,7 @@ function defaultExtractResult(
|
|
|
50
42
|
|
|
51
43
|
export async function executeTextToVoice(
|
|
52
44
|
request: TextToVoiceRequest,
|
|
53
|
-
options:
|
|
45
|
+
options: TextToVoiceExecuteOptions,
|
|
54
46
|
): Promise<TextToVoiceResult> {
|
|
55
47
|
const provider = providerRegistry.getActiveProvider();
|
|
56
48
|
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|