@umituz/react-native-ai-fal-provider 2.0.18 → 2.0.19

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": "2.0.18",
3
+ "version": "2.0.19",
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",
@@ -39,8 +39,6 @@ export interface AIProviderConfig {
39
39
  textToImageModel?: string;
40
40
  imageEditModel?: string;
41
41
  videoGenerationModel?: string;
42
- videoFeatureModels?: Partial<Record<VideoFeatureType, string>>;
43
- imageFeatureModels?: Partial<Record<ImageFeatureType, string>>;
44
42
  }
45
43
 
46
44
  // =============================================================================
@@ -18,15 +18,6 @@ export {
18
18
  isFalErrorRetryable,
19
19
  buildSingleImageInput,
20
20
  buildDualImageInput,
21
- buildUpscaleInput,
22
- buildPhotoRestoreInput,
23
- buildVideoFromImageInput,
24
- buildFaceSwapInput,
25
- buildImageToImageInput,
26
- buildRemoveBackgroundInput,
27
- buildRemoveObjectInput,
28
- buildReplaceBackgroundInput,
29
- buildHDTouchUpInput,
30
21
  } from "../infrastructure/utils";
31
22
 
32
23
  export { CostTracker } from "../infrastructure/utils/cost-tracker";
@@ -14,17 +14,8 @@ export const DEFAULT_FAL_CONFIG = {
14
14
  } as const;
15
15
 
