@umituz/react-native-ai-generation-content 1.17.18 → 1.17.20

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 (33) hide show
  1. package/package.json +1 -1
  2. package/src/features/image-to-video/domain/constants/animation.constants.ts +47 -0
  3. package/src/features/image-to-video/domain/constants/duration.constants.ts +13 -0
  4. package/src/features/image-to-video/domain/constants/form.constants.ts +22 -0
  5. package/src/features/image-to-video/domain/constants/index.ts +23 -0
  6. package/src/features/image-to-video/domain/constants/music.constants.ts +53 -0
  7. package/src/features/image-to-video/domain/index.ts +4 -0
  8. package/src/features/image-to-video/domain/types/animation.types.ts +20 -0
  9. package/src/features/image-to-video/domain/types/config.types.ts +56 -0
  10. package/src/features/image-to-video/domain/types/duration.types.ts +11 -0
  11. package/src/features/image-to-video/domain/types/form.types.ts +35 -0
  12. package/src/features/image-to-video/domain/types/image-to-video.types.ts +18 -0
  13. package/src/features/image-to-video/domain/types/index.ts +25 -0
  14. package/src/features/image-to-video/domain/types/music.types.ts +21 -0
  15. package/src/features/text-to-image/domain/types/config.types.ts +9 -5
  16. package/src/features/text-to-image/domain/types/index.ts +4 -4
  17. package/src/features/text-to-image/index.ts +4 -4
  18. package/src/features/text-to-image/presentation/hooks/useGeneration.ts +5 -5
  19. package/src/features/text-to-voice/index.ts +34 -6
  20. package/src/features/text-to-voice/infrastructure/services/index.ts +0 -1
  21. package/src/features/text-to-voice/presentation/components/TextToVoiceAudioPlayer.tsx +81 -0
  22. package/src/features/text-to-voice/presentation/components/TextToVoiceErrorMessage.tsx +57 -0
  23. package/src/features/text-to-voice/presentation/components/TextToVoiceExamplePrompts.tsx +77 -0
  24. package/src/features/text-to-voice/presentation/components/TextToVoiceGenerateButton.tsx +87 -0
  25. package/src/features/text-to-voice/presentation/components/TextToVoiceHeader.tsx +73 -0
  26. package/src/features/text-to-voice/presentation/components/TextToVoiceOptionalInput.tsx +73 -0
  27. package/src/features/text-to-voice/presentation/components/TextToVoiceTextInput.tsx +85 -0
  28. package/src/features/text-to-voice/presentation/components/index.ts +7 -0
  29. package/src/features/text-to-voice/presentation/hooks/index.ts +5 -4
  30. package/src/features/text-to-voice/presentation/hooks/useTextToVoiceForm.ts +91 -0
  31. package/src/features/text-to-voice/presentation/hooks/useTextToVoiceGeneration.ts +116 -0
  32. package/src/features/text-to-voice/presentation/index.ts +1 -0
  33. package/src/features/text-to-voice/presentation/hooks/useTextToVoiceFeature.ts +0 -105
@@ -1,105 +0,0 @@
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
- }