@umituz/react-native-ai-generation-content 1.17.152 → 1.17.154
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 +1 -1
- package/src/domains/creations/domain/utils/creation-helpers.ts +8 -0
- package/src/domains/creations/index.ts +1 -0
- package/src/features/ai-hug/domain/types/ai-hug.types.ts +9 -32
- package/src/features/ai-kiss/domain/types/ai-kiss.types.ts +9 -32
- package/src/features/shared/dual-image-video/domain/types/dual-image-video.types.ts +13 -2
- package/src/features/shared/dual-image-video/domain/types/index.ts +1 -0
- package/src/features/shared/dual-image-video/index.ts +1 -0
- package/src/features/shared/dual-image-video/presentation/hooks/useDualImageVideoFeature.ts +18 -4
- package/src/index.ts +10 -0
package/package.json
CHANGED
|
@@ -3,8 +3,16 @@
|
|
|
3
3
|
* Utility functions for creation data manipulation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { generateUUID } from "@umituz/react-native-uuid";
|
|
6
7
|
import type { CreationTypeId } from "../types";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Generate a unique creation ID using UUID v4
|
|
11
|
+
*/
|
|
12
|
+
export function generateCreationId(): string {
|
|
13
|
+
return generateUUID();
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Icon name type for design system
|
|
10
18
|
*/
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* Request, Result, Config types for AI hug video generation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type {
|
|
7
|
+
DualImageVideoFeatureConfig,
|
|
8
|
+
DualImageVideoFeatureState,
|
|
9
|
+
DualImageVideoTranslations,
|
|
10
|
+
} from "../../../shared/dual-image-video";
|
|
11
|
+
|
|
6
12
|
export interface AIHugOptions {
|
|
7
13
|
intensity?: "gentle" | "warm" | "tight";
|
|
8
14
|
preserveFaces?: boolean;
|
|
@@ -25,39 +31,10 @@ export interface AIHugResult {
|
|
|
25
31
|
requestId?: string;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
export
|
|
29
|
-
sourceImageUri: string | null;
|
|
30
|
-
targetImageUri: string | null;
|
|
31
|
-
processedVideoUrl: string | null;
|
|
32
|
-
isProcessing: boolean;
|
|
33
|
-
progress: number;
|
|
34
|
-
error: string | null;
|
|
35
|
-
}
|
|
34
|
+
export type AIHugFeatureState = DualImageVideoFeatureState;
|
|
36
35
|
|
|
37
|
-
export
|
|
38
|
-
sourceUploadTitle: string;
|
|
39
|
-
sourceUploadSubtitle: string;
|
|
40
|
-
targetUploadTitle: string;
|
|
41
|
-
targetUploadSubtitle: string;
|
|
42
|
-
uploadChange: string;
|
|
43
|
-
uploadAnalyzing: string;
|
|
44
|
-
description: string;
|
|
45
|
-
processingText: string;
|
|
46
|
-
processButtonText: string;
|
|
47
|
-
successText: string;
|
|
48
|
-
saveButtonText: string;
|
|
49
|
-
tryAnotherText: string;
|
|
50
|
-
}
|
|
36
|
+
export type AIHugTranslations = DualImageVideoTranslations;
|
|
51
37
|
|
|
52
38
|
export type AIHugResultExtractor = (result: unknown) => string | undefined;
|
|
53
39
|
|
|
54
|
-
export
|
|
55
|
-
creditCost?: number;
|
|
56
|
-
extractResult?: AIHugResultExtractor;
|
|
57
|
-
prepareImage: (imageUri: string) => Promise<string>;
|
|
58
|
-
onSourceImageSelect?: (uri: string) => void;
|
|
59
|
-
onTargetImageSelect?: (uri: string) => void;
|
|
60
|
-
onProcessingStart?: () => void;
|
|
61
|
-
onProcessingComplete?: (result: AIHugResult) => void;
|
|
62
|
-
onError?: (error: string) => void;
|
|
63
|
-
}
|
|
40
|
+
export type AIHugFeatureConfig = DualImageVideoFeatureConfig;
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* Request, Result, Config types for AI kiss video generation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type {
|
|
7
|
+
DualImageVideoFeatureConfig,
|
|
8
|
+
DualImageVideoFeatureState,
|
|
9
|
+
DualImageVideoTranslations,
|
|
10
|
+
} from "../../../shared/dual-image-video";
|
|
11
|
+
|
|
6
12
|
export interface AIKissOptions {
|
|
7
13
|
style?: "romantic" | "cheek" | "forehead";
|
|
8
14
|
preserveFaces?: boolean;
|
|
@@ -25,39 +31,10 @@ export interface AIKissResult {
|
|
|
25
31
|
requestId?: string;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
export
|
|
29
|
-
sourceImageUri: string | null;
|
|
30
|
-
targetImageUri: string | null;
|
|
31
|
-
processedVideoUrl: string | null;
|
|
32
|
-
isProcessing: boolean;
|
|
33
|
-
progress: number;
|
|
34
|
-
error: string | null;
|
|
35
|
-
}
|
|
34
|
+
export type AIKissFeatureState = DualImageVideoFeatureState;
|
|
36
35
|
|
|
37
|
-
export
|
|
38
|
-
sourceUploadTitle: string;
|
|
39
|
-
sourceUploadSubtitle: string;
|
|
40
|
-
targetUploadTitle: string;
|
|
41
|
-
targetUploadSubtitle: string;
|
|
42
|
-
uploadChange: string;
|
|
43
|
-
uploadAnalyzing: string;
|
|
44
|
-
description: string;
|
|
45
|
-
processingText: string;
|
|
46
|
-
processButtonText: string;
|
|
47
|
-
successText: string;
|
|
48
|
-
saveButtonText: string;
|
|
49
|
-
tryAnotherText: string;
|
|
50
|
-
}
|
|
36
|
+
export type AIKissTranslations = DualImageVideoTranslations;
|
|
51
37
|
|
|
52
38
|
export type AIKissResultExtractor = (result: unknown) => string | undefined;
|
|
53
39
|
|
|
54
|
-
export
|
|
55
|
-
creditCost?: number;
|
|
56
|
-
extractResult?: AIKissResultExtractor;
|
|
57
|
-
prepareImage: (imageUri: string) => Promise<string>;
|
|
58
|
-
onSourceImageSelect?: (uri: string) => void;
|
|
59
|
-
onTargetImageSelect?: (uri: string) => void;
|
|
60
|
-
onProcessingStart?: () => void;
|
|
61
|
-
onProcessingComplete?: (result: AIKissResult) => void;
|
|
62
|
-
onError?: (error: string) => void;
|
|
63
|
-
}
|
|
40
|
+
export type AIKissFeatureConfig = DualImageVideoFeatureConfig;
|
|
@@ -20,6 +20,14 @@ export interface DualImageVideoResult {
|
|
|
20
20
|
videoUrl?: string;
|
|
21
21
|
error?: string;
|
|
22
22
|
requestId?: string;
|
|
23
|
+
creationId?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DualImageVideoProcessingStartData {
|
|
27
|
+
creationId: string;
|
|
28
|
+
featureType: string;
|
|
29
|
+
sourceImageUri: string;
|
|
30
|
+
targetImageUri: string;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
export type DualImageVideoResultExtractor = (result: unknown) => string | undefined;
|
|
@@ -30,9 +38,12 @@ export interface DualImageVideoFeatureConfig {
|
|
|
30
38
|
prepareImage: (imageUri: string) => Promise<string>;
|
|
31
39
|
onSourceImageSelect?: (uri: string) => void;
|
|
32
40
|
onTargetImageSelect?: (uri: string) => void;
|
|
33
|
-
|
|
41
|
+
/** Called when processing starts - use to create Firestore doc with "processing" status */
|
|
42
|
+
onProcessingStart?: (data: DualImageVideoProcessingStartData) => void;
|
|
43
|
+
/** Called when processing completes - use to update Firestore doc with result */
|
|
34
44
|
onProcessingComplete?: (result: DualImageVideoResult) => void;
|
|
35
|
-
|
|
45
|
+
/** Called on error - use to update Firestore doc with "failed" status */
|
|
46
|
+
onError?: (error: string, creationId?: string) => void;
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
export interface DualImageVideoTranslations {
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* DRY: Consolidates common logic from useAIHugFeature and useAIKissFeature
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useState, useCallback } from "react";
|
|
7
|
+
import { useState, useCallback, useRef } from "react";
|
|
8
8
|
import { executeVideoFeature } from "../../../../../infrastructure/services";
|
|
9
|
+
import { generateCreationId } from "../../../../../domains/creations/domain/utils";
|
|
9
10
|
import type {
|
|
10
11
|
DualImageVideoFeatureState,
|
|
11
12
|
UseDualImageVideoFeatureProps,
|
|
@@ -26,6 +27,7 @@ export function useDualImageVideoFeature(
|
|
|
26
27
|
): UseDualImageVideoFeatureReturn {
|
|
27
28
|
const { featureType, config, onSelectSourceImage, onSelectTargetImage, onSaveVideo, onBeforeProcess } = props;
|
|
28
29
|
const [state, setState] = useState<DualImageVideoFeatureState>(initialState);
|
|
30
|
+
const currentCreationIdRef = useRef<string | null>(null);
|
|
29
31
|
|
|
30
32
|
const selectSourceImage = useCallback(async () => {
|
|
31
33
|
try {
|
|
@@ -65,6 +67,10 @@ export function useDualImageVideoFeature(
|
|
|
65
67
|
if (!canProceed) return;
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
// Generate creationId for this processing session
|
|
71
|
+
const creationId = generateCreationId();
|
|
72
|
+
currentCreationIdRef.current = creationId;
|
|
73
|
+
|
|
68
74
|
setState((prev) => ({
|
|
69
75
|
...prev,
|
|
70
76
|
isProcessing: true,
|
|
@@ -72,7 +78,13 @@ export function useDualImageVideoFeature(
|
|
|
72
78
|
error: null,
|
|
73
79
|
}));
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
// Notify start with creationId for Firestore creation
|
|
82
|
+
config.onProcessingStart?.({
|
|
83
|
+
creationId,
|
|
84
|
+
featureType,
|
|
85
|
+
sourceImageUri: state.sourceImageUri,
|
|
86
|
+
targetImageUri: state.targetImageUri,
|
|
87
|
+
});
|
|
76
88
|
|
|
77
89
|
const sourceImageBase64 = await config.prepareImage(state.sourceImageUri);
|
|
78
90
|
const targetImageBase64 = await config.prepareImage(state.targetImageUri);
|
|
@@ -90,7 +102,8 @@ export function useDualImageVideoFeature(
|
|
|
90
102
|
processedVideoUrl: result.videoUrl!,
|
|
91
103
|
progress: 100,
|
|
92
104
|
}));
|
|
93
|
-
|
|
105
|
+
// Notify completion with creationId and videoUrl for Firestore update
|
|
106
|
+
config.onProcessingComplete?.({ success: true, videoUrl: result.videoUrl, creationId });
|
|
94
107
|
} else {
|
|
95
108
|
const errorMessage = result.error || "Processing failed";
|
|
96
109
|
setState((prev) => ({
|
|
@@ -99,7 +112,8 @@ export function useDualImageVideoFeature(
|
|
|
99
112
|
error: errorMessage,
|
|
100
113
|
progress: 0,
|
|
101
114
|
}));
|
|
102
|
-
|
|
115
|
+
// Notify error with creationId for Firestore update to "failed"
|
|
116
|
+
config.onError?.(errorMessage, creationId);
|
|
103
117
|
}
|
|
104
118
|
}, [state.sourceImageUri, state.targetImageUri, featureType, config, handleProgress, onBeforeProcess]);
|
|
105
119
|
|
package/src/index.ts
CHANGED
|
@@ -483,6 +483,16 @@ export * from "./features/script-generator";
|
|
|
483
483
|
|
|
484
484
|
export * from "./features/photo-restoration";
|
|
485
485
|
|
|
486
|
+
// =============================================================================
|
|
487
|
+
// FEATURES - Shared Dual Image Video Types
|
|
488
|
+
// =============================================================================
|
|
489
|
+
|
|
490
|
+
export type {
|
|
491
|
+
DualImageVideoProcessingStartData,
|
|
492
|
+
DualImageVideoResult,
|
|
493
|
+
DualImageVideoFeatureConfig,
|
|
494
|
+
} from "./features/shared/dual-image-video";
|
|
495
|
+
|
|
486
496
|
// =============================================================================
|
|
487
497
|
// FEATURES - AI Hug
|
|
488
498
|
// =============================================================================
|