@umituz/react-native-ai-gemini-provider 1.14.22 → 1.14.24

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.
@@ -1,265 +1,42 @@
1
1
  /**
2
2
  * Gemini Input Builders
3
- * Constructs Gemini API input from normalized data
4
- */
5
-
6
- // =============================================================================
7
- // TYPES
8
- // =============================================================================
9
-
10
- export interface UpscaleOptions {
11
- scaleFactor?: number;
12
- enhanceFaces?: boolean;
13
- }
14
-
15
- export interface PhotoRestoreOptions {
16
- enhanceFaces?: boolean;
17
- }
18
-
19
- export interface FaceSwapOptions {
20
- // No additional options
21
- }
22
-
23
- export interface AnimeSelfieOptions {
24
- style?: string;
25
- }
26
-
27
- export interface RemoveBackgroundOptions {
28
- // No additional options
29
- }
30
-
31
- export interface RemoveObjectOptions {
32
- mask?: string;
33
- prompt?: string;
34
- }
35
-
36
- export interface ReplaceBackgroundOptions {
37
- prompt: string;
38
- }
39
-
40
- export interface VideoFromImageOptions {
41
- motion_prompt?: string;
42
- duration?: number;
43
- }
44
-
45
- // =============================================================================
46
- // BASE BUILDERS
47
- // =============================================================================
48
-
49
- /**
50
- * Build Gemini single image input format
51
- */
52
- export function buildSingleImageInput(
53
- base64: string,
54
- prompt: string,
55
- ): Record<string, unknown> {
56
- // Remove data: prefix if present
57
- const cleanBase64 = base64.replace(/^data:image\/\w+;base64,/, "");
58
-
59
- return {
60
- contents: [
61
- {
62
- parts: [
63
- { text: prompt },
64
- { inlineData: { mimeType: "image/jpeg", data: cleanBase64 } },
65
- ],
66
- },
67
- ],
68
- };
69
- }
70
-
71
- /**
72
- * Build Gemini dual image input format
73
- */
74
- export function buildDualImageInput(
75
- sourceBase64: string,
76
- targetBase64: string,
77
- prompt: string,
78
- ): Record<string, unknown> {
79
- const cleanSource = sourceBase64.replace(/^data:image\/\w+;base64,/, "");
80
- const cleanTarget = targetBase64.replace(/^data:image\/\w+;base64,/, "");
81
-
82
- return {
83
- contents: [
84
- {
85
- parts: [
86
- { text: prompt },
87
- { inlineData: { mimeType: "image/jpeg", data: cleanSource } },
88
- { inlineData: { mimeType: "image/jpeg", data: cleanTarget } },
89
- ],
90
- },
91
- ],
92
- };
93
- }
94
-
95
- // =============================================================================
96
- // FEATURE-SPECIFIC BUILDERS
97
- // =============================================================================
98
-
99
- /**
100
- * Build upscale input for Gemini
101
- */
102
- export function buildUpscaleInput(
103
- base64: string,
104
- options?: UpscaleOptions,
105
- ): Record<string, unknown> {
106
- const scale = options?.scaleFactor || 2;
107
- const faceEnhance = options?.enhanceFaces
108
- ? " Enhance facial features."
109
- : "";
110
-
111
- const prompt = `Upscale this image by ${scale}x. Preserve all details, colors and enhance clarity.${faceEnhance}`;
112
-
113
- return buildSingleImageInput(base64, prompt);
114
- }
115
-
116
- /**
117
- * Build photo restore input for Gemini
118
- */
119
- export function buildPhotoRestoreInput(
120
- base64: string,
121
- options?: PhotoRestoreOptions,
122
- ): Record<string, unknown> {
123
- const faceEnhance = options?.enhanceFaces !== false
124
- ? " Enhance facial features and expressions."
125
- : "";
126
-
127
- const prompt = `Restore this photo. Remove noise, scratches, and damage while preserving original content.${faceEnhance}`;
128
-
129
- return buildSingleImageInput(base64, prompt);
130
- }
131
-
132
- /**
133
- * Build AI hug video input for Gemini
134
- */
135
- export function buildAIHugInput(
136
- base64: string,
137
- options?: VideoFromImageOptions,
138
- ): Record<string, unknown> {
139
- const motionPrompt = options?.motion_prompt || "Create a warm hugging animation";
140
-
141
- const prompt = `Transform this image into a video. ${motionPrompt}. Make it natural and emotional.`;
142
-
143
- return buildSingleImageInput(base64, prompt);
144
- }
145
-
146
- /**
147
- * Build AI kiss video input for Gemini
148
- */
149
- export function buildAIKissInput(
150
- base64: string,
151
- options?: VideoFromImageOptions,
152
- ): Record<string, unknown> {
153
- const motionPrompt = options?.motion_prompt || "Create a kissing animation";
154
-
155
- const prompt = `Transform this image into a video. ${motionPrompt}. Make it romantic and natural.`;
156
-
157
- return buildSingleImageInput(base64, prompt);
158
- }
159
-
160
- /**
161
- * Build face swap input for Gemini
162
- */
163
- export function buildFaceSwapInput(
164
- sourceBase64: string,
165
- targetBase64: string,
166
- _options?: FaceSwapOptions,
167
- ): Record<string, unknown> {
168
- const prompt = "Swap the face from the first image onto the person in the second image. Preserve lighting, expression, and natural appearance.";
169
-
170
- return buildDualImageInput(sourceBase64, targetBase64, prompt);
171
- }
172
-
173
- /**
174
- * Build anime selfie input for Gemini
175
- */
176
- export function buildAnimeSelfieInput(
177
- base64: string,
178
- options?: AnimeSelfieOptions,
179
- ): Record<string, unknown> {
180
- const style = options?.style || "anime";
181
-
182
- const prompt = `Convert this photo into ${style} style. Preserve facial features and expression while applying artistic transformation.`;
183
-
184
- return buildSingleImageInput(base64, prompt);
185
- }
186
-
187
- /**
188
- * Build remove background input for Gemini
189
- */
190
- export function buildRemoveBackgroundInput(
191
- base64: string,
192
- _options?: RemoveBackgroundOptions,
193
- ): Record<string, unknown> {
194
- const prompt = "Remove the background from this image. Keep only the main subject with transparent background.";
195
-
196
- return buildSingleImageInput(base64, prompt);
197
- }
198
-
199
- /**
200
- * Build remove object (inpaint) input for Gemini
201
- */
202
- export function buildRemoveObjectInput(
203
- base64: string,
204
- options?: RemoveObjectOptions,
205
- ): Record<string, unknown> {
206
- const objectDescription = options?.prompt || "the unwanted object";
207
-
208
- const prompt = `Remove ${objectDescription} from this image and fill the area naturally with the surrounding background.`;
209
-
210
- return buildSingleImageInput(base64, prompt);
211
- }
212
-
213
- /**
214
- * Build replace background input for Gemini
215
- */
216
- export function buildReplaceBackgroundInput(
217
- base64: string,
218
- options: ReplaceBackgroundOptions,
219
- ): Record<string, unknown> {
220
- const prompt = `Replace the background with: ${options.prompt}. Keep the main subject intact and blend naturally.`;
221
-
222
- return buildSingleImageInput(base64, prompt);
223
- }
224
-
225
- /**
226
- * Build HD touch up input (same as upscale with face enhancement)
227
- */
228
- export function buildHDTouchUpInput(
229
- base64: string,
230
- options?: UpscaleOptions,
231
- ): Record<string, unknown> {
232
- return buildUpscaleInput(base64, { ...options, enhanceFaces: true });
233
- }
234
-
235
- // =============================================================================
236
- // VIDEO FEATURE BUILDERS
237
- // =============================================================================
238
-
239
- export interface VideoFromDualImageOptions {
240
- target_image?: string;
241
- motion_prompt?: string;
242
- duration?: number;
243
- }
244
-
245
- /**
246
- * Build video from dual images input for Gemini
247
- * Used for ai-hug and ai-kiss features that need source and target images
248
- */
249
- export function buildVideoFromDualImagesInput(
250
- sourceBase64: string,
251
- options?: VideoFromDualImageOptions,
252
- ): Record<string, unknown> {
253
- const targetBase64 = options?.target_image || "";
254
- const motionPrompt = options?.motion_prompt || "Create an animated interaction between the two people";
255
-
256
- if (!targetBase64) {
257
- // Single image case (fallback)
258
- const prompt = `Transform this image into a video. ${motionPrompt}. Make it natural and emotional.`;
259
- return buildSingleImageInput(sourceBase64, prompt);
260
- }
261
-
262
- const prompt = `Transform these two images into a video. ${motionPrompt}. Make it natural and emotional. The first image is the source person, the second is the target person.`;
263
-
264
- return buildDualImageInput(sourceBase64, targetBase64, prompt);
265
- }
3
+ * Central export point for all input builder functions
4
+ */
5
+
6
+ // Base builders
7
+ export {
8
+ buildSingleImageInput,
9
+ buildDualImageInput,
10
+ } from "./base-input-builders.util";
11
+
12
+ // Image feature builders
13
+ export {
14
+ buildUpscaleInput,
15
+ buildPhotoRestoreInput,
16
+ buildFaceSwapInput,
17
+ buildAnimeSelfieInput,
18
+ buildRemoveBackgroundInput,
19
+ buildRemoveObjectInput,
20
+ buildReplaceBackgroundInput,
21
+ buildHDTouchUpInput,
22
+ } from "./image-feature-builders.util";
23
+
24
+ // Video feature builders
25
+ export {
26
+ buildAIHugInput,
27
+ buildAIKissInput,
28
+ buildVideoFromDualImagesInput,
29
+ } from "./video-feature-builders.util";
30
+
31
+ // Types
32
+ export type {
33
+ UpscaleOptions,
34
+ PhotoRestoreOptions,
35
+ FaceSwapOptions,
36
+ AnimeSelfieOptions,
37
+ RemoveBackgroundOptions,
38
+ RemoveObjectOptions,
39
+ ReplaceBackgroundOptions,
40
+ VideoFromImageOptions,
41
+ VideoFromDualImageOptions,
42
+ } from "./input-builder.types";
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Video Feature Input Builders
3
+ * Constructs Gemini API inputs for video generation features
4
+ */
5
+
6
+ import { buildSingleImageInput, buildDualImageInput } from "./base-input-builders.util";
7
+ import type { VideoFromImageOptions, VideoFromDualImageOptions } from "./input-builder.types";
8
+
9
+ /**
10
+ * Build AI hug video input for Gemini
11
+ */
12
+ export function buildAIHugInput(
13
+ base64: string,
14
+ options?: VideoFromImageOptions,
15
+ ): Record<string, unknown> {
16
+ const motionPrompt = options?.motion_prompt || "Create a warm hugging animation";
17
+
18
+ const prompt = `Transform this image into a video. ${motionPrompt}. Make it natural and emotional.`;
19
+
20
+ return buildSingleImageInput(base64, prompt);
21
+ }
22
+
23
+ /**
24
+ * Build AI kiss video input for Gemini
25
+ */
26
+ export function buildAIKissInput(
27
+ base64: string,
28
+ options?: VideoFromImageOptions,
29
+ ): Record<string, unknown> {
30
+ const motionPrompt = options?.motion_prompt || "Create a kissing animation";
31
+
32
+ const prompt = `Transform this image into a video. ${motionPrompt}. Make it romantic and natural.`;
33
+
34
+ return buildSingleImageInput(base64, prompt);
35
+ }
36
+
37
+ /**
38
+ * Build video from dual images input for Gemini
39
+ * Used for ai-hug and ai-kiss features that need source and target images
40
+ */
41
+ export function buildVideoFromDualImagesInput(
42
+ sourceBase64: string,
43
+ options?: VideoFromDualImageOptions,
44
+ ): Record<string, unknown> {
45
+ const targetBase64 = options?.target_image || "";
46
+ const motionPrompt = options?.motion_prompt || "Create an animated interaction between the two people";
47
+
48
+ if (!targetBase64) {
49
+ // Single image case (fallback)
50
+ const prompt = `Transform this image into a video. ${motionPrompt}. Make it natural and emotional.`;
51
+ return buildSingleImageInput(sourceBase64, prompt);
52
+ }
53
+
54
+ const prompt = `Transform these two images into a video. ${motionPrompt}. Make it natural and emotional. The first image is the source person, the second is the target person.`;
55
+
56
+ return buildDualImageInput(sourceBase64, targetBase64, prompt);
57
+ }