@umituz/react-native-ai-generation-content 1.65.4 → 1.65.6
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.65.
|
|
3
|
+
"version": "1.65.6",
|
|
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",
|
|
@@ -21,7 +21,7 @@ export interface BaseProcessingResult {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface UseCreationPersistenceReturn {
|
|
24
|
-
readonly onProcessingStart: <T extends BaseProcessingStartData>(data: T) => void
|
|
25
|
-
readonly onProcessingComplete: <T extends BaseProcessingResult>(result: T) => void
|
|
26
|
-
readonly onError: (error: string, creationId?: string) => void
|
|
24
|
+
readonly onProcessingStart: <T extends BaseProcessingStartData>(data: T) => Promise<void>;
|
|
25
|
+
readonly onProcessingComplete: <T extends BaseProcessingResult>(result: T) => Promise<void>;
|
|
26
|
+
readonly onError: (error: string, creationId?: string) => Promise<void>;
|
|
27
27
|
}
|
|
@@ -25,7 +25,7 @@ export function useCreationPersistence(
|
|
|
25
25
|
const repository = useMemo(() => createCreationsRepository(collectionName), [collectionName]);
|
|
26
26
|
|
|
27
27
|
const onProcessingStart = useCallback(
|
|
28
|
-
<T extends BaseProcessingStartData>(data: T) => {
|
|
28
|
+
async <T extends BaseProcessingStartData>(data: T): Promise<void> => {
|
|
29
29
|
if (!userId) return;
|
|
30
30
|
const { creationId, ...rest } = data;
|
|
31
31
|
const cleanMetadata = Object.fromEntries(
|
|
@@ -41,23 +41,23 @@ export function useCreationPersistence(
|
|
|
41
41
|
isFavorite: false,
|
|
42
42
|
metadata: cleanMetadata,
|
|
43
43
|
};
|
|
44
|
-
repository.create(userId, creation);
|
|
44
|
+
await repository.create(userId, creation);
|
|
45
45
|
},
|
|
46
46
|
[userId, repository, type]
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const onProcessingComplete = useCallback(
|
|
50
|
-
<T extends BaseProcessingResult>(result: T) => {
|
|
50
|
+
async <T extends BaseProcessingResult>(result: T): Promise<void> => {
|
|
51
51
|
if (!userId || !result.creationId) return;
|
|
52
52
|
|
|
53
53
|
const validation = runAllValidations(result.imageUrl, result.videoUrl);
|
|
54
54
|
if (!validation.isValid) {
|
|
55
|
-
markCreationAsFailed(repository, userId, result.creationId, validation.error!);
|
|
55
|
+
await markCreationAsFailed(repository, userId, result.creationId, validation.error!);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const uri = result.imageUrl || result.videoUrl || "";
|
|
60
|
-
repository.update(userId, result.creationId, {
|
|
60
|
+
await repository.update(userId, result.creationId, {
|
|
61
61
|
[CREATION_FIELDS.URI]: uri,
|
|
62
62
|
[CREATION_FIELDS.STATUS]: CREATION_STATUS.COMPLETED,
|
|
63
63
|
[CREATION_FIELDS.OUTPUT]: result.imageUrl
|
|
@@ -75,9 +75,9 @@ export function useCreationPersistence(
|
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
const onError = useCallback(
|
|
78
|
-
(error: string, creationId?: string) => {
|
|
78
|
+
async (error: string, creationId?: string): Promise<void> => {
|
|
79
79
|
if (!userId || !creationId) return;
|
|
80
|
-
markCreationAsFailed(repository, userId, creationId, error);
|
|
80
|
+
await markCreationAsFailed(repository, userId, creationId, error);
|
|
81
81
|
},
|
|
82
82
|
[userId, repository]
|
|
83
83
|
);
|
|
@@ -51,19 +51,17 @@ export const useDualImageGeneration = (
|
|
|
51
51
|
const strategy: GenerationStrategy<GenerationInput, string> = useMemo(
|
|
52
52
|
() => ({
|
|
53
53
|
execute: async (input) => {
|
|
54
|
-
|
|
54
|
+
// Don't use fake progress - let UI show indeterminate loading
|
|
55
55
|
const result = await executeMultiImageGeneration({
|
|
56
56
|
photos: [input.sourceBase64, input.targetBase64],
|
|
57
57
|
prompt: getPrompt(),
|
|
58
58
|
model,
|
|
59
59
|
});
|
|
60
|
-
setProgress(90);
|
|
61
60
|
|
|
62
61
|
if (!result.success || !result.imageUrl) {
|
|
63
62
|
throw new Error(result.error || "Generation failed");
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
setProgress(100);
|
|
67
65
|
return result.imageUrl;
|
|
68
66
|
},
|
|
69
67
|
getCreditCost: () => creditCost,
|
|
@@ -87,12 +85,14 @@ export const useDualImageGeneration = (
|
|
|
87
85
|
return;
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
|
|
88
|
+
// Progress will be indeterminate - no fake percentages
|
|
89
|
+
setProgress(-1); // -1 indicates indeterminate/unknown progress
|
|
91
90
|
try {
|
|
92
91
|
await orchestrator.generate({
|
|
93
92
|
sourceBase64: sourceImage.base64,
|
|
94
93
|
targetBase64: targetImage.base64,
|
|
95
94
|
});
|
|
95
|
+
setProgress(100); // Only set to 100 when actually complete
|
|
96
96
|
} catch {
|
|
97
97
|
setProgress(0);
|
|
98
98
|
}
|