@umituz/react-native-ai-generation-content 1.17.146 → 1.17.148
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 -1
- package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +3 -3
- package/src/domains/creations/index.ts +1 -1
- package/src/domains/creations/infrastructure/repositories/CreationsFetcher.ts +6 -6
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +5 -5
- package/src/domains/creations/infrastructure/repositories/CreationsWriter.ts +5 -5
- package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +1 -1
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +1 -1
- package/src/domains/creations/presentation/hooks/advancedFilter.types.ts +38 -0
- package/src/domains/creations/presentation/hooks/filterHelpers.ts +145 -0
- package/src/domains/creations/presentation/hooks/index.ts +5 -0
- package/src/domains/creations/presentation/hooks/useAdvancedFilter.ts +34 -184
- package/src/domains/flashcard-generation/parsers/flashcard-response.parser.ts +1 -1
- package/src/features/face-swap/domain/types/face-swap.types.ts +13 -41
- package/src/features/face-swap/domain/types/index.ts +0 -1
- package/src/features/face-swap/index.ts +1 -5
- package/src/features/face-swap/presentation/hooks/index.ts +1 -4
- package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +17 -121
- package/src/features/image-to-image/domain/index.ts +1 -0
- package/src/features/image-to-image/domain/types/base.types.ts +189 -0
- package/src/features/image-to-image/domain/types/index.ts +1 -0
- package/src/features/image-to-image/index.ts +2 -0
- package/src/features/image-to-image/presentation/hooks/index.ts +3 -0
- package/src/features/image-to-image/presentation/hooks/useDualImageFeature.ts +154 -0
- package/src/features/image-to-image/presentation/hooks/useImageWithPromptFeature.ts +180 -0
- package/src/features/image-to-image/presentation/hooks/useSingleImageFeature.ts +132 -0
- package/src/features/image-to-image/presentation/index.ts +1 -0
- package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +10 -10
- package/src/features/image-to-video/presentation/hooks/useImageToVideoFeature.ts +8 -8
- package/src/features/image-to-video/presentation/hooks/useImageToVideoForm.ts +5 -5
- package/src/features/meme-generator/infrastructure/services/MemeGenerationService.ts +2 -2
- package/src/features/remove-background/domain/types/index.ts +0 -1
- package/src/features/remove-background/domain/types/remove-background.types.ts +14 -40
- package/src/features/remove-background/index.ts +1 -5
- package/src/features/remove-background/presentation/hooks/index.ts +1 -4
- package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +15 -100
- package/src/features/replace-background/domain/types/index.ts +1 -2
- package/src/features/replace-background/domain/types/replace-background.types.ts +14 -39
- package/src/features/replace-background/index.ts +0 -1
- package/src/features/replace-background/presentation/hooks/useReplaceBackgroundFeature.ts +30 -118
- package/src/features/script-generator/presentation/hooks/useScriptGenerator.ts +1 -1
- package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +2 -2
- package/src/features/text-to-image/presentation/hooks/useGeneration.ts +12 -12
- package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +9 -9
- package/src/features/text-to-video/presentation/hooks/textToVideoExecution.ts +134 -0
- package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +24 -118
- package/src/features/text-to-video/presentation/hooks/useTextToVideoForm.ts +1 -1
- package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +2 -2
- package/src/features/upscaling/domain/types/upscale.types.ts +12 -42
- package/src/features/upscaling/index.ts +1 -5
- package/src/features/upscaling/presentation/hooks/index.ts +1 -4
- package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +15 -106
- package/src/index.ts +7 -1
- package/src/infrastructure/config/app-services.config.ts +2 -2
- package/src/infrastructure/orchestration/GenerationOrchestrator.ts +23 -114
- package/src/infrastructure/orchestration/index.ts +3 -1
- package/src/infrastructure/orchestration/orchestrator.errors.ts +29 -0
- package/src/infrastructure/orchestration/orchestrator.types.ts +48 -0
- package/src/infrastructure/services/generation-orchestrator.service.ts +5 -5
- package/src/infrastructure/services/image-feature-executor.service.ts +2 -2
- package/src/infrastructure/services/job-poller.service.ts +1 -1
- package/src/infrastructure/services/job-poller.ts +3 -3
- package/src/infrastructure/services/provider-registry.service.ts +6 -6
- package/src/infrastructure/services/provider-validator.ts +4 -4
- package/src/infrastructure/services/video-feature-executor.service.ts +2 -2
- package/src/infrastructure/utils/error-classifier.util.ts +2 -2
- package/src/infrastructure/utils/feature-utils.ts +4 -4
- package/src/infrastructure/utils/result-validator.util.ts +1 -1
- package/src/infrastructure/utils/video-helpers.ts +3 -3
- package/src/presentation/components/AIGenerationForm.tsx +2 -2
- package/src/presentation/components/buttons/GenerateButton.tsx +3 -3
- package/src/presentation/hooks/useGenerationCallbacksBuilder.ts +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useRemoveBackgroundFeature Hook
|
|
3
|
-
*
|
|
3
|
+
* Uses base single image hook for background removal
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
useSingleImageFeature,
|
|
8
|
+
type BaseSingleImageHookReturn,
|
|
9
|
+
} from "../../../image-to-image";
|
|
8
10
|
import type {
|
|
9
|
-
RemoveBackgroundFeatureState,
|
|
10
11
|
RemoveBackgroundFeatureConfig,
|
|
11
12
|
RemoveBackgroundResult,
|
|
12
13
|
} from "../../domain/types";
|
|
@@ -17,104 +18,18 @@ export interface UseRemoveBackgroundFeatureProps {
|
|
|
17
18
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export interface UseRemoveBackgroundFeatureReturn extends RemoveBackgroundFeatureState {
|
|
21
|
-
selectImage: () => Promise<void>;
|
|
22
|
-
process: () => Promise<void>;
|
|
23
|
-
save: () => Promise<void>;
|
|
24
|
-
reset: () => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const initialState: RemoveBackgroundFeatureState = {
|
|
28
|
-
imageUri: null,
|
|
29
|
-
processedUrl: null,
|
|
30
|
-
isProcessing: false,
|
|
31
|
-
progress: 0,
|
|
32
|
-
error: null,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
21
|
export function useRemoveBackgroundFeature(
|
|
36
22
|
props: UseRemoveBackgroundFeatureProps,
|
|
37
|
-
):
|
|
23
|
+
): BaseSingleImageHookReturn {
|
|
38
24
|
const { config, onSelectImage, onSaveImage } = props;
|
|
39
|
-
const [state, setState] = useState<RemoveBackgroundFeatureState>(initialState);
|
|
40
|
-
|
|
41
|
-
const selectImage = useCallback(async () => {
|
|
42
|
-
try {
|
|
43
|
-
const uri = await onSelectImage();
|
|
44
|
-
if (uri) {
|
|
45
|
-
setState((prev) => ({ ...prev, imageUri: uri, error: null }));
|
|
46
|
-
config.onImageSelect?.(uri);
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
-
setState((prev) => ({ ...prev, error: message }));
|
|
51
|
-
}
|
|
52
|
-
}, [onSelectImage, config]);
|
|
53
|
-
|
|
54
|
-
const handleProgress = useCallback((progress: number) => {
|
|
55
|
-
setState((prev) => ({ ...prev, progress }));
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
const process = useCallback(async () => {
|
|
59
|
-
if (!state.imageUri) return;
|
|
60
|
-
|
|
61
|
-
setState((prev) => ({
|
|
62
|
-
...prev,
|
|
63
|
-
isProcessing: true,
|
|
64
|
-
progress: 0,
|
|
65
|
-
error: null,
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
config.onProcessingStart?.();
|
|
69
|
-
|
|
70
|
-
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
71
|
-
|
|
72
|
-
const result = await executeImageFeature(
|
|
73
|
-
"remove-background",
|
|
74
|
-
{ imageBase64 },
|
|
75
|
-
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
if (result.success && result.imageUrl) {
|
|
79
|
-
setState((prev) => ({
|
|
80
|
-
...prev,
|
|
81
|
-
isProcessing: false,
|
|
82
|
-
processedUrl: result.imageUrl!,
|
|
83
|
-
progress: 100,
|
|
84
|
-
}));
|
|
85
|
-
config.onProcessingComplete?.(result as RemoveBackgroundResult);
|
|
86
|
-
} else {
|
|
87
|
-
const errorMessage = result.error || "Processing failed";
|
|
88
|
-
setState((prev) => ({
|
|
89
|
-
...prev,
|
|
90
|
-
isProcessing: false,
|
|
91
|
-
error: errorMessage,
|
|
92
|
-
progress: 0,
|
|
93
|
-
}));
|
|
94
|
-
config.onError?.(errorMessage);
|
|
95
|
-
}
|
|
96
|
-
}, [state.imageUri, config, handleProgress]);
|
|
97
|
-
|
|
98
|
-
const save = useCallback(async () => {
|
|
99
|
-
if (!state.processedUrl) return;
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
await onSaveImage(state.processedUrl);
|
|
103
|
-
} catch (error) {
|
|
104
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
-
setState((prev) => ({ ...prev, error: message }));
|
|
106
|
-
}
|
|
107
|
-
}, [state.processedUrl, onSaveImage]);
|
|
108
|
-
|
|
109
|
-
const reset = useCallback(() => {
|
|
110
|
-
setState(initialState);
|
|
111
|
-
}, []);
|
|
112
25
|
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
26
|
+
return useSingleImageFeature<RemoveBackgroundFeatureConfig, RemoveBackgroundResult>(
|
|
27
|
+
{ config, onSelectImage, onSaveImage },
|
|
28
|
+
{
|
|
29
|
+
buildInput: (imageBase64, cfg) => ({
|
|
30
|
+
imageBase64,
|
|
31
|
+
options: cfg.defaultOptions,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
);
|
|
120
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Background Domain Types Index
|
|
2
|
+
* Replace Background Domain Types Index
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export type {
|
|
@@ -9,6 +9,5 @@ export type {
|
|
|
9
9
|
ReplaceBackgroundResult,
|
|
10
10
|
ReplaceBackgroundFeatureState,
|
|
11
11
|
ReplaceBackgroundTranslations,
|
|
12
|
-
ReplaceBackgroundResultExtractor,
|
|
13
12
|
ReplaceBackgroundFeatureConfig,
|
|
14
13
|
} from "./replace-background.types";
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Replace Background Feature Types
|
|
3
|
-
*
|
|
3
|
+
* Extends base image-to-image types with replace-background options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type {
|
|
7
|
+
BaseImageResult,
|
|
8
|
+
BaseImageWithPromptState,
|
|
9
|
+
BaseImageTranslations,
|
|
10
|
+
SingleImageConfig,
|
|
11
|
+
} from "../../../image-to-image/domain/types";
|
|
12
|
+
|
|
6
13
|
export type ReplaceBackgroundMode =
|
|
7
14
|
| "replace"
|
|
8
15
|
| "blur"
|
|
@@ -24,50 +31,18 @@ export interface ReplaceBackgroundRequest {
|
|
|
24
31
|
options?: ReplaceBackgroundOptions;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
export
|
|
28
|
-
success: boolean;
|
|
29
|
-
imageUrl?: string;
|
|
30
|
-
imageBase64?: string;
|
|
31
|
-
error?: string;
|
|
32
|
-
requestId?: string;
|
|
33
|
-
}
|
|
34
|
+
export type ReplaceBackgroundResult = BaseImageResult;
|
|
34
35
|
|
|
35
|
-
export interface ReplaceBackgroundFeatureState {
|
|
36
|
-
imageUri: string | null;
|
|
37
|
-
prompt: string;
|
|
38
|
-
processedUrl: string | null;
|
|
39
|
-
isProcessing: boolean;
|
|
40
|
-
progress: number;
|
|
41
|
-
error: string | null;
|
|
36
|
+
export interface ReplaceBackgroundFeatureState extends BaseImageWithPromptState {
|
|
42
37
|
mode: ReplaceBackgroundMode;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
export interface ReplaceBackgroundTranslations {
|
|
46
|
-
uploadTitle: string;
|
|
47
|
-
uploadSubtitle: string;
|
|
48
|
-
uploadChange: string;
|
|
49
|
-
uploadAnalyzing: string;
|
|
40
|
+
export interface ReplaceBackgroundTranslations extends BaseImageTranslations {
|
|
50
41
|
promptPlaceholder: string;
|
|
51
|
-
description: string;
|
|
52
|
-
processingText: string;
|
|
53
|
-
processButtonText: string;
|
|
54
|
-
successText: string;
|
|
55
|
-
saveButtonText: string;
|
|
56
|
-
tryAnotherText: string;
|
|
57
|
-
beforeLabel?: string;
|
|
58
|
-
afterLabel?: string;
|
|
59
|
-
compareHint?: string;
|
|
60
42
|
}
|
|
61
43
|
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
export interface ReplaceBackgroundFeatureConfig {
|
|
65
|
-
creditCost?: number;
|
|
44
|
+
export interface ReplaceBackgroundFeatureConfig
|
|
45
|
+
extends SingleImageConfig<ReplaceBackgroundResult> {
|
|
66
46
|
defaultMode?: ReplaceBackgroundMode;
|
|
67
|
-
|
|
68
|
-
prepareImage: (imageUri: string) => Promise<string>;
|
|
69
|
-
onImageSelect?: (uri: string) => void;
|
|
70
|
-
onProcessingStart?: () => void;
|
|
71
|
-
onProcessingComplete?: (result: ReplaceBackgroundResult) => void;
|
|
72
|
-
onError?: (error: string) => void;
|
|
47
|
+
onPromptChange?: (prompt: string) => void;
|
|
73
48
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useReplaceBackgroundFeature Hook
|
|
3
|
-
*
|
|
3
|
+
* Uses base image with prompt hook for background replacement
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useState, useCallback } from "react";
|
|
7
|
-
import {
|
|
6
|
+
import { useState, useCallback, useMemo } from "react";
|
|
7
|
+
import {
|
|
8
|
+
useImageWithPromptFeature,
|
|
9
|
+
type ImageWithPromptHookReturn,
|
|
10
|
+
} from "../../../image-to-image";
|
|
8
11
|
import type {
|
|
9
|
-
ReplaceBackgroundFeatureState,
|
|
10
12
|
ReplaceBackgroundFeatureConfig,
|
|
11
13
|
ReplaceBackgroundResult,
|
|
12
14
|
ReplaceBackgroundMode,
|
|
@@ -18,128 +20,38 @@ export interface UseReplaceBackgroundFeatureProps {
|
|
|
18
20
|
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
export interface UseReplaceBackgroundFeatureReturn extends
|
|
22
|
-
|
|
23
|
-
setPrompt: (prompt: string) => void;
|
|
23
|
+
export interface UseReplaceBackgroundFeatureReturn extends ImageWithPromptHookReturn {
|
|
24
|
+
mode: ReplaceBackgroundMode;
|
|
24
25
|
setMode: (mode: ReplaceBackgroundMode) => void;
|
|
25
|
-
process: () => Promise<void>;
|
|
26
|
-
save: () => Promise<void>;
|
|
27
|
-
reset: () => void;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const initialState: ReplaceBackgroundFeatureState = {
|
|
31
|
-
imageUri: null,
|
|
32
|
-
prompt: "",
|
|
33
|
-
processedUrl: null,
|
|
34
|
-
isProcessing: false,
|
|
35
|
-
progress: 0,
|
|
36
|
-
error: null,
|
|
37
|
-
mode: "replace",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
28
|
export function useReplaceBackgroundFeature(
|
|
41
29
|
props: UseReplaceBackgroundFeatureProps,
|
|
42
30
|
): UseReplaceBackgroundFeatureReturn {
|
|
43
31
|
const { config, onSelectImage, onSaveImage } = props;
|
|
44
|
-
const [
|
|
45
|
-
...initialState,
|
|
46
|
-
mode: config.defaultMode || "replace",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const selectImage = useCallback(async () => {
|
|
50
|
-
try {
|
|
51
|
-
const uri = await onSelectImage();
|
|
52
|
-
if (uri) {
|
|
53
|
-
setState((prev) => ({ ...prev, imageUri: uri, error: null }));
|
|
54
|
-
config.onImageSelect?.(uri);
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
-
setState((prev) => ({ ...prev, error: message }));
|
|
59
|
-
}
|
|
60
|
-
}, [onSelectImage, config]);
|
|
61
|
-
|
|
62
|
-
const setPrompt = useCallback((prompt: string) => {
|
|
63
|
-
setState((prev) => ({ ...prev, prompt }));
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
const setMode = useCallback((mode: ReplaceBackgroundMode) => {
|
|
67
|
-
setState((prev) => ({ ...prev, mode }));
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
const handleProgress = useCallback((progress: number) => {
|
|
71
|
-
setState((prev) => ({ ...prev, progress }));
|
|
72
|
-
}, []);
|
|
73
|
-
|
|
74
|
-
const process = useCallback(async () => {
|
|
75
|
-
if (!state.imageUri) return;
|
|
32
|
+
const [mode, setMode] = useState<ReplaceBackgroundMode>(config.defaultMode || "replace");
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
error: null,
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
config.onProcessingStart?.();
|
|
85
|
-
|
|
86
|
-
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
87
|
-
|
|
88
|
-
const result = await executeImageFeature(
|
|
89
|
-
"replace-background",
|
|
90
|
-
{
|
|
34
|
+
const baseHook = useImageWithPromptFeature<ReplaceBackgroundFeatureConfig, ReplaceBackgroundResult>(
|
|
35
|
+
{ config, onSelectImage, onSaveImage },
|
|
36
|
+
{
|
|
37
|
+
buildInput: (imageBase64, prompt) => ({
|
|
91
38
|
imageBase64,
|
|
92
|
-
prompt:
|
|
93
|
-
options: { mode
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
isProcessing: false,
|
|
102
|
-
processedUrl: result.imageUrl!,
|
|
103
|
-
progress: 100,
|
|
104
|
-
}));
|
|
105
|
-
config.onProcessingComplete?.(result as ReplaceBackgroundResult);
|
|
106
|
-
} else {
|
|
107
|
-
const errorMessage = result.error || "Processing failed";
|
|
108
|
-
setState((prev) => ({
|
|
109
|
-
...prev,
|
|
110
|
-
isProcessing: false,
|
|
111
|
-
error: errorMessage,
|
|
112
|
-
progress: 0,
|
|
113
|
-
}));
|
|
114
|
-
config.onError?.(errorMessage);
|
|
115
|
-
}
|
|
116
|
-
}, [state.imageUri, state.prompt, state.mode, config, handleProgress]);
|
|
117
|
-
|
|
118
|
-
const save = useCallback(async () => {
|
|
119
|
-
if (!state.processedUrl) return;
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
await onSaveImage(state.processedUrl);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
-
setState((prev) => ({ ...prev, error: message }));
|
|
126
|
-
}
|
|
127
|
-
}, [state.processedUrl, onSaveImage]);
|
|
128
|
-
|
|
129
|
-
const reset = useCallback(() => {
|
|
130
|
-
setState({
|
|
131
|
-
...initialState,
|
|
132
|
-
mode: config.defaultMode || "replace",
|
|
133
|
-
});
|
|
134
|
-
}, [config.defaultMode]);
|
|
39
|
+
prompt: prompt || undefined,
|
|
40
|
+
options: { mode },
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const handleSetMode = useCallback((newMode: ReplaceBackgroundMode) => {
|
|
46
|
+
setMode(newMode);
|
|
47
|
+
}, []);
|
|
135
48
|
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
49
|
+
return useMemo(
|
|
50
|
+
() => ({
|
|
51
|
+
...baseHook,
|
|
52
|
+
mode,
|
|
53
|
+
setMode: handleSetMode,
|
|
54
|
+
}),
|
|
55
|
+
[baseHook, mode, handleSetMode],
|
|
56
|
+
);
|
|
145
57
|
}
|
|
@@ -105,7 +105,7 @@ export async function executeTextToImage(
|
|
|
105
105
|
const { model, buildInput, extractResult, onProgress } = options;
|
|
106
106
|
|
|
107
107
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
console.log(`[TextToImage] Provider: ${provider.providerId}, Model: ${model}`);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -134,7 +134,7 @@ export async function executeTextToImage(
|
|
|
134
134
|
} catch (error) {
|
|
135
135
|
const message = error instanceof Error ? error.message : String(error);
|
|
136
136
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
console.error("[TextToImage] Error:", message);
|
|
139
139
|
}
|
|
140
140
|
return { success: false, error: message };
|
|
@@ -45,7 +45,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
45
45
|
|
|
46
46
|
const handleGenerate = useCallback(async (): Promise<TextToImageGenerationResult | null> => {
|
|
47
47
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
console.log("[TextToImage] handleGenerate called");
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -53,7 +53,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
53
53
|
|
|
54
54
|
if (!trimmedPrompt) {
|
|
55
55
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
console.log("[TextToImage] No prompt provided");
|
|
58
58
|
}
|
|
59
59
|
setGenerationState((prev) => ({ ...prev, error: "Prompt is required" }));
|
|
@@ -62,13 +62,13 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
62
62
|
|
|
63
63
|
const isAuth = callbacks.isAuthenticated();
|
|
64
64
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
console.log("[TextToImage] isAuthenticated:", isAuth);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (!isAuth) {
|
|
70
70
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
console.log("[TextToImage] Auth required - calling onAuthRequired");
|
|
73
73
|
}
|
|
74
74
|
callbacks.onAuthRequired?.();
|
|
@@ -77,13 +77,13 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
77
77
|
|
|
78
78
|
const affordable = callbacks.canAfford(totalCost);
|
|
79
79
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
console.log("[TextToImage] canAfford:", affordable, "totalCost:", totalCost);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (!affordable) {
|
|
85
85
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
console.log("[TextToImage] Credits required - calling onCreditsRequired");
|
|
88
88
|
}
|
|
89
89
|
callbacks.onCreditsRequired?.(totalCost);
|
|
@@ -91,7 +91,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
console.log("[TextToImage] Starting generation...");
|
|
96
96
|
}
|
|
97
97
|
setGenerationState({ isGenerating: true, progress: 0, error: null });
|
|
@@ -109,7 +109,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
console.log("[TextToImage] Request:", JSON.stringify(request, null, 2));
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -121,13 +121,13 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
121
121
|
imageCount: result.success ? result.imageUrls?.length : 0,
|
|
122
122
|
error: result.success === false ? result.error : undefined,
|
|
123
123
|
};
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
console.log("[TextToImage] Result:", JSON.stringify(logResult));
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (result.success === true) {
|
|
129
129
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
console.log("[TextToImage] Success! Generated", result.imageUrls?.length, "image(s)");
|
|
132
132
|
}
|
|
133
133
|
callbacks.onSuccess?.(result.imageUrls);
|
|
@@ -135,7 +135,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
135
135
|
setGenerationState({ isGenerating: false, progress: 100, error: null });
|
|
136
136
|
} else {
|
|
137
137
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
console.log("[TextToImage] Generation failed:", result.error);
|
|
140
140
|
}
|
|
141
141
|
setGenerationState({ isGenerating: false, progress: 0, error: result.error });
|
|
@@ -146,7 +146,7 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
146
146
|
} catch (error) {
|
|
147
147
|
const message = error instanceof Error ? error.message : String(error);
|
|
148
148
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
console.error("[TextToImage] Exception:", message);
|
|
151
151
|
}
|
|
152
152
|
setGenerationState({ isGenerating: false, progress: 0, error: message });
|
|
@@ -50,7 +50,7 @@ export async function executeTextToVideo(
|
|
|
50
50
|
options: ExecuteTextToVideoOptions,
|
|
51
51
|
): Promise<TextToVideoResult> {
|
|
52
52
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
console.log("[TextToVideoExecutor] executeTextToVideo() called");
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -58,7 +58,7 @@ export async function executeTextToVideo(
|
|
|
58
58
|
|
|
59
59
|
if (!provider) {
|
|
60
60
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
console.error("[TextToVideoExecutor] No AI provider configured");
|
|
63
63
|
}
|
|
64
64
|
return { success: false, error: "No AI provider configured" };
|
|
@@ -66,7 +66,7 @@ export async function executeTextToVideo(
|
|
|
66
66
|
|
|
67
67
|
if (!provider.isInitialized()) {
|
|
68
68
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
console.error("[TextToVideoExecutor] AI provider not initialized");
|
|
71
71
|
}
|
|
72
72
|
return { success: false, error: "AI provider not initialized" };
|
|
@@ -79,14 +79,14 @@ export async function executeTextToVideo(
|
|
|
79
79
|
const { model, buildInput, extractResult, onProgress } = options;
|
|
80
80
|
|
|
81
81
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
console.log(`[TextToVideoExecutor] Provider: ${provider.providerId}, Model: ${model}`);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
try {
|
|
87
87
|
onProgress?.(5);
|
|
88
88
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
console.log("[TextToVideoExecutor] Starting provider.run()...");
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -96,7 +96,7 @@ export async function executeTextToVideo(
|
|
|
96
96
|
onProgress: (progressInfo) => {
|
|
97
97
|
const progressValue = progressInfo.progress;
|
|
98
98
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
console.log("[TextToVideoExecutor] Progress:", progressValue);
|
|
101
101
|
}
|
|
102
102
|
onProgress?.(progressValue);
|
|
@@ -104,7 +104,7 @@ export async function executeTextToVideo(
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
console.log("[TextToVideoExecutor] provider.run() completed", result);
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -114,7 +114,7 @@ export async function executeTextToVideo(
|
|
|
114
114
|
|
|
115
115
|
if (!extracted?.videoUrl) {
|
|
116
116
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
console.error("[TextToVideoExecutor] No video URL in response");
|
|
119
119
|
}
|
|
120
120
|
return { success: false, error: "No video in response" };
|
|
@@ -128,7 +128,7 @@ export async function executeTextToVideo(
|
|
|
128
128
|
} catch (error) {
|
|
129
129
|
const message = error instanceof Error ? error.message : String(error);
|
|
130
130
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
console.error("[TextToVideoExecutor] Error:", message);
|
|
133
133
|
}
|
|
134
134
|
return { success: false, error: message };
|