@umituz/react-native-ai-generation-content 1.28.2 → 1.28.4
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/ai-provider.interface.ts +6 -2
- package/src/domains/generation/wizard/domain/entities/wizard-config.types.ts +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +14 -4
- package/src/domains/generation/wizard/infrastructure/utils/index.ts +2 -0
- package/src/domains/generation/wizard/infrastructure/utils/wizard-data-extractors.ts +36 -0
- package/src/infrastructure/services/video-feature-executor.types.ts +6 -2
- package/src/infrastructure/utils/photo-generation/photo-preparation.util.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.4",
|
|
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",
|
|
@@ -141,9 +141,13 @@ export interface ImageFeatureInputData {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export interface VideoFeatureInputData {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
/** Source image (required for image-to-video, optional for text-to-video) */
|
|
145
|
+
sourceImageBase64?: string;
|
|
146
|
+
/** Target image (optional, used for dual-image features like ai-kiss, ai-hug) */
|
|
147
|
+
targetImageBase64?: string;
|
|
148
|
+
/** Generation prompt (required for text-to-video) */
|
|
146
149
|
prompt?: string;
|
|
150
|
+
/** Additional generation options */
|
|
147
151
|
options?: Record<string, unknown>;
|
|
148
152
|
}
|
|
149
153
|
|
|
@@ -51,7 +51,7 @@ export interface TextInputStepConfig extends BaseStepConfig {
|
|
|
51
51
|
*/
|
|
52
52
|
export interface SelectionStepConfig extends BaseStepConfig {
|
|
53
53
|
readonly type: "selection";
|
|
54
|
-
readonly selectionType: "style" | "duration" | "aspect_ratio" | "quality" | "custom";
|
|
54
|
+
readonly selectionType: "style" | "duration" | "aspect_ratio" | "quality" | "resolution" | "custom";
|
|
55
55
|
readonly options: readonly {
|
|
56
56
|
readonly id: string;
|
|
57
57
|
readonly label: string;
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { createCreationsRepository } from "../../../../creations/infrastructure/
|
|
|
10
10
|
import type { WizardScenarioData } from "../../presentation/hooks/useWizardGeneration";
|
|
11
11
|
import type { WizardStrategy } from "./wizard-strategy.types";
|
|
12
12
|
import { PHOTO_KEY_PREFIX, VIDEO_FEATURE_PATTERNS } from "./wizard-strategy.constants";
|
|
13
|
-
import { extractPrompt, extractDuration } from "../utils";
|
|
13
|
+
import { extractPrompt, extractDuration, extractAspectRatio, extractResolution } from "../utils";
|
|
14
14
|
|
|
15
15
|
// ============================================================================
|
|
16
16
|
// Types
|
|
@@ -24,6 +24,10 @@ export interface VideoGenerationInput {
|
|
|
24
24
|
readonly prompt: string;
|
|
25
25
|
/** Video duration in seconds */
|
|
26
26
|
readonly duration?: number;
|
|
27
|
+
/** Aspect ratio (e.g., "16:9", "9:16") */
|
|
28
|
+
readonly aspectRatio?: string;
|
|
29
|
+
/** Video resolution (e.g., "720p", "1080p") */
|
|
30
|
+
readonly resolution?: string;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export interface VideoGenerationResult {
|
|
@@ -94,14 +98,18 @@ export async function buildVideoInput(
|
|
|
94
98
|
throw new Error("Prompt is required for video generation");
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
// Extract
|
|
101
|
+
// Extract video generation parameters
|
|
98
102
|
const duration = extractDuration(wizardData);
|
|
103
|
+
const aspectRatio = extractAspectRatio(wizardData);
|
|
104
|
+
const resolution = extractResolution(wizardData);
|
|
99
105
|
|
|
100
106
|
return {
|
|
101
107
|
sourceImageBase64: photos[0],
|
|
102
108
|
targetImageBase64: photos[1] || photos[0],
|
|
103
109
|
prompt,
|
|
104
110
|
duration,
|
|
111
|
+
aspectRatio,
|
|
112
|
+
resolution,
|
|
105
113
|
};
|
|
106
114
|
}
|
|
107
115
|
|
|
@@ -129,11 +137,13 @@ export function createVideoStrategy(options: CreateVideoStrategyOptions): Wizard
|
|
|
129
137
|
const result = await executeVideoFeature(
|
|
130
138
|
videoFeatureType,
|
|
131
139
|
{
|
|
132
|
-
sourceImageBase64: videoInput.sourceImageBase64
|
|
133
|
-
targetImageBase64: videoInput.targetImageBase64
|
|
140
|
+
sourceImageBase64: videoInput.sourceImageBase64,
|
|
141
|
+
targetImageBase64: videoInput.targetImageBase64,
|
|
134
142
|
prompt: videoInput.prompt,
|
|
135
143
|
options: {
|
|
136
144
|
duration: videoInput.duration,
|
|
145
|
+
aspect_ratio: videoInput.aspectRatio,
|
|
146
|
+
resolution: videoInput.resolution,
|
|
137
147
|
},
|
|
138
148
|
},
|
|
139
149
|
{ onProgress },
|
|
@@ -194,3 +194,39 @@ export function extractDuration(
|
|
|
194
194
|
|
|
195
195
|
return undefined;
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
// ============================================================================
|
|
199
|
+
// Aspect Ratio Extractor (Specialized)
|
|
200
|
+
// ============================================================================
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Extracts aspect ratio from wizard data
|
|
204
|
+
* Common values: "16:9", "9:16", "1:1", "4:3"
|
|
205
|
+
*
|
|
206
|
+
* @param wizardData - The wizard data object
|
|
207
|
+
* @returns The extracted aspect ratio or undefined
|
|
208
|
+
*/
|
|
209
|
+
export function extractAspectRatio(
|
|
210
|
+
wizardData: Record<string, unknown>,
|
|
211
|
+
): string | undefined {
|
|
212
|
+
const aspectRatioData = wizardData.aspect_ratio;
|
|
213
|
+
return extractTrimmedString(aspectRatioData);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Resolution Extractor (Specialized)
|
|
218
|
+
// ============================================================================
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Extracts resolution from wizard data
|
|
222
|
+
* Common values: "720p", "1080p", "default"
|
|
223
|
+
*
|
|
224
|
+
* @param wizardData - The wizard data object
|
|
225
|
+
* @returns The extracted resolution or undefined
|
|
226
|
+
*/
|
|
227
|
+
export function extractResolution(
|
|
228
|
+
wizardData: Record<string, unknown>,
|
|
229
|
+
): string | undefined {
|
|
230
|
+
const resolutionData = wizardData.resolution;
|
|
231
|
+
return extractTrimmedString(resolutionData);
|
|
232
|
+
}
|
|
@@ -27,8 +27,12 @@ export interface VideoFeatureResult {
|
|
|
27
27
|
* Request data for video features
|
|
28
28
|
*/
|
|
29
29
|
export interface VideoFeatureRequest {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
/** Source image (required for image-to-video, optional for text-to-video) */
|
|
31
|
+
sourceImageBase64?: string;
|
|
32
|
+
/** Target image (optional, used for dual-image features) */
|
|
33
|
+
targetImageBase64?: string;
|
|
34
|
+
/** Generation prompt (required for text-to-video) */
|
|
32
35
|
prompt?: string;
|
|
36
|
+
/** Additional options */
|
|
33
37
|
options?: Record<string, unknown>;
|
|
34
38
|
}
|
|
@@ -17,8 +17,10 @@ export interface PreparedImage {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Clean base64 string by removing data URI prefix
|
|
20
|
+
* Returns empty string if input is undefined or empty
|
|
20
21
|
*/
|
|
21
|
-
export const cleanBase64 = (base64: string): string => {
|
|
22
|
+
export const cleanBase64 = (base64: string | undefined): string => {
|
|
23
|
+
if (!base64) return "";
|
|
22
24
|
return base64.replace(/^data:image\/(png|jpeg|jpg|webp);base64,/, "");
|
|
23
25
|
};
|
|
24
26
|
|