@umituz/react-native-ai-generation-content 1.19.6 → 1.19.7

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.19.6",
3
+ "version": "1.19.7",
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",
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Couple Future Flow Types
3
+ * Type definitions for couple future wizard flow
4
+ */
5
+
6
+ export interface CoupleFutureFlowConfig<TStep, TScenarioId> {
7
+ steps: {
8
+ SCENARIO: TStep;
9
+ SCENARIO_PREVIEW: TStep;
10
+ COUPLE_FEATURE_SELECTOR: TStep;
11
+ TEXT_INPUT: TStep;
12
+ PARTNER_A: TStep;
13
+ PARTNER_B: TStep;
14
+ GENERATING: TStep;
15
+ };
16
+ customScenarioId: TScenarioId;
17
+ }
18
+
19
+ export interface CoupleFutureFlowState<TStep, TScenarioId> {
20
+ step: TStep;
21
+ selectedScenarioId: TScenarioId | null;
22
+ selectedFeature: string | null;
23
+ partnerA: unknown;
24
+ partnerB: unknown;
25
+ partnerAName: string;
26
+ partnerBName: string;
27
+ customPrompt: string | null;
28
+ visualStyle: string | null;
29
+ selection: unknown;
30
+ isProcessing: boolean;
31
+ scenarioConfig: unknown;
32
+ selectedScenarioData: { requiresPhoto?: boolean } | null;
33
+ }
34
+
35
+ export interface CoupleFutureFlowActions<TStep, TScenarioId, TResult> {
36
+ setStep: (step: TStep) => void;
37
+ selectScenario: (id: TScenarioId) => void;
38
+ setPartnerA: (image: unknown) => void;
39
+ setPartnerAName: (name: string) => void;
40
+ setPartnerB: (image: unknown) => void;
41
+ setPartnerBName: (name: string) => void;
42
+ setCustomPrompt: (prompt: string) => void;
43
+ setVisualStyle: (style: string) => void;
44
+ startGeneration: () => void;
45
+ generationSuccess: (result: TResult) => void;
46
+ generationError: (error: string) => void;
47
+ requireFeature: (callback: () => void) => void;
48
+ onNavigateToHistory: () => void;
49
+ }
50
+
51
+ export interface CoupleFutureFlowProps<TStep, TScenarioId, TResult> {
52
+ userId?: string;
53
+ config: CoupleFutureFlowConfig<TStep, TScenarioId>;
54
+ state: CoupleFutureFlowState<TStep, TScenarioId>;
55
+ actions: CoupleFutureFlowActions<TStep, TScenarioId, TResult>;
56
+ generationConfig: {
57
+ visualStyleModifiers: Record<string, string>;
58
+ defaultPartnerAName: string;
59
+ defaultPartnerBName: string;
60
+ };
61
+ alertMessages: {
62
+ networkError: string;
63
+ policyViolation: string;
64
+ saveFailed: string;
65
+ creditFailed: string;
66
+ unknown: string;
67
+ };
68
+ processResult: (imageUrl: string, input: unknown) => TResult;
69
+ buildCreation: (result: TResult, input: unknown) => unknown;
70
+ onCreditsExhausted: () => void;
71
+ }
@@ -8,73 +8,19 @@ import { InteractionManager } from "react-native";
8
8
  import { useCoupleFutureGeneration } from "./useCoupleFutureGeneration";
9
9
  import { buildGenerationInputFromConfig } from "../../infrastructure/generationUtils";
10
10
  import type { UploadedImage } from "../../../partner-upload/domain/types";
11
-
12
- export interface CoupleFutureFlowConfig<TStep, TScenarioId> {
13
- steps: {
14
- SCENARIO: TStep;
15
- SCENARIO_PREVIEW: TStep;
16
- COUPLE_FEATURE_SELECTOR: TStep;
17
- TEXT_INPUT: TStep;
18
- PARTNER_A: TStep;
19
- PARTNER_B: TStep;
20
- GENERATING: TStep;
21
- };
22
- customScenarioId: TScenarioId;
23
- }
24
-
25
- export interface CoupleFutureFlowState<TStep, TScenarioId> {
26
- step: TStep;
27
- selectedScenarioId: TScenarioId | null;
28
- selectedFeature: string | null;
29
- partnerA: unknown;
30
- partnerB: unknown;
31
- partnerAName: string;
32
- partnerBName: string;
33
- customPrompt: string | null;
34
- visualStyle: string | null;
35
- selection: unknown;
36
- isProcessing: boolean;
37
- scenarioConfig: unknown;
38
- selectedScenarioData: { requiresPhoto?: boolean } | null;
39
- }
40
-
41
- export interface CoupleFutureFlowActions<TStep, TScenarioId, TResult> {
42
- setStep: (step: TStep) => void;
43
- selectScenario: (id: TScenarioId) => void;
44
- setPartnerA: (image: unknown) => void;
45
- setPartnerAName: (name: string) => void;
46
- setPartnerB: (image: unknown) => void;
47
- setPartnerBName: (name: string) => void;
48
- setCustomPrompt: (prompt: string) => void;
49
- setVisualStyle: (style: string) => void;
50
- startGeneration: () => void;
51
- generationSuccess: (result: TResult) => void;
52
- generationError: (error: string) => void;
53
- requireFeature: (callback: () => void) => void;
54
- onNavigateToHistory: () => void;
55
- }
56
-
57
- export interface CoupleFutureFlowProps<TStep, TScenarioId, TResult> {
58
- userId?: string;
59
- config: CoupleFutureFlowConfig<TStep, TScenarioId>;
60
- state: CoupleFutureFlowState<TStep, TScenarioId>;
61
- actions: CoupleFutureFlowActions<TStep, TScenarioId, TResult>;
62
- generationConfig: {
63
- visualStyleModifiers: Record<string, string>;
64
- defaultPartnerAName: string;
65
- defaultPartnerBName: string;
66
- };
67
- alertMessages: {
68
- networkError: string;
69
- policyViolation: string;
70
- saveFailed: string;
71
- creditFailed: string;
72
- unknown: string;
73
- };
74
- processResult: (imageUrl: string, input: unknown) => TResult;
75
- buildCreation: (result: TResult, input: unknown) => unknown;
76
- onCreditsExhausted: () => void;
77
- }
11
+ import type {
12
+ CoupleFutureFlowConfig,
13
+ CoupleFutureFlowState,
14
+ CoupleFutureFlowActions,
15
+ CoupleFutureFlowProps,
16
+ } from "./coupleFutureFlow.types";
17
+
18
+ export type {
19
+ CoupleFutureFlowConfig,
20
+ CoupleFutureFlowState,
21
+ CoupleFutureFlowActions,
22
+ CoupleFutureFlowProps,
23
+ };
78
24
 
