@umituz/react-native-ai-generation-content 1.84.7 → 1.84.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.84.7",
3
+ "version": "1.84.9",
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) */
@@ -50,6 +50,9 @@ function buildGenericInput(input: WizardVideoInput): Record<string, unknown> {
50
50
  if (input.resolution) {
51
51
  modelInput.resolution = input.resolution;
52
52
  }
53
+ if (input.audioUrl) {
54
+ modelInput.audio = input.audioUrl;
55
+ }
53
56
 
54
57
  return modelInput;
55
58
  }
@@ -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 { readFileAsBase64 } from "@umituz/react-native-design-system/filesystem";
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 readFileAsBase64(audioData.uri);
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,12 +46,16 @@ 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
+
26
52
  // If a pre-generated image URL exists (e.g., two-step solo video),
27
53
  // use it directly instead of extracting photos from wizard data
28
54
  if (scenario.preGeneratedImageUrl) {
29
55
  if (typeof __DEV__ !== "undefined" && __DEV__) {
30
56
  console.log("[VideoStrategy] Using pre-generated image URL", {
31
57
  url: scenario.preGeneratedImageUrl.slice(0, 80),
58
+ hasAudio: !!audioUrl,
32
59
  });
33
60
  }
34
61
  const finalPrompt = extractPrompt(wizardData, scenario.aiPrompt) || scenario.aiPrompt || "";
@@ -38,6 +65,7 @@ export async function buildVideoInput(
38
65
  duration: extractDuration(wizardData),
39
66
  aspectRatio: extractAspectRatio(wizardData),
40
67
  resolution: extractResolution(wizardData),
68
+ audioUrl,
41
69
  };
42
70
  }
43
71
 
@@ -63,12 +91,11 @@ export async function buildVideoInput(
63
91
  }
64
92
  }
65
93
 
66
- // For video generation, use clean prompt directly
67
- // Modern models handle context natively
68
94
  if (typeof __DEV__ !== "undefined" && __DEV__) {
69
95
  console.log("[VideoStrategy] Using clean prompt for video generation", {
70
96
  promptLength: finalPrompt.length,
71
97
  photoCount: photos.length,
98
+ hasAudio: !!audioUrl,
72
99
  });
73
100
  }
74
101
 
@@ -79,6 +106,7 @@ export async function buildVideoInput(
79
106
  duration: extractDuration(wizardData),
80
107
  aspectRatio: extractAspectRatio(wizardData),
81
108
  resolution: extractResolution(wizardData),
109
+ audioUrl,
82
110
  };
83
111
  }
84
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