@umituz/react-native-ai-generation-content 1.84.6 → 1.84.8
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/domain/interfaces/video-model-config.types.ts +1 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +3 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +48 -2
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +10 -0
- package/src/domains/generation/wizard/presentation/hooks/wizard-generation.types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.84.
|
|
3
|
+
"version": "1.84.8",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -37,6 +37,7 @@ export interface VideoModelConfig {
|
|
|
37
37
|
readonly duration?: number;
|
|
38
38
|
readonly aspectRatio?: string;
|
|
39
39
|
readonly resolution?: string;
|
|
40
|
+
readonly audioUrl?: string;
|
|
40
41
|
}) => Record<string, unknown>;
|
|
41
42
|
|
|
42
43
|
/** Pricing data for credit calculation (keys = resolution IDs) */
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -12,9 +12,32 @@ import { extractPhotosAsBase64 } from "./shared/photo-extraction.utils";
|
|
|
12
12
|
import type { WizardVideoInput, CreateVideoStrategyOptions } from "./video-generation.types";
|
|
13
13
|
import { validatePhotoCount, validateWizardVideoInput } from "./video-generation.types";
|
|
14
14
|
import { executeVideoGeneration, submitVideoGenerationToQueue } from "./video-generation.executor";
|
|
15
|
+
import { readAsStringAsync, EncodingType } from "expo-file-system";
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Extract audio from wizardData and read as base64.
|
|
21
|
+
* Audio step stores data as { uri: "file:///..." }.
|
|
22
|
+
*/
|
|
23
|
+
async function extractAudioAsBase64(wizardData: Record<string, unknown>): Promise<string | undefined> {
|
|
24
|
+
const audioData = wizardData.background_audio as { uri?: string } | undefined;
|
|
25
|
+
if (!audioData?.uri) return undefined;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const base64 = await readAsStringAsync(audioData.uri, { encoding: EncodingType.Base64 });
|
|
29
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
30
|
+
console.log("[VideoStrategy] Audio extracted as base64", { length: base64.length });
|
|
31
|
+
}
|
|
32
|
+
return base64;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
35
|
+
console.warn("[VideoStrategy] Failed to read audio file:", error);
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
18
41
|
export async function buildVideoInput(
|
|
19
42
|
wizardData: Record<string, unknown>,
|
|
20
43
|
scenario: WizardScenarioData,
|
|
@@ -23,6 +46,29 @@ export async function buildVideoInput(
|
|
|
23
46
|
console.log("[VideoStrategy] Building input", { scenarioId: scenario.id });
|
|
24
47
|
}
|
|
25
48
|
|
|
49
|
+
// Extract audio (shared by all code paths)
|
|
50
|
+
const audioUrl = await extractAudioAsBase64(wizardData);
|
|
51
|
+
|
|
52
|
+
// If a pre-generated image URL exists (e.g., two-step solo video),
|
|
53
|
+
// use it directly instead of extracting photos from wizard data
|
|
54
|
+
if (scenario.preGeneratedImageUrl) {
|
|
55
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
56
|
+
console.log("[VideoStrategy] Using pre-generated image URL", {
|
|
57
|
+
url: scenario.preGeneratedImageUrl.slice(0, 80),
|
|
58
|
+
hasAudio: !!audioUrl,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const finalPrompt = extractPrompt(wizardData, scenario.aiPrompt) || scenario.aiPrompt || "";
|
|
62
|
+
return {
|
|
63
|
+
sourceImageBase64: scenario.preGeneratedImageUrl,
|
|
64
|
+
prompt: finalPrompt,
|
|
65
|
+
duration: extractDuration(wizardData),
|
|
66
|
+
aspectRatio: extractAspectRatio(wizardData),
|
|
67
|
+
resolution: extractResolution(wizardData),
|
|
68
|
+
audioUrl,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
26
72
|
const photos = await extractPhotosAsBase64(wizardData, true);
|
|
27
73
|
|
|
28
74
|
const validation = validatePhotoCount(photos.length, scenario.inputType);
|
|
@@ -45,12 +91,11 @@ export async function buildVideoInput(
|
|
|
45
91
|
}
|
|
46
92
|
}
|
|
47
93
|
|
|
48
|
-
// For video generation, use clean prompt directly
|
|
49
|
-
// Modern models handle context natively
|
|
50
94
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
51
95
|
console.log("[VideoStrategy] Using clean prompt for video generation", {
|
|
52
96
|
promptLength: finalPrompt.length,
|
|
53
97
|
photoCount: photos.length,
|
|
98
|
+
hasAudio: !!audioUrl,
|
|
54
99
|
});
|
|
55
100
|
}
|
|
56
101
|
|
|
@@ -61,6 +106,7 @@ export async function buildVideoInput(
|
|
|
61
106
|
duration: extractDuration(wizardData),
|
|
62
107
|
aspectRatio: extractAspectRatio(wizardData),
|
|
63
108
|
resolution: extractResolution(wizardData),
|
|
109
|
+
audioUrl,
|
|
64
110
|
};
|
|
65
111
|
}
|
|
66
112
|
|
|
@@ -19,6 +19,8 @@ export interface WizardVideoInput {
|
|
|
19
19
|
readonly aspectRatio?: string;
|
|
20
20
|
/** Video resolution (e.g., "720p", "1080p") */
|
|
21
21
|
readonly resolution?: string;
|
|
22
|
+
/** Audio file as base64 or URL for background music / audio-driven video */
|
|
23
|
+
readonly audioUrl?: string;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export interface CreateVideoStrategyOptions {
|
|
@@ -96,6 +98,10 @@ function isWizardVideoInput(input: unknown): input is WizardVideoInput {
|
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
98
100
|
|
|
101
|
+
if (obj.audioUrl !== undefined && typeof obj.audioUrl !== "string") {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
return true;
|
|
100
106
|
}
|
|
101
107
|
|
|
@@ -137,6 +143,10 @@ export function validateWizardVideoInput(input: unknown): WizardVideoInput {
|
|
|
137
143
|
errors.push("resolution (string, optional)");
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
if (obj.audioUrl !== undefined && typeof obj.audioUrl !== "string") {
|
|
147
|
+
errors.push("audioUrl (string, optional)");
|
|
148
|
+
}
|
|
149
|
+
|
|
140
150
|
throw new Error(`Invalid WizardVideoInput: ${errors.join(", ")}`);
|
|
141
151
|
}
|
|
142
152
|
|
|
@@ -22,6 +22,8 @@ export interface WizardScenarioData {
|
|
|
22
22
|
readonly description?: string;
|
|
23
23
|
/** Video feature type - set by main app to control generation mode */
|
|
24
24
|
readonly featureType?: "text-to-video" | "image-to-video";
|
|
25
|
+
/** Pre-generated image URL — when set, video generation uses this as source image instead of extracting from wizard data */
|
|
26
|
+
readonly preGeneratedImageUrl?: string;
|
|
25
27
|
[key: string]: unknown;
|
|
26
28
|
}
|
|
27
29
|
|