79
25
  export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
80
26
  props: CoupleFutureFlowProps<TStep, TScenarioId, TResult>,
@@ -99,21 +45,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
99
45
  alertMessages,
100
46
  });
101
47
 
102
- const {
103
- step,
104
- isProcessing,
105
- partnerA,
106
- partnerB,
107
- partnerAName,
108
- partnerBName,
109
- scenarioConfig,
110
- customPrompt,
111
- visualStyle,
112
- selection,
113
- selectedFeature,
114
- selectedScenarioId,
115
- selectedScenarioData,
116
- } = state;
48
+ const { step, isProcessing, selectedFeature, selectedScenarioId, selectedScenarioData } = state;
117
49
 
118
50
  useEffect(() => {
119
51
  if (step !== config.steps.GENERATING) {
@@ -124,38 +56,21 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
124
56
  hasStarted.current = true;
125
57
 
126
58
  const input = buildGenerationInputFromConfig({
127
- partnerA: partnerA as never,
128
- partnerB: partnerB as never,
129
- partnerAName,
130
- partnerBName,
131
- scenario: scenarioConfig as never,
132
- customPrompt: customPrompt || undefined,
133
- visualStyle: visualStyle || "",
59
+ partnerA: state.partnerA as never,
60
+ partnerB: state.partnerB as never,
61
+ partnerAName: state.partnerAName,
62
+ partnerBName: state.partnerBName,
63
+ scenario: state.scenarioConfig as never,
64
+ customPrompt: state.customPrompt || undefined,
65
+ visualStyle: state.visualStyle || "",
134
66
  defaultPartnerAName: generationConfig.defaultPartnerAName,
135
67
  defaultPartnerBName: generationConfig.defaultPartnerBName,
136
- coupleFeatureSelection: selection as never,
68
+ coupleFeatureSelection: state.selection as never,
137
69
  visualStyles: generationConfig.visualStyleModifiers,
138
70
  customScenarioId: config.customScenarioId as string,
139
71
  });
140
72
  if (input) generate(input);
141
- }, [
142
- step,
143
- isProcessing,
144
- partnerA,
145
- partnerB,
146
- partnerAName,
147
- partnerBName,
148
- scenarioConfig,
149
- customPrompt,
150
- visualStyle,
151
- selection,
152
- config.steps.GENERATING,
153
- config.customScenarioId,
154
- generationConfig.defaultPartnerAName,
155
- generationConfig.defaultPartnerBName,
156
- generationConfig.visualStyleModifiers,
157
- generate,
158
- ]);
73
+ }, [step, isProcessing, state, config, generationConfig, generate]);
159
74
 
160
75
  const handleScenarioSelect = useCallback(
161
76
  (id: string) => {
@@ -181,16 +96,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
181
96
  } else {
182
97
  actions.setStep(config.steps.PARTNER_A);
183
98
  }
184
- }, [
185
- actions,
186
- config.steps.COUPLE_FEATURE_SELECTOR,
187
- config.steps.TEXT_INPUT,
188
- config.steps.PARTNER_A,
189
- config.customScenarioId,
190
- selectedFeature,
191
- selectedScenarioId,
192
- selectedScenarioData,
193
- ]);
99
+ }, [actions, config, selectedFeature, selectedScenarioId, selectedScenarioData]);
194
100
 
195
101
  const handlePartnerAContinue = useCallback(
196
102
  (image: UploadedImage, name: string) => {
@@ -202,18 +108,12 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
202
108
  );
203
109
 
204
110
  const handlePartnerABack = useCallback(() => {
205
- actions.setStep(
111
+ const targetStep =
206
112
  selectedScenarioId === config.customScenarioId
207
113
  ? config.steps.TEXT_INPUT
208
- : config.steps.SCENARIO_PREVIEW,
209
- );
210
- }, [
211
- actions,
212
- config.customScenarioId,
213
- config.steps.TEXT_INPUT,
214
- config.steps.SCENARIO_PREVIEW,
215
- selectedScenarioId,
216
- ]);
114
+ : config.steps.SCENARIO_PREVIEW;
115
+ actions.setStep(targetStep);
116
+ }, [actions, config, selectedScenarioId]);
217
117
 
218
118
  const handlePartnerBContinue = useCallback(
219
119
  (image: UploadedImage, name: string) => {
@@ -241,7 +141,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
241
141
  actions.startGeneration();
242
142
  }
243
143
  },
244
- [actions, config.customScenarioId, config.steps.PARTNER_A, selectedScenarioId],
144
+ [actions, config, selectedScenarioId],
245
145
  );
246
146
 
247
147
  const handleMagicPromptBack = useCallback(