@umituz/react-native-ai-fal-provider 1.0.32 → 1.0.34

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-fal-provider",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@fal-ai/client": ">=0.6.0",
31
- "@umituz/react-native-ai-generation-content": ">=1.16.0",
31
+ "@umituz/react-native-ai-generation-content": ">=1.17.0",
32
32
  "react": ">=18.2.0",
33
33
  "react-native": ">=0.74.0"
34
34
  },
@@ -9,3 +9,14 @@ export type {
9
9
  ModelSelectionActions,
10
10
  UseModelsReturn,
11
11
  } from "./model-selection.types";
12
+
13
+ export type {
14
+ UpscaleOptions,
15
+ PhotoRestoreOptions,
16
+ ImageToImagePromptConfig,
17
+ RemoveBackgroundOptions,
18
+ RemoveObjectOptions,
19
+ ReplaceBackgroundOptions,
20
+ VideoFromImageOptions,
21
+ FaceSwapOptions,
22
+ } from "./input-builders.types";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * FAL Input Builder Types
3
+ */
4
+
5
+ export interface UpscaleOptions {
6
+ scaleFactor?: number;
7
+ enhanceFaces?: boolean;
8
+ }
9
+
10
+ export interface PhotoRestoreOptions {
11
+ enhanceFaces?: boolean;
12
+ }
13
+
14
+ export interface ImageToImagePromptConfig {
15
+ prompt: string;
16
+ negativePrompt: string;
17
+ strength?: number;
18
+ guidance_scale?: number;
19
+ num_inference_steps?: number;
20
+ }
21
+
22
+ export interface RemoveBackgroundOptions {
23
+ // No additional options
24
+ }
25
+
26
+ export interface RemoveObjectOptions {
27
+ mask?: string;
28
+ prompt?: string;
29
+ }
30
+
31
+ export interface ReplaceBackgroundOptions {
32
+ prompt: string;
33
+ }
34
+
35
+ export interface VideoFromImageOptions {
36
+ target_image?: string;
37
+ motion_prompt?: string;
38
+ duration?: number;
39
+ }
40
+
41
+ export interface FaceSwapOptions {
42
+ // No additional options
43
+ }
package/src/index.ts CHANGED
@@ -1,154 +1,48 @@
1
1
  /**
2
2
  * @umituz/react-native-ai-fal-provider
3
3
  * FAL AI provider for React Native - implements IAIProvider interface
4
- *
5
- * Usage:
6
- * import {
7
- * FalProvider,
8
- * falProvider,
9
- * providerRegistry,
10
- * } from '@umituz/react-native-ai-fal-provider';
11
- * import { providerRegistry } from '@umituz/react-native-ai-generation-content';
12
- *
13
- * // Register provider at app startup
14
- * falProvider.initialize({ apiKey: 'your-api-key' });
15
- * providerRegistry.register(falProvider);
16
- * providerRegistry.setActiveProvider('fal');
17
4
  */
18
5
 
19
- // =============================================================================
20
- // DOMAIN LAYER - Types
21
- // =============================================================================
22
-
23
6
  export type {
24
- FalConfig,
25
- FalModel,
26
- FalModelType,
27
- FalModelPricing,
28
- FalJobInput,
29
- FalJobResult,
30
- FalLogEntry,
31
- FalQueueStatus,
32
- FalSubscribeOptions,
7
+ FalConfig, FalModel, FalModelType, FalModelPricing, FalJobInput,
8
+ FalJobResult, FalLogEntry, FalQueueStatus, FalSubscribeOptions,
33
9
  } from "./domain/entities/fal.types";
34
10
 
