@umituz/react-native-ai-generation-content 1.17.1 → 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.
Files changed (52) hide show
  1. package/package.json +1 -1
  2. package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +1 -1
  3. package/src/domains/creations/presentation/hooks/useAdvancedFilter.ts +0 -1
  4. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +9 -6
  5. package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
  6. package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +1 -1
  7. package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +2 -2
  8. package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -4
  9. package/src/features/image-to-video/domain/index.ts +1 -0
  10. package/src/features/image-to-video/domain/types/image-to-video.types.ts +71 -0
  11. package/src/features/image-to-video/domain/types/index.ts +10 -0
  12. package/src/features/image-to-video/index.ts +27 -0
  13. package/src/features/image-to-video/infrastructure/index.ts +1 -0
  14. package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +112 -0
  15. package/src/features/image-to-video/infrastructure/services/index.ts +5 -0
  16. package/src/features/image-to-video/presentation/hooks/index.ts +5 -0
  17. package/src/features/image-to-video/presentation/hooks/useImageToVideoFeature.ts +121 -0
  18. package/src/features/image-to-video/presentation/index.ts +1 -0
  19. package/src/features/text-to-image/domain/index.ts +1 -0
  20. package/src/features/text-to-image/domain/types/index.ts +10 -0
  21. package/src/features/text-to-image/domain/types/text-to-image.types.ts +66 -0
  22. package/src/features/text-to-image/index.ts +27 -1
  23. package/src/features/text-to-image/infrastructure/index.ts +1 -0
  24. package/src/features/text-to-image/infrastructure/services/index.ts +5 -0
  25. package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +113 -0
  26. package/src/features/text-to-image/presentation/hooks/index.ts +5 -0
  27. package/src/features/text-to-image/presentation/hooks/useTextToImageFeature.ts +111 -0
  28. package/src/features/text-to-image/presentation/index.ts +1 -0
  29. package/src/features/text-to-video/domain/index.ts +1 -0
  30. package/src/features/text-to-video/domain/types/index.ts +10 -0
  31. package/src/features/text-to-video/domain/types/text-to-video.types.ts +65 -0
  32. package/src/features/text-to-video/index.ts +27 -1
  33. package/src/features/text-to-video/infrastructure/index.ts +1 -0
  34. package/src/features/text-to-video/infrastructure/services/index.ts +5 -0
  35. package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +108 -0
  36. package/src/features/text-to-video/presentation/hooks/index.ts +5 -0
  37. package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +111 -0
  38. package/src/features/text-to-video/presentation/index.ts +1 -0
  39. package/src/features/text-to-voice/domain/index.ts +1 -0
  40. package/src/features/text-to-voice/domain/types/index.ts +10 -0
  41. package/src/features/text-to-voice/domain/types/text-to-voice.types.ts +65 -0
  42. package/src/features/text-to-voice/index.ts +27 -0
  43. package/src/features/text-to-voice/infrastructure/index.ts +1 -0
  44. package/src/features/text-to-voice/infrastructure/services/index.ts +5 -0
  45. package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +111 -0
  46. package/src/features/text-to-voice/presentation/hooks/index.ts +5 -0
  47. package/src/features/text-to-voice/presentation/hooks/useTextToVoiceFeature.ts +105 -0
  48. package/src/features/text-to-voice/presentation/index.ts +1 -0
  49. package/src/index.ts +24 -0
  50. package/src/features/text-to-image/domain/entities.ts +0 -58
  51. package/src/features/text-to-video/domain/entities.ts +0 -52
  52. package/src/types/jsx.d.ts +0 -19
@@ -0,0 +1,5 @@
1
+ export {
2
+ executeTextToVoice,
3
+ hasTextToVoiceSupport,
4
+ } from "./text-to-voice-executor";
5
+ export type { ExecuteTextToVoiceOptions } from "./text-to-voice-executor";
@@ -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,5 @@
1
+ export { useTextToVoiceFeature } from "./useTextToVoiceFeature";
2
+ export type {
3
+ UseTextToVoiceFeatureProps,
4
+ UseTextToVoiceFeatureReturn,
5
+ } from "./useTextToVoiceFeature";
@@ -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";
package/src/index.ts CHANGED
@@ -353,3 +353,27 @@ export * from "./features/remove-background";
353
353
 
354
354
  export * from "./features/remove-object";
355
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
+
@@ -1,58 +0,0 @@
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
- }
@@ -1,52 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * React 19 JSX Compatibility for React Native
3
- * Fixes JSX namespace issues between React 19 and react-native
4
- */
5
-
6
- import type { JSX as ReactJSX } from 'react';
7
-
8
- declare global {
9
- namespace JSX {
10
- interface Element extends ReactJSX.Element {}
11
- interface ElementClass extends ReactJSX.ElementClass {}
12
- interface ElementAttributesProperty extends ReactJSX.ElementAttributesProperty {}
13
- interface ElementChildrenAttribute extends ReactJSX.ElementChildrenAttribute {}
14
- interface IntrinsicAttributes extends ReactJSX.IntrinsicAttributes {}
15
- interface IntrinsicClassAttributes<T> extends ReactJSX.IntrinsicClassAttributes<T> {}
16
- }
17
- }
18
-
19
- export {};