@umituz/react-native-ai-generation-content 1.17.157 → 1.17.158
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
|
@@ -73,24 +73,35 @@ export function useAnimeSelfieFeature(
|
|
|
73
73
|
|
|
74
74
|
config.onProcessingStart?.();
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
76
|
+
try {
|
|
77
|
+
const imageBase64 = await config.prepareImage(state.imageUri);
|
|
78
|
+
|
|
79
|
+
const result = await executeImageFeature(
|
|
80
|
+
"anime-selfie",
|
|
81
|
+
{ imageBase64, options: { style: config.defaultStyle } },
|
|
82
|
+
{ extractResult: config.extractResult, onProgress: handleProgress },
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (result.success && result.imageUrl) {
|
|
86
|
+
setState((prev) => ({
|
|
87
|
+
...prev,
|
|
88
|
+
isProcessing: false,
|
|
89
|
+
processedUrl: result.imageUrl!,
|
|
90
|
+
progress: 100,
|
|
91
|
+
}));
|
|
92
|
+
config.onProcessingComplete?.(result as AnimeSelfieResult);
|
|
93
|
+
} else {
|
|
94
|
+
const errorMessage = result.error || "Processing failed";
|
|
95
|
+
setState((prev) => ({
|
|
96
|
+
...prev,
|
|
97
|
+
isProcessing: false,
|
|
98
|
+
error: errorMessage,
|
|
99
|
+
progress: 0,
|
|
100
|
+
}));
|
|
101
|
+
config.onError?.(errorMessage);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
94
105
|
setState((prev) => ({
|
|
95
106
|
...prev,
|
|
96
107
|
isProcessing: false,
|
|
@@ -18,15 +18,35 @@ export interface FeatureUtilsConfig {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export async function prepareImage(uri: string): Promise<string> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
22
|
+
console.log("[prepareImage] Starting with URI:", uri);
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
if (!
|
|
26
|
-
throw new Error("
|
|
25
|
+
if (!uri) {
|
|
26
|
+
throw new Error("[prepareImage] No URI provided");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
const base64 = await FileSystem.readAsStringAsync(uri, {
|
|
31
|
+
encoding: "base64",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
35
|
+
console.log("[prepareImage] Base64 length:", base64?.length || 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!base64) {
|
|
39
|
+
throw new Error("[prepareImage] Failed to convert image to base64");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return base64;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
46
|
+
console.error("[prepareImage] Error:", message);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`[prepareImage] Failed: ${message}`);
|
|
49
|
+
}
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
export function createDevCallbacks(featureName: string) {
|