@umituz/react-native-ai-generation-content 1.17.110 → 1.17.112
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/creations/infrastructure/repositories/CreationsWriter.ts +8 -0
- package/src/features/text-to-video/domain/types/callback.types.ts +11 -1
- package/src/features/text-to-video/domain/types/index.ts +1 -0
- package/src/features/text-to-video/index.ts +1 -0
- package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +16 -2
- package/src/presentation/components/AIGenerationForm.tsx +3 -1
- package/src/presentation/components/AIGenerationForm.types.ts +4 -0
- package/src/presentation/components/GenerationProgressContent.tsx +27 -3
- package/src/presentation/components/GenerationProgressModal.tsx +2 -2
package/package.json
CHANGED
|
@@ -23,6 +23,8 @@ export class CreationsWriter {
|
|
|
23
23
|
metadata: creation.metadata || {},
|
|
24
24
|
isShared: creation.isShared || false,
|
|
25
25
|
isFavorite: creation.isFavorite || false,
|
|
26
|
+
status: creation.status,
|
|
27
|
+
output: creation.output,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
await setDoc(docRef, data);
|
|
@@ -59,6 +61,12 @@ export class CreationsWriter {
|
|
|
59
61
|
if (updates.prompt !== undefined) {
|
|
60
62
|
updateData.prompt = updates.prompt;
|
|
61
63
|
}
|
|
64
|
+
if (updates.status !== undefined) {
|
|
65
|
+
updateData.status = updates.status;
|
|
66
|
+
}
|
|
67
|
+
if (updates.output !== undefined) {
|
|
68
|
+
updateData.output = updates.output;
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
await updateDoc(docRef, updateData);
|
|
64
72
|
return true;
|
|
@@ -27,12 +27,22 @@ export interface CreationData {
|
|
|
27
27
|
metadata?: Record<string, unknown>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export interface GenerationStartData {
|
|
31
|
+
creationId: string;
|
|
32
|
+
type: "text-to-video";
|
|
33
|
+
prompt: string;
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
export interface TextToVideoCallbacks {
|
|
31
38
|
onCreditCheck?: (cost: number) => Promise<boolean>;
|
|
32
39
|
onCreditDeduct?: (cost: number) => Promise<void>;
|
|
33
40
|
onAuthCheck?: () => boolean;
|
|
34
41
|
onModeration?: (prompt: string) => Promise<VideoModerationResult>;
|
|
35
|
-
|
|
42
|
+
/** Called when generation starts - save a "processing" creation */
|
|
43
|
+
onGenerationStart?: (data: GenerationStartData) => Promise<void>;
|
|
44
|
+
/** Called when generation completes - update creation to "completed" */
|
|
45
|
+
onCreationSave?: (data: CreationData & { creationId: string }) => Promise<void>;
|
|
36
46
|
onGenerate?: (result: TextToVideoResult) => void;
|
|
37
47
|
onError?: (error: string) => void;
|
|
38
48
|
onProgress?: (progress: number) => void;
|
|
@@ -124,6 +124,9 @@ export function useTextToVideoFeature(
|
|
|
124
124
|
|
|
125
125
|
const executeGeneration = useCallback(
|
|
126
126
|
async (prompt: string, options?: TextToVideoOptions): Promise<TextToVideoResult> => {
|
|
127
|
+
// Generate unique creation ID for tracking
|
|
128
|
+
const creationId = `text-to-video_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
129
|
+
|
|
127
130
|
setState((prev) => ({
|
|
128
131
|
...prev,
|
|
129
132
|
isProcessing: true,
|
|
@@ -133,7 +136,17 @@ export function useTextToVideoFeature(
|
|
|
133
136
|
|
|
134
137
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
135
138
|
// eslint-disable-next-line no-console
|
|
136
|
-
console.log("[TextToVideoFeature] Starting generation with prompt:", prompt);
|
|
139
|
+
console.log("[TextToVideoFeature] Starting generation with prompt:", prompt, "creationId:", creationId);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Create "processing" creation at start
|
|
143
|
+
if (callbacks.onGenerationStart) {
|
|
144
|
+
await callbacks.onGenerationStart({
|
|
145
|
+
creationId,
|
|
146
|
+
type: "text-to-video",
|
|
147
|
+
prompt,
|
|
148
|
+
metadata: options as Record<string, unknown> | undefined,
|
|
149
|
+
});
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
const result = await executeTextToVideo(
|
|
@@ -163,9 +176,10 @@ export function useTextToVideoFeature(
|
|
|
163
176
|
await callbacks.onCreditDeduct(config.creditCost);
|
|
164
177
|
}
|
|
165
178
|
|
|
166
|
-
//
|
|
179
|
+
// Update creation to completed after successful generation
|
|
167
180
|
if (callbacks.onCreationSave) {
|
|
168
181
|
await callbacks.onCreationSave({
|
|
182
|
+
creationId,
|
|
169
183
|
type: "text-to-video",
|
|
170
184
|
videoUrl: result.videoUrl,
|
|
171
185
|
thumbnailUrl: result.thumbnailUrl,
|
|
@@ -37,6 +37,7 @@ export const AIGenerationForm: React.FC<AIGenerationFormProps> = ({
|
|
|
37
37
|
hideGenerateButton,
|
|
38
38
|
progress,
|
|
39
39
|
progressIcon,
|
|
40
|
+
isProgressModalVisible,
|
|
40
41
|
onCloseProgressModal,
|
|
41
42
|
generateButtonProps,
|
|
42
43
|
showAdvanced,
|
|
@@ -159,12 +160,13 @@ export const AIGenerationForm: React.FC<AIGenerationFormProps> = ({
|
|
|
159
160
|
|
|
160
161
|
{/* MANDATORY: Progress Modal shows automatically when isGenerating */}
|
|
161
162
|
<GenerationProgressModal
|
|
162
|
-
visible={isGenerating}
|
|
163
|
+
visible={isProgressModalVisible ?? isGenerating}
|
|
163
164
|
progress={progress ?? 0}
|
|
164
165
|
icon={progressIcon || "sparkles-outline"}
|
|
165
166
|
title={translations.progressTitle || translations.generatingButton}
|
|
166
167
|
message={translations.progressMessage || translations.progressHint}
|
|
167
168
|
onClose={onCloseProgressModal}
|
|
169
|
+
backgroundHint={onCloseProgressModal ? translations.progressBackgroundHint : undefined}
|
|
168
170
|
/>
|
|
169
171
|
</>
|
|
170
172
|
);
|
|
@@ -18,6 +18,8 @@ export interface AIGenerationFormTranslations {
|
|
|
18
18
|
progressTitle?: string;
|
|
19
19
|
progressMessage?: string;
|
|
20
20
|
progressHint?: string;
|
|
21
|
+
/** Hint for background generation (e.g., "Continue in background") */
|
|
22
|
+
progressBackgroundHint?: string;
|
|
21
23
|
presetsTitle?: string;
|
|
22
24
|
showAdvancedLabel?: string;
|
|
23
25
|
hideAdvancedLabel?: string;
|
|
@@ -57,6 +59,8 @@ export interface AIGenerationFormProps extends PropsWithChildren {
|
|
|
57
59
|
// Optional: Generation Progress
|
|
58
60
|
progress?: number;
|
|
59
61
|
progressIcon?: string;
|
|
62
|
+
/** Override modal visibility (defaults to isGenerating) */
|
|
63
|
+
isProgressModalVisible?: boolean;
|
|
60
64
|
/** Callback when user closes the progress modal (for background generation) */
|
|
61
65
|
onCloseProgressModal?: () => void;
|
|
62
66
|
|
|
@@ -23,8 +23,8 @@ export interface GenerationProgressContentProps {
|
|
|
23
23
|
readonly onDismiss?: () => void;
|
|
24
24
|
/** Close button in top-right corner for background generation */
|
|
25
25
|
readonly onClose?: () => void;
|
|
26
|
-
/**
|
|
27
|
-
readonly
|
|
26
|
+
/** Hint text shown near close button (e.g., "Continue in background") */
|
|
27
|
+
readonly backgroundHint?: string;
|
|
28
28
|
readonly backgroundColor?: string;
|
|
29
29
|
readonly textColor?: string;
|
|
30
30
|
readonly hintColor?: string;
|
|
@@ -44,7 +44,7 @@ export const GenerationProgressContent: React.FC<
|
|
|
44
44
|
dismissLabel,
|
|
45
45
|
onDismiss,
|
|
46
46
|
onClose,
|
|
47
|
-
|
|
47
|
+
backgroundHint,
|
|
48
48
|
backgroundColor,
|
|
49
49
|
textColor,
|
|
50
50
|
hintColor,
|
|
@@ -119,6 +119,21 @@ export const GenerationProgressContent: React.FC<
|
|
|
119
119
|
</AtomicText>
|
|
120
120
|
)}
|
|
121
121
|
|
|
122
|
+
{/* Background hint - clickable to close and continue in background */}
|
|
123
|
+
{onClose && backgroundHint && (
|
|
124
|
+
<TouchableOpacity
|
|
125
|
+
style={styles.backgroundHintButton}
|
|
126
|
+
onPress={onClose}
|
|
127
|
+
>
|
|
128
|
+
<AtomicText
|
|
129
|
+
type="bodySmall"
|
|
130
|
+
style={[styles.backgroundHintText, { color: tokens.colors.primary }]}
|
|
131
|
+
>
|
|
132
|
+
{backgroundHint}
|
|
133
|
+
</AtomicText>
|
|
134
|
+
</TouchableOpacity>
|
|
135
|
+
)}
|
|
136
|
+
|
|
122
137
|
{onDismiss && (
|
|
123
138
|
<TouchableOpacity
|
|
124
139
|
style={[
|
|
@@ -178,6 +193,15 @@ const styles = StyleSheet.create({
|
|
|
178
193
|
lineHeight: 18,
|
|
179
194
|
paddingHorizontal: 8,
|
|
180
195
|
},
|
|
196
|
+
backgroundHintButton: {
|
|
197
|
+
marginTop: 16,
|
|
198
|
+
paddingVertical: 8,
|
|
199
|
+
paddingHorizontal: 16,
|
|
200
|
+
},
|
|
201
|
+
backgroundHintText: {
|
|
202
|
+
textAlign: "center",
|
|
203
|
+
textDecorationLine: "underline",
|
|
204
|
+
},
|
|
181
205
|
dismissButton: {
|
|
182
206
|
marginTop: 16,
|
|
183
207
|
paddingVertical: 14,
|
|
@@ -46,7 +46,7 @@ export const GenerationProgressModal: React.FC<
|
|
|
46
46
|
dismissLabel,
|
|
47
47
|
onDismiss,
|
|
48
48
|
onClose,
|
|
49
|
-
|
|
49
|
+
backgroundHint,
|
|
50
50
|
modalBackgroundColor,
|
|
51
51
|
textColor,
|
|
52
52
|
hintColor,
|
|
@@ -82,7 +82,7 @@ export const GenerationProgressModal: React.FC<
|
|
|
82
82
|
dismissLabel={dismissLabel}
|
|
83
83
|
onDismiss={onDismiss}
|
|
84
84
|
onClose={onClose}
|
|
85
|
-
|
|
85
|
+
backgroundHint={backgroundHint}
|
|
86
86
|
backgroundColor={modalBackgroundColor || tokens.colors.surface}
|
|
87
87
|
textColor={textColor || tokens.colors.textPrimary}
|
|
88
88
|
hintColor={hintColor || tokens.colors.textTertiary}
|