@umituz/react-native-ai-generation-content 1.61.1 → 1.61.2

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.61.1",
3
+ "version": "1.61.2",
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",
@@ -4,25 +4,16 @@
4
4
  * Output: image URL
5
5
  */
6
6
 
7
- import { providerRegistry } from "./provider-registry.service";
8
- import { cleanBase64, extractErrorMessage } from "../utils";
7
+ import { extractErrorMessage, validateProvider, prepareImageInputData } from "../utils";
9
8
  import { extractImageResult } from "../utils/url-extractor";
10
9
  import type { ImageResultExtractor } from "../utils/url-extractor";
11
- import type { ImageFeatureType, ImageFeatureInputData } from "../../domain/interfaces";
10
+ import type { ImageFeatureType } from "../../domain/interfaces";
12
11
 
13
- declare const __DEV__: boolean;
14
-
15
- /**
16
- * Execution options
17
- */
18
12
  export interface ExecuteImageFeatureOptions {
19
13
  extractResult?: ImageResultExtractor;
20
14
  onProgress?: (progress: number) => void;
21
15
  }
22
16
 
23
- /**
24
- * Execution result
25
- */
26
17
  export interface ImageFeatureResult {
27
18
  success: boolean;
28
19
  imageUrl?: string;
@@ -30,9 +21,6 @@ export interface ImageFeatureResult {
30
21
  requestId?: string;
31
22
  }
32
23
 
33
- /**
34
- * Request data for image features
35
- */
36
24
  export interface ImageFeatureRequest {
37
25
  imageBase64?: string;
38
26
  targetImageBase64?: string;
@@ -48,41 +36,26 @@ export async function executeImageFeature(
48
36
  request: ImageFeatureRequest,
49
37
  options?: ExecuteImageFeatureOptions,
50
38
  ): Promise<ImageFeatureResult> {
51
- const provider = providerRegistry.getActiveProvider();
52
-
53
- if (!provider) {
54
- return { success: false, error: "No AI provider configured" };
55
- }
56
-
57
- if (!provider.isInitialized()) {
58
- return { success: false, error: "AI provider not initialized" };
39
+ const validation = validateProvider(`Image:${featureType}`);
40
+ if (!validation.success) {
41
+ return { success: false, error: validation.error };
59
42
  }
60
43
 
44
+ const { provider } = validation;
61
45
  const { extractResult, onProgress } = options ?? {};
62
-
63
46
  const model = provider.getImageFeatureModel(featureType);
64
47
 
65
- if (__DEV__) {
66
-
67
- console.log(`[Image:${featureType}] Provider: ${provider.providerId}, Model: ${model}`);
68
- }
69
-
70
48
  try {
71
- const inputData: ImageFeatureInputData = {
72
- imageBase64: request.imageBase64 ? cleanBase64(request.imageBase64) : "",
73
- targetImageBase64: request.targetImageBase64
74
- ? cleanBase64(request.targetImageBase64)
75
- : undefined,
76
- prompt: request.prompt,
77
- options: request.options,
78
- };
79
-
49
+ const inputData = prepareImageInputData(
50
+ request.imageBase64 ?? "",
51
+ request.targetImageBase64,
52
+ request.prompt,
53
+ request.options,
54
+ );
80
55
  const input = provider.buildImageFeatureInput(featureType, inputData);
81
56
  const result = await provider.run(model, input);
82
57
 
83
- const extractor = extractResult ?? extractImageResult;
84
- const imageUrl = extractor(result);
85
-
58
+ const imageUrl = (extractResult ?? extractImageResult)(result);
86
59
  onProgress?.(100);
87
60
 
88
61
  if (!imageUrl) {
@@ -104,6 +77,5 @@ export async function executeImageFeature(
104
77
  * Check if image features are supported
105
78
  */
106
79
  export function hasImageFeatureSupport(): boolean {
107
- const provider = providerRegistry.getActiveProvider();
108
- return provider !== null && provider.isInitialized();
80
+ return validateProvider("ImageFeatureSupport").success;
109
81
  }