16
16
  export const FAL_CAPABILITIES: ProviderCapabilities = {
17
- imageFeatures: [
18
- "upscale",
19
- "photo-restore",
20
- "face-swap",
21
- "anime-selfie",
22
- "remove-background",
23
- "remove-object",
24
- "hd-touch-up",
25
- "replace-background",
26
- ] as const,
27
- videoFeatures: ["image-to-video", "text-to-video"] as const,
17
+ imageFeatures: [] as const,
18
+ videoFeatures: [] as const,
28
19
  textToImage: true,
29
20
  textToVideo: true,
30
21
  imageToVideo: true,
@@ -6,8 +6,8 @@
6
6
  import { fal } from "@fal-ai/client";
7
7
  import type {
8
8
  IAIProvider, AIProviderConfig, JobSubmission, JobStatus, SubscribeOptions,
9
- RunOptions, ImageFeatureType, VideoFeatureType, ImageFeatureInputData,
10
- VideoFeatureInputData, ProviderCapabilities,
9
+ RunOptions, ProviderCapabilities, ImageFeatureType, VideoFeatureType,
10
+ ImageFeatureInputData, VideoFeatureInputData,
11
11
  } from "../../domain/types";
12
12
  import type { CostTrackerConfig } from "../../domain/entities/cost-tracking.types";
13
13
  import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
@@ -18,7 +18,6 @@ import {
18
18
  removeRequest, cancelAllRequests, hasActiveRequests,
19
19
  } from "./request-store";
20
20
  import * as queueOps from "./fal-queue-operations";
21
- import * as featureModels from "./fal-feature-models";
22
21
  import { validateInput } from "../utils/input-validator.util";
23
22
 
24
23
  export class FalProvider implements IAIProvider {
@@ -28,13 +27,9 @@ export class FalProvider implements IAIProvider {
28
27
  private apiKey: string | null = null;
29
28
  private initialized = false;
30
29
  private costTracker: CostTracker | null = null;
31
- private videoFeatureModels: Record<string, string> = {};
32
- private imageFeatureModels: Record<string, string> = {};
33
30
 
34
31
  initialize(config: AIProviderConfig): void {
35
32
  this.apiKey = config.apiKey;
36
- this.videoFeatureModels = config.videoFeatureModels ?? {};
37
- this.imageFeatureModels = config.imageFeatureModels ?? {};
38
33
  fal.config({
39
34
  credentials: config.apiKey,
40
35
  retry: {
@@ -70,10 +65,24 @@ export class FalProvider implements IAIProvider {
70
65
  return FAL_CAPABILITIES;
71
66
  }
72
67
 
73
- isFeatureSupported(feature: ImageFeatureType | VideoFeatureType): boolean {
74
- const caps = this.getCapabilities();
75
- return caps.imageFeatures.includes(feature as ImageFeatureType) ||
76
- caps.videoFeatures.includes(feature as VideoFeatureType);
68
+ isFeatureSupported(_feature: ImageFeatureType | VideoFeatureType): boolean {
69
+ return false;
70
+ }
71
+
72
+ getImageFeatureModel(_feature: ImageFeatureType): string {
73
+ throw new Error("Feature-specific models are not supported in this provider. Use the main app's feature implementations.");
74
+ }
75
+
76
+ buildImageFeatureInput(_feature: ImageFeatureType, _data: ImageFeatureInputData): Record<string, unknown> {
77
+ throw new Error("Feature-specific input building is not supported in this provider. Use the main app's feature implementations.");
78
+ }
79
+
80
+ getVideoFeatureModel(_feature: VideoFeatureType): string {
81
+ throw new Error("Feature-specific models are not supported in this provider. Use the main app's feature implementations.");
82
+ }
83
+
84
+ buildVideoFeatureInput(_feature: VideoFeatureType, _data: VideoFeatureInputData): Record<string, unknown> {
85
+ throw new Error("Feature-specific input building is not supported in this provider. Use the main app's feature implementations.");
77
86
  }
78
87
 
79
88
  private validateInit(): void {
@@ -160,22 +169,6 @@ export class FalProvider implements IAIProvider {
160
169
  hasRunningRequest(): boolean {
161
170
  return hasActiveRequests();
162
171
  }
163
-
164
- getImageFeatureModel(feature: ImageFeatureType): string {
165
- return featureModels.getImageFeatureModel(this.imageFeatureModels, feature);
166
- }
167
-
168
- buildImageFeatureInput(feature: ImageFeatureType, data: ImageFeatureInputData): Record<string, unknown> {
169
- return featureModels.buildImageFeatureInput(feature, data);
170
- }
171
-
172
- getVideoFeatureModel(feature: VideoFeatureType): string {
173
- return featureModels.getVideoFeatureModel(this.videoFeatureModels, feature);
174
- }
175
-
176
- buildVideoFeatureInput(feature: VideoFeatureType, data: VideoFeatureInputData): Record<string, unknown> {
177
- return featureModels.buildVideoFeatureInput(feature, data);
178
- }
179
172
  }
180
173
 
181
174
  export const falProvider = new FalProvider();
@@ -11,15 +11,6 @@ export {
11
11
  export {
12
12
  buildSingleImageInput,
13
13
  buildDualImageInput,
14
- buildUpscaleInput,
15
- buildPhotoRestoreInput,
16
- buildVideoFromImageInput,
17
- buildFaceSwapInput,
18
- buildImageToImageInput,
19
- buildRemoveBackgroundInput,
20
- buildRemoveObjectInput,
21
- buildReplaceBackgroundInput,
22
- buildHDTouchUpInput,
23
14
  } from "./input-builders.util";
24
15
 
25
16
  export {
@@ -4,5 +4,3 @@
4
4
  */
5
5
 
6
6
  export * from "./base-builders.util";
7
- export * from "./image-feature-builders.util";
8
- export * from "./video-feature-builders.util";
@@ -22,18 +22,6 @@ export interface AiProviderInitModuleConfig {
22
22
  */
23
23
  getApiKey: () => string | undefined;
24
24
 
25
- /**
26
- * Video feature models mapping
27
- * Maps feature types to FAL model IDs
28
- */
29
- videoFeatureModels?: Record<string, string>;
30
-
31
- /**
32
- * Image feature models mapping
33
- * Maps feature types to FAL model IDs
34
- */
35
- imageFeatureModels?: Record<string, string>;
36
-
37
25
  /**
38
26
  * Whether this module is critical for app startup
39
27
  * @default false
@@ -61,10 +49,6 @@ export interface AiProviderInitModuleConfig {
61
49
  * createFirebaseInitModule(),
62
50
  * createAiProviderInitModule({
63
51
  * getApiKey: () => getFalApiKey(),
64
- * videoFeatureModels: {
65
- * "image-to-video": "fal-ai/wan-25-preview/image-to-video",
66
- * "text-to-video": "fal-ai/wan-25-preview/text-to-video",
67
- * },
68
52
  * }),
69
53
  * ],
70
54
  * });
@@ -75,8 +59,6 @@ export function createAiProviderInitModule(
75
59
  ): InitModule {
76
60
  const {
77
61
  getApiKey,
78
- videoFeatureModels,
79
- imageFeatureModels,
80
62
  critical = false,
81
63
  dependsOn = ['firebase'],
82
64
  } = config;
@@ -95,8 +77,6 @@ export function createAiProviderInitModule(
95
77
 
96
78
  falProvider.initialize({
97
79
  apiKey,
98
- videoFeatureModels,
99
- imageFeatureModels,
100
80
  });
101
81
 
102
82
  return Promise.resolve(true);
@@ -1,64 +0,0 @@
1
- /**
2
- * Image Feature Input Builder
3
- * Builds inputs for image-based AI features
4
- */
5
-
6
- import type {
7
- ImageFeatureType,
8
- ImageFeatureInputData,
9
- } from "../../domain/types";
10
- import { buildSingleImageInput } from "../utils/base-builders.util";
11
- import {
12
- buildUpscaleInput,
13
- buildPhotoRestoreInput,
14
- buildFaceSwapInput,
15
- buildRemoveBackgroundInput,
16
- buildRemoveObjectInput,
17
- buildReplaceBackgroundInput,
18
- buildKontextStyleTransferInput,
19
- } from "../utils/image-feature-builders.util";
20
-
21
- const DEFAULT_ANIME_SELFIE_PROMPT = "Transform this person into anime style illustration. Keep the same gender, face structure, hair color, eye color, and expression. Make it look like a high-quality anime character portrait with vibrant colors and clean lineart.";
22
-
23
- export function buildImageFeatureInput(
24
- feature: ImageFeatureType,
25
- data: ImageFeatureInputData,
26
- ): Record<string, unknown> {
27
- const { imageBase64, targetImageBase64, prompt, options } = data;
28
-
29
- switch (feature) {
30
- case "upscale":
31
- case "hd-touch-up":
32
- return buildUpscaleInput(imageBase64, options);
33
-
34
- case "photo-restore":
35
- return buildPhotoRestoreInput(imageBase64, options);
36
-
37
- case "face-swap":
38
- if (!targetImageBase64) {
39
- throw new Error("Face swap requires target image");
40
- }
41
- return buildFaceSwapInput(imageBase64, targetImageBase64, options);
42
-
43
- case "remove-background":
44
- return buildRemoveBackgroundInput(imageBase64, options);
45
-
46
- case "remove-object":
47
- return buildRemoveObjectInput(imageBase64, { prompt, ...options });
48
-
49
- case "replace-background":
50
- if (!prompt) {
51
- throw new Error("Replace background requires prompt");
52
- }
53
- return buildReplaceBackgroundInput(imageBase64, { prompt, ...options });
54
-
55
- case "anime-selfie":
56
- return buildKontextStyleTransferInput(imageBase64, {
57
- prompt: prompt || (options?.prompt as string) || DEFAULT_ANIME_SELFIE_PROMPT,
58
- guidance_scale: options?.guidance_scale as number | undefined,
59
- });
60
-
61
- default:
62
- return buildSingleImageInput(imageBase64, options);
63
- }
64
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Video Feature Input Builder
3
- * Builds inputs for video-based AI features
4
- */
5
-
6
- import type {
7
- VideoFeatureType,
8
- VideoFeatureInputData,
9
- } from "../../domain/types";
10
- import {
11
- buildVideoFromImageInput,
12
- buildTextToVideoInput,
13
- } from "../utils/video-feature-builders.util";
14
-
15
- const DEFAULT_VIDEO_PROMPTS: Partial<Record<VideoFeatureType, string>> = {
16
- "image-to-video": "Animate this image with natural, smooth motion while preserving all details",
17
- "text-to-video": "Generate a high-quality video based on the description, smooth motion",
18
- } as const;
19
-
20
- /**
21
- * Features that require image input
22
- */
23
- const IMAGE_REQUIRED_FEATURES: readonly VideoFeatureType[] = [
24
- "image-to-video",
25
- ] as const;
26
-
27
- function isImageRequiredFeature(feature: VideoFeatureType): boolean {
28
- return IMAGE_REQUIRED_FEATURES.includes(feature);
29
- }
30
-
31
- export function buildVideoFeatureInput(
32
- feature: VideoFeatureType,
33
- data: VideoFeatureInputData,
34
- ): Record<string, unknown> {
35
- const { sourceImageBase64, prompt, options } = data;
36
- const effectivePrompt = prompt || DEFAULT_VIDEO_PROMPTS[feature] || "Generate video";
37
-
38
- if (isImageRequiredFeature(feature)) {
39
- if (!sourceImageBase64 || sourceImageBase64.trim().length === 0) {
40
- throw new Error(`${feature} requires a source image`);
41
- }
42
- return buildVideoFromImageInput(sourceImageBase64, {
43
- prompt: effectivePrompt,
44
- duration: options?.duration as number | undefined,
45
- resolution: options?.resolution as string | undefined,
46
- });
47
- }
48
-
49
- return buildTextToVideoInput({
50
- prompt: effectivePrompt,
51
- duration: options?.duration as number | undefined,
52
- aspectRatio: options?.aspect_ratio as string | undefined,
53
- resolution: options?.resolution as string | undefined,
54
- });
55
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * FAL Feature Models - Model resolution and input building
3
- */
4
-
5
- import type {
6
- ImageFeatureType,
7
- VideoFeatureType,
8
- ImageFeatureInputData,
9
- VideoFeatureInputData,
10
- } from "../../domain/types";
11
- import {
12
- buildImageFeatureInput as buildImageFeatureInputImpl,
13
- } from "../builders/image-feature-builder";
14
- import {
15
- buildVideoFeatureInput as buildVideoFeatureInputImpl,
16
- } from "../builders/video-feature-builder";
17
-
18
- export function getImageFeatureModel(
19
- imageFeatureModels: Record<string, string>,
20
- feature: ImageFeatureType,
21
- ): string {
22
- const model = imageFeatureModels[feature];
23
- if (!model) throw new Error(`No model for image feature: ${feature}`);
24
- return model;
25
- }
26
-
27
- export function getVideoFeatureModel(
28
- videoFeatureModels: Record<string, string>,
29
- feature: VideoFeatureType,
30
- ): string {
31
- const model = videoFeatureModels[feature];
32
- if (!model) throw new Error(`No model for video feature: ${feature}`);
33
- return model;
34
- }
35
-
36
- export function buildImageFeatureInput(
37
- feature: ImageFeatureType,
38
- data: ImageFeatureInputData,
39
- ): Record<string, unknown> {
40
- return buildImageFeatureInputImpl(feature, data);
41
- }
42
-
43
- export function buildVideoFeatureInput(
44
- feature: VideoFeatureType,
45
- data: VideoFeatureInputData,
46
- ): Record<string, unknown> {
47
- return buildVideoFeatureInputImpl(feature, data);
48
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * Image Feature Input Builders
3
- * Builder functions for specific image features
4
- */
5
-
6
- import type {
7
- UpscaleOptions,
8
- PhotoRestoreOptions,
9
- RemoveBackgroundOptions,
10
- RemoveObjectOptions,
11
- ReplaceBackgroundOptions,
12
- FaceSwapOptions,
13
- } from "../../domain/types";
14
- import { buildSingleImageInput } from "./base-builders.util";
15
- import { formatImageDataUri } from "./image-helpers.util";
16
-
17
- export function buildUpscaleInput(
18
- base64: string,
19
- options?: UpscaleOptions,
20
- ): Record<string, unknown> {
21
- return buildSingleImageInput(base64, {
22
- scale: options?.scaleFactor ?? 2,
23
- face_enhance: options?.enhanceFaces ?? false,
24
- });
25
- }
26
-
27
- export function buildPhotoRestoreInput(
28
- base64: string,
29
- options?: PhotoRestoreOptions,
30
- ): Record<string, unknown> {
31
- return buildSingleImageInput(base64, {
32
- face_enhance: options?.enhanceFaces ?? true,
33
- });
34
- }
35
-
36
- export function buildFaceSwapInput(
37
- sourceBase64: string,
38
- targetBase64: string,
39
- options?: FaceSwapOptions,
40
- ): Record<string, unknown> {
41
- return {
42
- base_image_url: formatImageDataUri(sourceBase64),
43
- swap_image_url: formatImageDataUri(targetBase64),
44
- ...(options?.enhanceFaces !== undefined && { enhance_faces: options.enhanceFaces }),
45
- };
46
- }
47
-
48
- export function buildRemoveBackgroundInput(
49
- base64: string,
50
- options?: RemoveBackgroundOptions & {
51
- model?: string;
52
- operating_resolution?: string;
53
- output_format?: string;
54
- refine_foreground?: boolean;
55
- },
56
- ): Record<string, unknown> {
57
- return buildSingleImageInput(base64, {
58
- model: options?.model ?? "General Use (Light)",
59
- operating_resolution: options?.operating_resolution ?? "1024x1024",
60
- output_format: options?.output_format ?? "png",
61
- refine_foreground: options?.refine_foreground ?? true,
62
- });
63
- }
64
-
65
- export function buildRemoveObjectInput(
66
- base64: string,
67
- options?: RemoveObjectOptions,
68
- ): Record<string, unknown> {
69
- return buildSingleImageInput(base64, {
70
- mask_url: options?.mask,
71
- prompt: options?.prompt || "Remove the object and fill with background",
72
- });
73
- }
74
-
75
- export function buildReplaceBackgroundInput(
76
- base64: string,
77
- options: ReplaceBackgroundOptions,
78
- ): Record<string, unknown> {
79
- return buildSingleImageInput(base64, {
80
- prompt: options.prompt,
81
- });
82
- }
83
-
84
- export function buildHDTouchUpInput(
85
- base64: string,
86
- options?: UpscaleOptions,
87
- ): Record<string, unknown> {
88
- return buildUpscaleInput(base64, options);
89
- }
90
-
91
- export interface KontextStyleTransferOptions {
92
- prompt: string;
93
- guidance_scale?: number;
94
- }
95
-
96
- export function buildKontextStyleTransferInput(
97
- base64: string,
98
- options: KontextStyleTransferOptions,
99
- ): Record<string, unknown> {
100
- return buildSingleImageInput(base64, {
101
- prompt: options.prompt,
102
- guidance_scale: options.guidance_scale ?? 3.5,
103
- });
104
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * Video Feature Input Builders
3
- * Builder functions for video features
4
- */
5
-
6
- import type {
7
- ImageToImagePromptConfig,
8
- VideoFromImageOptions,
9
- TextToVideoOptions,
10
- } from "../../domain/types";
11
- import { buildSingleImageInput } from "./base-builders.util";
12
- import { formatImageDataUri } from "./image-helpers.util";
13
-
14
- export function buildImageToImageInput(
15
- base64: string,
16
- promptConfig: ImageToImagePromptConfig,
17
- ): Record<string, unknown> {
18
- return buildSingleImageInput(base64, {
19
- prompt: promptConfig.prompt,
20
- negative_prompt: promptConfig.negativePrompt,
21
- strength: promptConfig.strength ?? 0.85,
22
- num_inference_steps: promptConfig.num_inference_steps ?? 50,
23
- guidance_scale: promptConfig.guidance_scale ?? 7.5,
24
- });
25
- }
26
-
27
- export function buildVideoFromImageInput(
28
- base64: string,
29
- options?: VideoFromImageOptions & {
30
- enable_safety_checker?: boolean;
31
- default_prompt?: string;
32
- },
33
- ): Record<string, unknown> {
34
- return {
35
- prompt: options?.prompt || options?.default_prompt || "Generate natural motion video",
36
- image_url: formatImageDataUri(base64),
37
- enable_safety_checker: options?.enable_safety_checker ?? false,
38
- ...(options?.duration && { duration: options.duration }),
39
- ...(options?.resolution && { resolution: options.resolution }),
40
- };
41
- }
42
-
43
- /**
44
- * Build input for text-to-video generation (no image required)
45
- */
46
- export function buildTextToVideoInput(
47
- options: TextToVideoOptions,
48
- ): Record<string, unknown> {
49
- const { prompt, duration, aspectRatio, resolution } = options;
50
-
51
- return {
52
- prompt,
53
- enable_safety_checker: false,
54
- ...(duration && { duration }),
55
- ...(aspectRatio && { aspect_ratio: aspectRatio }),
56
- ...(resolution && { resolution }),
57
- };
58
- }