35
- export {
36
- FalErrorType,
37
- } from "./domain/entities/error.types";
38
-
39
- export type {
40
- FalErrorCategory,
41
- FalErrorInfo,
42
- FalErrorMessages,
43
- } from "./domain/entities/error.types";
44
-
45
- // =============================================================================
46
- // DOMAIN LAYER - Default Models
47
- // =============================================================================
11
+ export { FalErrorType } from "./domain/entities/error.types";
12
+ export type { FalErrorCategory, FalErrorInfo, FalErrorMessages } from "./domain/entities/error.types";
48
13
 
49
14
  export {
50
- DEFAULT_TEXT_TO_IMAGE_MODELS,
51
- DEFAULT_TEXT_TO_VOICE_MODELS,
52
- DEFAULT_TEXT_TO_VIDEO_MODELS,
53
- DEFAULT_IMAGE_TO_VIDEO_MODELS,
54
- getAllDefaultModels,
55
- getDefaultModelsByType,
56
- getDefaultModel,
57
- findModelById,
15
+ DEFAULT_TEXT_TO_IMAGE_MODELS, DEFAULT_TEXT_TO_VOICE_MODELS,
16
+ DEFAULT_TEXT_TO_VIDEO_MODELS, DEFAULT_IMAGE_TO_VIDEO_MODELS,
17
+ getAllDefaultModels, getDefaultModelsByType, getDefaultModel, findModelById,
58
18
  } from "./domain/constants/default-models.constants";
59
-
60
19
  export type { FalModelConfig } from "./domain/constants/default-models.constants";
61
20
 
62
- // =============================================================================
63
- // DOMAIN LAYER - Feature Models
64
- // =============================================================================
65
-
66
21
  export {
67
- FAL_IMAGE_FEATURE_MODELS,
68
- FAL_VIDEO_FEATURE_MODELS,
69
- getAllFeatureModels,
22
+ FAL_IMAGE_FEATURE_MODELS, FAL_VIDEO_FEATURE_MODELS, getAllFeatureModels,
70
23
  } from "./domain/constants/feature-models.constants";
24
+ export type { FeatureModelConfig } from "./domain/constants/feature-models.constants";
71
25
 
72
- // Feature model getters (use these instead of deprecated getFal* functions)
73
26
  export {
74
- getImageFeatureModel,
75
- getVideoFeatureModel,
27
+ FalProvider, falProvider, falModelsService,
28
+ getImageFeatureModel, getVideoFeatureModel,
76
29
  } from "./infrastructure/services";
77
-
78
- export type {
79
- FeatureModelConfig,
80
- } from "./domain/constants/feature-models.constants";
81
-
82
- // =============================================================================
83
- // INFRASTRUCTURE LAYER - Provider (IAIProvider Implementation)
84
- // =============================================================================
85
-
86
- export { FalProvider, falProvider } from "./infrastructure/services";
87
-
88
- // =============================================================================
89
- // INFRASTRUCTURE LAYER - Services
90
- // =============================================================================
91
-
92
- export { falModelsService } from "./infrastructure/services";
93
30
  export type { ModelFetcher } from "./infrastructure/services";
94
31
 
95
- // =============================================================================
96
- // INFRASTRUCTURE LAYER - Utils
97
- // =============================================================================
98
-
99
32
  export {
100
- categorizeFalError,
101
- falErrorMapper,
102
- mapFalError,
103
- isFalErrorRetryable,
104
- // Input builders
105
- buildSingleImageInput,
106
- buildDualImageInput,
107
- buildUpscaleInput,
108
- buildPhotoRestoreInput,
109
- buildVideoFromImageInput,
110
- buildFaceSwapInput,
111
- buildAnimeSelfieInput,
112
- buildRemoveBackgroundInput,
113
- buildRemoveObjectInput,
114
- buildReplaceBackgroundInput,
115
- buildHDTouchUpInput,
33
+ categorizeFalError, falErrorMapper, mapFalError, isFalErrorRetryable,
34
+ buildSingleImageInput, buildDualImageInput, buildUpscaleInput,
35
+ buildPhotoRestoreInput, buildVideoFromImageInput, buildFaceSwapInput,
36
+ buildImageToImageInput, buildRemoveBackgroundInput, buildRemoveObjectInput,
37
+ buildReplaceBackgroundInput, buildHDTouchUpInput,
116
38
  } from "./infrastructure/utils";
