@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.17.152",
3
+ "version": "1.17.154",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -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
  */
@@ -62,6 +62,7 @@ export {
62
62
  getPrimaryMediaUrl,
63
63
  type CreationOutput,
64
64
  // Creation helpers
65
+ generateCreationId,
65
66
  getTypeIcon,
66
67
  getTypeTextKey,
67
68
  getTypeText,
@@ -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 interface AIHugFeatureState {
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 interface AIHugTranslations {
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 interface AIHugFeatureConfig {
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 interface AIKissFeatureState {
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 interface AIKissTranslations {
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 interface AIKissFeatureConfig {
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
- onProcessingStart?: () => void;
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
- onError?: (error: string) => void;
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 {
@@ -5,6 +5,7 @@
5
5
  export type {
6
6
  DualImageVideoFeatureState,
7
7
  DualImageVideoResult,
8
+ DualImageVideoProcessingStartData,
8
9
  DualImageVideoResultExtractor,
9
10
  DualImageVideoFeatureConfig,
10
11
  DualImageVideoTranslations,
@@ -6,6 +6,7 @@
6
6
  export type {
7
7
  DualImageVideoFeatureState,
8
8
  DualImageVideoResult,
9
+ DualImageVideoProcessingStartData,
9
10
  DualImageVideoResultExtractor,
10
11
  DualImageVideoFeatureConfig,
11
12
  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
- config.onProcessingStart?.();
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
- config.onProcessingComplete?.({ success: true, videoUrl: result.videoUrl });
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
- config.onError?.(errorMessage);
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
  // =============================================================================