@umituz/react-native-ai-generation-content 1.17.103 → 1.17.105
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
CHANGED
|
@@ -7,6 +7,7 @@ export { useTextToVideoFeature } from "./useTextToVideoFeature";
|
|
|
7
7
|
export type {
|
|
8
8
|
UseTextToVideoFeatureProps,
|
|
9
9
|
UseTextToVideoFeatureReturn,
|
|
10
|
+
TextToVideoGenerateParams,
|
|
10
11
|
} from "./useTextToVideoFeature";
|
|
11
12
|
|
|
12
13
|
export { useTextToVideoForm } from "./useTextToVideoForm";
|
|
@@ -25,10 +25,14 @@ export interface UseTextToVideoFeatureProps {
|
|
|
25
25
|
extractResult?: TextToVideoResultExtractor;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface TextToVideoGenerateParams extends TextToVideoOptions {
|
|
29
|
+
prompt?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
export interface UseTextToVideoFeatureReturn {
|
|
29
33
|
state: TextToVideoFeatureState;
|
|
30
34
|
setPrompt: (prompt: string) => void;
|
|
31
|
-
generate: (
|
|
35
|
+
generate: (params?: TextToVideoGenerateParams) => Promise<TextToVideoResult>;
|
|
32
36
|
reset: () => void;
|
|
33
37
|
isReady: boolean;
|
|
34
38
|
canGenerate: boolean;
|
|
@@ -58,25 +62,44 @@ export function useTextToVideoFeature(
|
|
|
58
62
|
);
|
|
59
63
|
|
|
60
64
|
const generate = useCallback(
|
|
61
|
-
async (
|
|
62
|
-
|
|
65
|
+
async (params?: TextToVideoGenerateParams): Promise<TextToVideoResult> => {
|
|
66
|
+
const { prompt: paramPrompt, ...options } = params || {};
|
|
67
|
+
const effectivePrompt = paramPrompt?.trim() || state.prompt.trim();
|
|
68
|
+
|
|
69
|
+
if (!effectivePrompt) {
|
|
63
70
|
const error = "Prompt is required";
|
|
64
71
|
setState((prev) => ({ ...prev, error }));
|
|
65
72
|
callbacks.onError?.(error);
|
|
73
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.log("[TextToVideoFeature] Generate failed: Prompt is required");
|
|
76
|
+
}
|
|
66
77
|
return { success: false, error };
|
|
67
78
|
}
|
|
68
79
|
|
|
80
|
+
if (paramPrompt) {
|
|
81
|
+
setState((prev) => ({ ...prev, prompt: effectivePrompt }));
|
|
82
|
+
}
|
|
83
|
+
|
|
69
84
|
if (callbacks.onAuthCheck && !callbacks.onAuthCheck()) {
|
|
85
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.log("[TextToVideoFeature] Generate failed: Authentication required");
|
|
88
|
+
}
|
|
70
89
|
return { success: false, error: "Authentication required" };
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
if (callbacks.onCreditCheck && !callbacks.onCreditCheck(config.creditCost)) {
|
|
92
|
+
if (callbacks.onCreditCheck && !(await callbacks.onCreditCheck(config.creditCost))) {
|
|
74
93
|
callbacks.onShowPaywall?.(config.creditCost);
|
|
94
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
console.log("[TextToVideoFeature] Generate failed: Insufficient credits");
|
|
97
|
+
}
|
|
75
98
|
return { success: false, error: "Insufficient credits" };
|
|
76
99
|
}
|
|
77
100
|
|
|
78
101
|
if (callbacks.onModeration) {
|
|
79
|
-
const moderationResult = await callbacks.onModeration(
|
|
102
|
+
const moderationResult = await callbacks.onModeration(effectivePrompt);
|
|
80
103
|
if (!moderationResult.allowed && moderationResult.warnings.length > 0) {
|
|
81
104
|
return new Promise((resolve) => {
|
|
82
105
|
callbacks.onShowModerationWarning?.(
|
|
@@ -86,7 +109,7 @@ export function useTextToVideoFeature(
|
|
|
86
109
|
resolve({ success: false, error: "Content policy violation" });
|
|
87
110
|
},
|
|
88
111
|
async () => {
|
|
89
|
-
const result = await executeGeneration(options);
|
|
112
|
+
const result = await executeGeneration(effectivePrompt, options);
|
|
90
113
|
resolve(result);
|
|
91
114
|
},
|
|
92
115
|
);
|
|
@@ -94,13 +117,13 @@ export function useTextToVideoFeature(
|
|
|
94
117
|
}
|
|
95
118
|
}
|
|
96
119
|
|
|
97
|
-
return executeGeneration(options);
|
|
120
|
+
return executeGeneration(effectivePrompt, options);
|
|
98
121
|
},
|
|
99
|
-
[state.prompt, callbacks, config.creditCost
|
|
122
|
+
[state.prompt, callbacks, config.creditCost],
|
|
100
123
|
);
|
|
101
124
|
|
|
102
125
|
const executeGeneration = useCallback(
|
|
103
|
-
async (options?: TextToVideoOptions): Promise<TextToVideoResult> => {
|
|
126
|
+
async (prompt: string, options?: TextToVideoOptions): Promise<TextToVideoResult> => {
|
|
104
127
|
setState((prev) => ({
|
|
105
128
|
...prev,
|
|
106
129
|
isProcessing: true,
|
|
@@ -108,13 +131,13 @@ export function useTextToVideoFeature(
|
|
|
108
131
|
error: null,
|
|
109
132
|
}));
|
|
110
133
|
|
|
111
|
-
if (__DEV__) {
|
|
134
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
112
135
|
// eslint-disable-next-line no-console
|
|
113
|
-
console.log("[TextToVideoFeature] Starting generation");
|
|
136
|
+
console.log("[TextToVideoFeature] Starting generation with prompt:", prompt);
|
|
114
137
|
}
|
|
115
138
|
|
|
116
139
|
const result = await executeTextToVideo(
|
|
117
|
-
{ prompt
|
|
140
|
+
{ prompt, userId, options },
|
|
118
141
|
{
|
|
119
142
|
model: config.model,
|
|
120
143
|
buildInput,
|
|
@@ -147,7 +170,7 @@ export function useTextToVideoFeature(
|
|
|
147
170
|
|
|
148
171
|
return result;
|
|
149
172
|
},
|
|
150
|
-
[
|
|
173
|
+
[userId, config.model, buildInput, extractResult, callbacks],
|
|
151
174
|
);
|
|
152
175
|
|
|
153
176
|
const reset = useCallback(() => {
|