@umituz/react-native-ai-generation-content 1.14.0 → 1.15.1

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.
Files changed (37) hide show
  1. package/package.json +2 -2
  2. package/src/features/audio-generation/index.ts +0 -1
  3. package/src/features/colorization/index.ts +0 -1
  4. package/src/features/face-swap/index.ts +0 -1
  5. package/src/features/future-prediction/index.ts +0 -1
  6. package/src/features/image-captioning/index.ts +0 -1
  7. package/src/features/inpainting/index.ts +0 -1
  8. package/src/features/photo-restoration/index.ts +0 -1
  9. package/src/features/sketch-to-image/index.ts +0 -1
  10. package/src/features/style-transfer/index.ts +0 -1
  11. package/src/features/text-to-image/index.ts +0 -1
  12. package/src/features/text-to-video/index.ts +0 -1
  13. package/src/features/upscaling/index.ts +0 -1
  14. package/src/index.ts +24 -0
  15. package/src/presentation/components/index.ts +1 -0
  16. package/src/presentation/components/photo-step/PhotoStep.tsx +96 -0
  17. package/src/presentation/components/photo-step/index.ts +2 -0
  18. package/src/presentation/hooks/base/index.ts +9 -0
  19. package/src/presentation/hooks/base/types.ts +47 -0
  20. package/src/presentation/hooks/base/use-dual-image-feature.ts +178 -0
  21. package/src/presentation/hooks/base/use-image-with-prompt-feature.ts +170 -0
  22. package/src/presentation/hooks/base/use-single-image-feature.ts +154 -0
  23. package/src/presentation/hooks/index.ts +9 -0
  24. package/src/presentation/hooks/useGenerationFlow.ts +315 -0
  25. package/src/presentation/types/flow-config.types.ts +246 -0
  26. package/src/features/audio-generation/presentation/hooks.ts +0 -39
  27. package/src/features/colorization/presentation/hooks.ts +0 -39
  28. package/src/features/face-swap/presentation/hooks.ts +0 -41
  29. package/src/features/future-prediction/presentation/hooks.ts +0 -39
  30. package/src/features/image-captioning/presentation/hooks.ts +0 -39
  31. package/src/features/inpainting/presentation/hooks.ts +0 -39
  32. package/src/features/photo-restoration/presentation/hooks.ts +0 -39
  33. package/src/features/sketch-to-image/presentation/hooks.ts +0 -39
  34. package/src/features/style-transfer/presentation/hooks.ts +0 -39
  35. package/src/features/text-to-image/presentation/hooks.ts +0 -39
  36. package/src/features/text-to-video/presentation/hooks.ts +0 -39
  37. package/src/features/upscaling/presentation/hooks.ts +0 -39
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Flow Configuration Types
3
+ * Configuration system for step-by-step generation flows
4
+ *
5
+ * @package @umituz/react-native-ai-generation-content
6
+ */
7
+
8
+ import type { StepHeaderConfig } from "@umituz/react-native-design-system";
9
+ import type { PhotoUploadCardConfig } from "@umituz/react-native-design-system";
10
+
11
+ /**
12
+ * Photo upload step configuration
13
+ */
14
+ export interface PhotoStepConfig {
15
+ /** Whether this step is enabled */
16
+ enabled: boolean;
17
+ /** Step order (1, 2, 3, etc.) */
18
+ order: number;
19
+ /** Step identifier */
20
+ id: string;
21
+ /** Header configuration */
22
+ header?: StepHeaderConfig;
23
+ /** Photo upload card configuration */
24
+ photoCard?: PhotoUploadCardConfig;
25
+ /** Whether name input is required */
26
+ requireNameInput?: boolean;
27
+ /** Whether photo validation is enabled */
28
+ enableValidation?: boolean;
29
+ /** Validation type */
30
+ validationType?: "none" | "face-detection" | "custom";
31
+ /** Whether to show photo tips */
32
+ showPhotoTips?: boolean;
33
+ /** Custom validation function */
34
+ customValidator?: (imageUri: string) => Promise<boolean>;
35
+ }
36
+
37
+ /**
38
+ * Text input step configuration
39
+ */
40
+ export interface TextInputStepConfig {
41
+ /** Whether this step is enabled */
42
+ enabled: boolean;
43
+ /** Step order */
44
+ order: number;
45
+ /** Step identifier */
46
+ id: string;
47
+ /** Header configuration */
48
+ header?: StepHeaderConfig;
49
+ /** Minimum character length */
50
+ minLength?: number;
51
+ /** Maximum character length */
52
+ maxLength?: number;
53
+ /** Placeholder text */
54
+ placeholder?: string;
55
+ /** Whether to show character counter */
56
+ showCharacterCount?: boolean;
57
+ }
58
+
59
+ /**
60
+ * Preview step configuration
61
+ */
62
+ export interface PreviewStepConfig {
63
+ /** Whether this step is enabled */
64
+ enabled: boolean;
65
+ /** Step order */
66
+ order: number;
67
+ /** Step identifier */
68
+ id: string;
69
+ /** Header configuration */
70
+ header?: StepHeaderConfig;
71
+ /** Whether to show edit buttons */
72
+ allowEditing?: boolean;
73
+ /** Preview layout style */
74
+ layout?: "grid" | "list" | "carousel";
75
+ }
76
+
77
+ /**
78
+ * Complete flow configuration
79
+ */
80
+ export interface GenerationFlowConfig {
81
+ /** Photo upload steps (can be 1 or multiple) */
82
+ photoSteps: PhotoStepConfig[];
83
+ /** Text input step */
84
+ textInputStep?: TextInputStepConfig;
85
+ /** Preview step */
86
+ previewStep?: PreviewStepConfig;
87
+ /** Flow behavior */
88
+ behavior?: {
89
+ /** Whether to allow going back */
90
+ allowBack?: boolean;
91
+ /** Whether to show progress indicator */
92
+ showProgress?: boolean;
93
+ /** Whether to auto-advance after photo selection */
94
+ autoAdvance?: boolean;
95
+ /** Whether to require authentication */
96
+ requireAuth?: boolean;
97
+ /** Whether to check feature gate */
98
+ checkFeatureGate?: boolean;
99
+ };
100
+ }
101
+
102
+ /**
103
+ * Default single photo flow configuration
104
+ */
105
+ export const DEFAULT_SINGLE_PHOTO_FLOW: GenerationFlowConfig = {
106
+ photoSteps: [
107
+ {
108
+ enabled: true,
109
+ order: 1,
110
+ id: "photo-1",
111
+ header: {
112
+ showStepIndicator: false,
113
+ titleAlignment: "center",
114
+ titleFontSize: 28,
115
+ subtitleFontSize: 16,
116
+ },
117
+ photoCard: {
118
+ aspectRatio: 1,
119
+ borderRadius: 28,
120
+ showValidationStatus: true,
121
+ allowChange: true,
122
+ borderStyle: "dashed",
123
+ },
124
+ requireNameInput: true,
125
+ enableValidation: false,
126
+ validationType: "none",
127
+ showPhotoTips: true,
128
+ },
129
+ ],
130
+ behavior: {
131
+ allowBack: false,
132
+ showProgress: false,
133
+ autoAdvance: false,
134
+ requireAuth: false,
135
+ checkFeatureGate: true,
136
+ },
137
+ };
138
+
139
+ /**
140
+ * Default dual photo flow configuration
141
+ */
142
+ export const DEFAULT_DUAL_PHOTO_FLOW: GenerationFlowConfig = {
143
+ photoSteps: [
144
+ {
145
+ enabled: true,
146
+ order: 1,
147
+ id: "partner-a",
148
+ header: {
149
+ showStepIndicator: true,
150
+ currentStep: 1,
151
+ totalSteps: 2,
152
+ titleAlignment: "center",
153
+ titleFontSize: 28,
154
+ subtitleFontSize: 16,
155
+ },
156
+ photoCard: {
157
+ aspectRatio: 1,
158
+ borderRadius: 28,
159
+ showValidationStatus: true,
160
+ allowChange: true,
161
+ borderStyle: "dashed",
162
+ },
163
+ requireNameInput: true,
164
+ enableValidation: false,
165
+ validationType: "none",
166
+ showPhotoTips: true,
167
+ },
168
+ {
169
+ enabled: true,
170
+ order: 2,
171
+ id: "partner-b",
172
+ header: {
173
+ showStepIndicator: true,
174
+ currentStep: 2,
175
+ totalSteps: 2,
176
+ titleAlignment: "center",
177
+ titleFontSize: 28,
178
+ subtitleFontSize: 16,
179
+ },
180
+ photoCard: {
181
+ aspectRatio: 1,
182
+ borderRadius: 28,
183
+ showValidationStatus: true,
184
+ allowChange: true,
185
+ borderStyle: "dashed",
186
+ },
187
+ requireNameInput: true,
188
+ enableValidation: false,
189
+ validationType: "none",
190
+ showPhotoTips: false,
191
+ },
192
+ ],
193
+ behavior: {
194
+ allowBack: true,
195
+ showProgress: true,
196
+ autoAdvance: false,
197
+ requireAuth: false,
198
+ checkFeatureGate: true,
199
+ },
200
+ };
201
+
202
+ /**
203
+ * Step data structure
204
+ */
205
+ export interface PhotoStepData {
206
+ /** Step identifier */
207
+ id: string;
208
+ /** Photo URI */
209
+ imageUri: string | null;
210
+ /** Preview URL */
211
+ previewUrl?: string;
212
+ /** Name/label for this photo */
213
+ name?: string;
214
+ /** Whether validation passed */
215
+ isValid?: boolean;
216
+ /** Validation status */
217
+ validationStatus?: "pending" | "validating" | "valid" | "invalid";
218
+ }
219
+
220
+ /**
221
+ * Text input step data
222
+ */
223
+ export interface TextInputStepData {
224
+ /** Step identifier */
225
+ id: string;
226
+ /** Text content */
227
+ text: string;
228
+ /** Whether text is valid */
229
+ isValid?: boolean;
230
+ }
231
+
232
+ /**
233
+ * Complete flow state
234
+ */
235
+ export interface GenerationFlowState {
236
+ /** Current step index */
237
+ currentStepIndex: number;
238
+ /** Photo steps data */
239
+ photoSteps: PhotoStepData[];
240
+ /** Text input data */
241
+ textInput?: TextInputStepData;
242
+ /** Whether flow is complete */
243
+ isComplete: boolean;
244
+ /** Whether currently processing */
245
+ isProcessing: boolean;
246
+ }
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { AudioGenerationRequest, AudioGenerationResult } from '../domain/entities';
10
-
11
- export interface UseAudioGenerationReturn {
12
- generateAudio: (request: AudioGenerationRequest) => Promise<AudioGenerationResult>;
13
- isGenerating: boolean;
14
- result: AudioGenerationResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useAudioGeneration = (): UseAudioGenerationReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<AudioGenerationResult | null>(null);
21
-
22
- const generateAudio = useCallback(async (request: AudioGenerationRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as AudioGenerationResult);
27
- return genResult.data as AudioGenerationResult;
28
- }
29
-
30
- throw new Error('Audio generation failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- generateAudio,
35
- isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { ColorizationRequest, ColorizationResult } from '../domain/entities';
10
-
11
- export interface UseColorizationReturn {
12
- colorize: (request: ColorizationRequest) => Promise<ColorizationResult>;
13
- isColorizing: boolean;
14
- result: ColorizationResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useColorization = (): UseColorizationReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<ColorizationResult | null>(null);
21
-
22
- const colorize = useCallback(async (request: ColorizationRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as ColorizationResult);
27
- return genResult.data as ColorizationResult;
28
- }
29
-
30
- throw new Error('Colorization failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- colorize,
35
- isColorizing: isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,41 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { FaceSwapRequest, FaceSwapResult } from '../domain/entities';
10
-
11
- export interface UseFaceSwapReturn {
12
- swapFace: (request: FaceSwapRequest) => Promise<FaceSwapResult>;
13
- isSwapping: boolean;
14
- result: FaceSwapResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useFaceSwap = (): UseFaceSwapReturn => {
19
- // @ts-ignore - Deprecated feature, kept for backward compatibility
20
- const { generate, isGenerating, error, result: genResult } = useGeneration<FaceSwapResult>({ model: 'face-swap' });
21
- const [result, setResult] = useState<FaceSwapResult | null>(null);
22
-
23
- const swapFace = useCallback(async (request: FaceSwapRequest) => {
24
- // @ts-ignore - Deprecated feature
25
- await generate(request);
26
-
27
- if (genResult?.data) {
28
- setResult(genResult.data as FaceSwapResult);
29
- return genResult.data as FaceSwapResult;
30
- }
31
-
32
- throw new Error('Face swap failed to return a result');
33
- }, [generate, genResult]);
34
-
35
- return {
36
- swapFace,
37
- isSwapping: isGenerating,
38
- result,
39
- error: error as any,
40
- };
41
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { FuturePredictionRequest, FuturePredictionResult } from '../domain/entities';
10
-
11
- export interface UseFuturePredictionReturn {
12
- predictFuture: (request: FuturePredictionRequest) => Promise<FuturePredictionResult>;
13
- isPredicting: boolean;
14
- result: FuturePredictionResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useFuturePrediction = (): UseFuturePredictionReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<FuturePredictionResult | null>(null);
21
-
22
- const predictFuture = useCallback(async (request: FuturePredictionRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as FuturePredictionResult);
27
- return genResult.data as FuturePredictionResult;
28
- }
29
-
30
- throw new Error('Future prediction failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- predictFuture,
35
- isPredicting: isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { ImageCaptioningRequest, ImageCaptioningResult } from '../domain/entities';
10
-
11
- export interface UseImageCaptioningReturn {
12
- generateCaption: (request: ImageCaptioningRequest) => Promise<ImageCaptioningResult>;
13
- isGenerating: boolean;
14
- result: ImageCaptioningResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useImageCaptioning = (): UseImageCaptioningReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<ImageCaptioningResult | null>(null);
21
-
22
- const generateCaption = useCallback(async (request: ImageCaptioningRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as ImageCaptioningResult);
27
- return genResult.data as ImageCaptioningResult;
28
- }
29
-
30
- throw new Error('Caption generation failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- generateCaption,
35
- isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { InpaintingRequest, InpaintingResult } from '../domain/entities';
10
-
11
- export interface UseInpaintingReturn {
12
- inpaint: (request: InpaintingRequest) => Promise<InpaintingResult>;
13
- isInpainting: boolean;
14
- result: InpaintingResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useInpainting = (): UseInpaintingReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<InpaintingResult | null>(null);
21
-
22
- const inpaint = useCallback(async (request: InpaintingRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as InpaintingResult);
27
- return genResult.data as InpaintingResult;
28
- }
29
-
30
- throw new Error('Inpainting failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- inpaint,
35
- isInpainting: isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { PhotoRestorationRequest, PhotoRestorationResult } from '../domain/entities';
10
-
11
- export interface UsePhotoRestorationReturn {
12
- restorePhoto: (request: PhotoRestorationRequest) => Promise<PhotoRestorationResult>;
13
- isRestoring: boolean;
14
- result: PhotoRestorationResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const usePhotoRestoration = (): UsePhotoRestorationReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<PhotoRestorationResult | null>(null);
21
-
22
- const restorePhoto = useCallback(async (request: PhotoRestorationRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as PhotoRestorationResult);
27
- return genResult.data as PhotoRestorationResult;
28
- }
29
-
30
- throw new Error('Photo restoration failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- restorePhoto,
35
- isRestoring: isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { SketchToImageRequest, SketchToImageResult } from '../domain/entities';
10
-
11
- export interface UseSketchToImageReturn {
12
- generateFromSketch: (request: SketchToImageRequest) => Promise<SketchToImageResult>;
13
- isGenerating: boolean;
14
- result: SketchToImageResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useSketchToImage = (): UseSketchToImageReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<SketchToImageResult | null>(null);
21
-
22
- const generateFromSketch = useCallback(async (request: SketchToImageRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as SketchToImageResult);
27
- return genResult.data as SketchToImageResult;
28
- }
29
-
30
- throw new Error('Sketch to image generation failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- generateFromSketch,
35
- isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { StyleTransferRequest, StyleTransferResult } from '../domain/entities';
10
-
11
- export interface UseStyleTransferReturn {
12
- transferStyle: (request: StyleTransferRequest) => Promise<StyleTransferResult>;
13
- isTransferring: boolean;
14
- result: StyleTransferResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useStyleTransfer = (): UseStyleTransferReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<StyleTransferResult | null>(null);
21
-
22
- const transferStyle = useCallback(async (request: StyleTransferRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as StyleTransferResult);
27
- return genResult.data as StyleTransferResult;
28
- }
29
-
30
- throw new Error('Style transfer failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- transferStyle,
35
- isTransferring: isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { TextToImageRequest, TextToImageResult } from '../domain/entities';
10
-
11
- export interface UseTextToImageReturn {
12
- generateImage: (request: TextToImageRequest) => Promise<TextToImageResult>;
13
- isGenerating: boolean;
14
- result: TextToImageResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useTextToImage = (): UseTextToImageReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<TextToImageResult | null>(null);
21
-
22
- const generateImage = useCallback(async (request: TextToImageRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as TextToImageResult);
27
- return genResult.data as TextToImageResult;
28
- }
29
-
30
- throw new Error('Image generation failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- generateImage,
35
- isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };
@@ -1,39 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- import { useState, useCallback } from 'react';
8
- import { useGeneration } from '../../../presentation/hooks/use-generation';
9
- import { TextToVideoRequest, TextToVideoResult } from '../domain/entities';
10
-
11
- export interface UseTextToVideoReturn {
12
- generateVideo: (request: TextToVideoRequest) => Promise<TextToVideoResult>;
13
- isGenerating: boolean;
14
- result: TextToVideoResult | null;
15
- error: Error | null;
16
- }
17
-
18
- export const useTextToVideo = (): UseTextToVideoReturn => {
19
- const { generate, isGenerating, error, result: genResult } = useGeneration({ model: "deprecated" });
20
- const [result, setResult] = useState<TextToVideoResult | null>(null);
21
-
22
- const generateVideo = useCallback(async (request: TextToVideoRequest) => {
23
- await generate(request as any);
24
-
25
- if (genResult?.data) {
26
- setResult(genResult.data as TextToVideoResult);
27
- return genResult.data as TextToVideoResult;
28
- }
29
-
30
- throw new Error('Video generation failed to return a result');
31
- }, [generate, genResult]);
32
-
33
- return {
34
- generateVideo,
35
- isGenerating,
36
- result,
37
- error: error as any,
38
- };
39
- };