117
39
 
118
40
  export type {
119
- UpscaleOptions,
120
- PhotoRestoreOptions,
121
- FaceSwapOptions,
122
- AnimeSelfieOptions,
123
- RemoveBackgroundOptions,
124
- RemoveObjectOptions,
125
- ReplaceBackgroundOptions,
126
- VideoFromImageOptions,
127
- } from "./infrastructure/utils";
128
-
129
- // =============================================================================
130
- // DOMAIN LAYER - Model Selection Types
131
- // =============================================================================
132
-
133
- export type {
134
- ModelType,
135
- ModelSelectionConfig,
136
- ModelSelectionState,
137
- ModelSelectionActions,
138
- UseModelsReturn,
41
+ UpscaleOptions, PhotoRestoreOptions, FaceSwapOptions, ImageToImagePromptConfig,
42
+ RemoveBackgroundOptions, RemoveObjectOptions, ReplaceBackgroundOptions,
43
+ VideoFromImageOptions, ModelType, ModelSelectionConfig, ModelSelectionState,
44
+ ModelSelectionActions, UseModelsReturn,
139
45
  } from "./domain/types";
140
46
 
141
- // =============================================================================
142
- // PRESENTATION LAYER - Hooks
143
- // =============================================================================
144
-
145
- export {
146
- useFalGeneration,
147
- useModels,
148
- } from "./presentation/hooks";
149
-
150
- export type {
151
- UseFalGenerationOptions,
152
- UseFalGenerationResult,
153
- UseModelsProps,
154
- } from "./presentation/hooks";
47
+ export { useFalGeneration, useModels } from "./presentation/hooks";
48
+ export type { UseFalGenerationOptions, UseFalGenerationResult, UseModelsProps } from "./presentation/hooks";
@@ -20,12 +20,7 @@ import type {
20
20
  import type { FalQueueStatus } from "../../domain/entities/fal.types";
21
21
  import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
22
22
  import { mapFalStatusToJobStatus } from "./fal-status-mapper";
23
- import {
24
- getImageFeatureModel,
25
- getVideoFeatureModel,
26
- buildImageFeatureInput,
27
- buildVideoFeatureInput,
28
- } from "./fal-feature-builder.service";
23
+ import { FAL_IMAGE_FEATURE_MODELS, FAL_VIDEO_FEATURE_MODELS } from "../../domain/constants/feature-models.constants";
29
24
 
30
25
  declare const __DEV__: boolean;
31
26
 
@@ -178,19 +173,19 @@ export class FalProvider implements IAIProvider {
178
173
  }
179
174
 
180
175
  getImageFeatureModel(feature: ImageFeatureType): string {
181
- return getImageFeatureModel(feature);
176
+ return FAL_IMAGE_FEATURE_MODELS[feature];
182
177
  }
183
178
 
184
- buildImageFeatureInput(feature: ImageFeatureType, data: ImageFeatureInputData): Record<string, unknown> {
185
- return buildImageFeatureInput(feature, data);
179
+ buildImageFeatureInput(_feature: ImageFeatureType, _data: ImageFeatureInputData): Record<string, unknown> {
180
+ throw new Error("Use input builders directly: buildUpscaleInput, buildFaceSwapInput, etc.");
186
181
  }
187
182
 
188
183
  getVideoFeatureModel(feature: VideoFeatureType): string {
189
- return getVideoFeatureModel(feature);
184
+ return FAL_VIDEO_FEATURE_MODELS[feature];
190
185
  }
191
186
 
192
- buildVideoFeatureInput(feature: VideoFeatureType, data: VideoFeatureInputData): Record<string, unknown> {
193
- return buildVideoFeatureInput(feature, data);
187
+ buildVideoFeatureInput(_feature: VideoFeatureType, _data: VideoFeatureInputData): Record<string, unknown> {
188
+ throw new Error("Use buildVideoFromImageInput directly");
194
189
  }
195
190
  }
196
191
 
@@ -1,13 +1,17 @@
1
1
  /**
2
2
  * Services Index
3
- * Exports all infrastructure services
4
3
  */
5
4
 
5
+ import { FAL_IMAGE_FEATURE_MODELS, FAL_VIDEO_FEATURE_MODELS } from "../../domain/constants/feature-models.constants";
6
+ import type { ImageFeatureType, VideoFeatureType } from "@umituz/react-native-ai-generation-content";
7
+
6
8
  export { FalProvider, falProvider } from "./fal-provider";
7
9
  export { falModelsService, type FalModelConfig, type ModelFetcher } from "./fal-models.service";
8
- export {
9
- getImageFeatureModel,
10
- getVideoFeatureModel,
11
- buildImageFeatureInput,
12
- buildVideoFeatureInput,
13
- } from "./fal-feature-builder.service";
10
+
11
+ export function getImageFeatureModel(feature: ImageFeatureType): string {
12
+ return FAL_IMAGE_FEATURE_MODELS[feature];
13
+ }
14
+
15
+ export function getVideoFeatureModel(feature: VideoFeatureType): string {
16
+ return FAL_VIDEO_FEATURE_MODELS[feature];
17
+ }
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * Utils Index
3
- * Exports all utility functions
4
3
  */
5
4
 
6
5
  export { categorizeFalError } from "./error-categorizer";
7
6
  export { falErrorMapper, mapFalError, isFalErrorRetryable } from "./error-mapper";
8
7
 
9
- // Input builders
10
8
  export {
11
9
  buildSingleImageInput,
12
10
  buildDualImageInput,
@@ -14,20 +12,9 @@ export {
14
12
  buildPhotoRestoreInput,
15
13
  buildVideoFromImageInput,
16
14
  buildFaceSwapInput,
17
- buildAnimeSelfieInput,
15
+ buildImageToImageInput,
18
16
  buildRemoveBackgroundInput,
19
17
  buildRemoveObjectInput,
20
18
  buildReplaceBackgroundInput,
21
19
  buildHDTouchUpInput,
22
20
  } from "./input-builders.util";
23
-
24
- export type {
25
- UpscaleOptions,
26
- PhotoRestoreOptions,
27
- FaceSwapOptions,
28
- AnimeSelfieOptions,
29
- RemoveBackgroundOptions,
30
- RemoveObjectOptions,
31
- ReplaceBackgroundOptions,
32
- VideoFromImageOptions,
33
- } from "./input-builders.util";
@@ -1,106 +1,18 @@
1
1
  /**
2
- * FAL Input Builders
3
- * Constructs FAL API input from normalized data
4
- *
5
- * NOTE: Once @umituz/react-native-ai-generation-content is published with
6
- * ImagePromptBuilder, replace buildAnimeSelfiePrompt with:
7
- *
8
- * import { createAnimeSelfiePrompt, createStyleTransferPrompt }
9
- * from "@umituz/react-native-ai-generation-content";
2
+ * FAL Input Builders - Constructs FAL API input from normalized data
3
+ * Provider-agnostic: accepts prompt config as parameter, not imported
10
4
  */
11
5
 
12
- // =============================================================================
13
- // INTERNAL PROMPT BUILDING (temporary - will use ImagePromptBuilder after publish)
14
- // =============================================================================
15
-
16
- const ANIME_SELFIE_PROMPT = [
17
- // Anime style FIRST - highest priority
18
- "anime style portrait",
19
- "2D anime illustration",
20
- "japanese anime art style",
21
- "cel-shaded anime character",
22
- "large sparkling anime eyes with detailed iris",
23
- "smooth cel-shaded skin with subtle anime blush",
24
- "stylized anime hair with highlights",
25
- "Studio Ghibli inspired",
26
- "vibrant anime colors",
27
- "clean anime lineart",
28
- "professional anime portrait",
29
- "hand drawn anime",
30
- "manga style",
31
- // Identity preservation - secondary
32
- "same person",
33
- "preserve original gender",
34
- "same facial features",
35
- ].join(", ");
36
-
37
- const ANIME_SELFIE_NEGATIVE_PROMPT = [
38
- // Identity negative
39
- "gender swap",
40
- "different person",
41
- "wrong gender",
42
- "changed identity",
43
- // Anti-realism
44
- "photorealistic",
45
- "realistic photo",
46
- "3D render",
47
- "hyperrealistic",
48
- "real person",
49
- "natural skin texture",
50
- "pores",
51
- "wrinkles",
52
- // Anatomy negative
53
- "deformed face",
54
- "bad anatomy",
55
- "extra limbs",
56
- "mutated hands",
57
- "extra fingers",
58
- "missing fingers",
59
- ].join(", ");
60
-
61
- // =============================================================================
62
- // TYPES
63
- // =============================================================================
64
-
65
- export interface UpscaleOptions {
66
- scaleFactor?: number;
67
- enhanceFaces?: boolean;
68
- }
69
-
70
- export interface PhotoRestoreOptions {
71
- enhanceFaces?: boolean;
72
- }
73
-
74
- export interface FaceSwapOptions {
75
- // No additional options
76
- }
77
-
78
- export interface AnimeSelfieOptions {
79
- style?: string;
80
- }
81
-
82
- export interface RemoveBackgroundOptions {
83
- // No additional options
84
- }
85
-
86
- export interface RemoveObjectOptions {
87
- mask?: string;
88
- prompt?: string;
89
- }
90
-
91
- export interface ReplaceBackgroundOptions {
92
- prompt: string;
93
- }
94
-
95
- export interface VideoFromImageOptions {
96
- target_image?: string;
97
- motion_prompt?: string;
98
- duration?: number;
99
- }
100
-
101
- // =============================================================================
102
- // BASE BUILDERS
103
- // =============================================================================
6
+ import type {
7
+ UpscaleOptions,
8
+ PhotoRestoreOptions,
9
+ ImageToImagePromptConfig,
10
+ RemoveBackgroundOptions,
11
+ RemoveObjectOptions,
12
+ ReplaceBackgroundOptions,
13
+ VideoFromImageOptions,
14
+ FaceSwapOptions,
15
+ } from "../../domain/types";
104
16
 
105
17
  /**
106
18
  * Build FAL single image input format
@@ -197,26 +109,19 @@ export function buildFaceSwapInput(
197
109
  }
198
110
 
199
111
  /**
200
- * Build anime selfie input for FAL flux/dev/image-to-image
201
- * Transforms person's photo to anime style while preserving facial features
202
- *
203
- * Uses comprehensive identity preservation + anime style prompts
204
- * After @umituz/react-native-ai-generation-content publish, will use ImagePromptBuilder
112
+ * Build image-to-image input for FAL flux/dev/image-to-image
113
+ * Accepts prompt config as parameter for provider-agnostic usage
205
114
  */
206
- export function buildAnimeSelfieInput(
115
+ export function buildImageToImageInput(
207
116
  base64: string,
208
- options?: AnimeSelfieOptions,
117
+ promptConfig: ImageToImagePromptConfig,
209
118
  ): Record<string, unknown> {
210
- const prompt = options?.style
211
- ? `${options.style} style, ${ANIME_SELFIE_PROMPT}`
212
- : ANIME_SELFIE_PROMPT;
213
-
214
119
  return buildSingleImageInput(base64, {
215
- prompt,
216
- negative_prompt: ANIME_SELFIE_NEGATIVE_PROMPT,
217
- strength: 0.92,
218
- num_inference_steps: 50,
219
- guidance_scale: 8.5,
120
+ prompt: promptConfig.prompt,
121
+ negative_prompt: promptConfig.negativePrompt,
122
+ strength: promptConfig.strength ?? 0.85,
123
+ num_inference_steps: promptConfig.num_inference_steps ?? 50,
124
+ guidance_scale: promptConfig.guidance_scale ?? 7.5,
220
125
  });
221
126
  }
222
127
 
@@ -1,87 +0,0 @@
1
- /**
2
- * FAL Feature Builder Service
3
- * Handles building input data for different AI features
4
- */
5
-
6
- import type {
7
- ImageFeatureType,
8
- VideoFeatureType,
9
- ImageFeatureInputData,
10
- VideoFeatureInputData,
11
- } from "@umituz/react-native-ai-generation-content";
12
- import {
13
- FAL_IMAGE_FEATURE_MODELS,
14
- FAL_VIDEO_FEATURE_MODELS,
15
- } from "../../domain/constants/feature-models.constants";
16
- import {
17
- buildUpscaleInput,
18
- buildPhotoRestoreInput,
19
- buildVideoFromImageInput,
20
- buildFaceSwapInput,
21
- buildAnimeSelfieInput,
22
- buildRemoveBackgroundInput,
23
- buildRemoveObjectInput,
24
- buildReplaceBackgroundInput,
25
- buildHDTouchUpInput,
26
- } from "../utils/input-builders.util";
27
-
28
- export function getImageFeatureModel(feature: ImageFeatureType): string {
29
- return FAL_IMAGE_FEATURE_MODELS[feature];
30
- }
31
-
32
- export function getVideoFeatureModel(feature: VideoFeatureType): string {
33
- return FAL_VIDEO_FEATURE_MODELS[feature];
34
- }
35
-
36
- export function buildImageFeatureInput(
37
- feature: ImageFeatureType,
38
- data: ImageFeatureInputData,
39
- ): Record<string, unknown> {
40
- const { imageBase64, targetImageBase64, prompt, options } = data;
41
-
42
- switch (feature) {
43
- case "upscale":
44
- return buildUpscaleInput(imageBase64, options);
45
- case "photo-restore":
46
- return buildPhotoRestoreInput(imageBase64, options);
47
- case "face-swap":
48
- if (!targetImageBase64) {
49
- throw new Error("Face swap requires target image");
50
- }
51
- return buildFaceSwapInput(imageBase64, targetImageBase64, options);
52
- case "anime-selfie":
53
- return buildAnimeSelfieInput(imageBase64, options);
54
- case "remove-background":
55
- return buildRemoveBackgroundInput(imageBase64, options);
56
- case "remove-object":
57
- return buildRemoveObjectInput(imageBase64, { prompt, ...options });
58
- case "hd-touch-up":
59
- return buildHDTouchUpInput(imageBase64, options);
60
- case "replace-background":
61
- if (!prompt) {
62
- throw new Error("Replace background requires prompt");
63
- }
64
- return buildReplaceBackgroundInput(imageBase64, { prompt });
65
- default:
66
- throw new Error(`Unknown image feature: ${String(feature)}`);
67
- }
68
- }
69
-
70
- export function buildVideoFeatureInput(
71
- feature: VideoFeatureType,
72
- data: VideoFeatureInputData,
73
- ): Record<string, unknown> {
74
- const { sourceImageBase64, targetImageBase64, prompt, options } = data;
75
-
76
- switch (feature) {
77
- case "ai-hug":
78
- case "ai-kiss":
79
- return buildVideoFromImageInput(sourceImageBase64, {
80
- target_image: targetImageBase64,
81
- motion_prompt: prompt,
82
- ...options,
83
- });
84
- default:
85
- throw new Error(`Unknown video feature: ${String(feature)}`);
86
- }
87
- }