@umituz/react-native-ai-generation-content 1.19.5 → 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.5",
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,22 +45,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
99
45
  alertMessages,
100
46
  });
101
47
 
102
- // Destructure state to avoid object reference changes triggering effect
103
- const {
104
- step,
105
- isProcessing,
106
- partnerA,
107
- partnerB,
108
- partnerAName,
109
- partnerBName,
110
- scenarioConfig,
111
- customPrompt,
112
- visualStyle,
113
- selection,
114
- selectedFeature,
115
- selectedScenarioId,
116
- selectedScenarioData,
117
- } = state;
48
+ const { step, isProcessing, selectedFeature, selectedScenarioId, selectedScenarioData } = state;
118
49
 
119
50
  useEffect(() => {
120
51
  if (step !== config.steps.GENERATING) {
@@ -125,38 +56,21 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
125
56
  hasStarted.current = true;
126
57
 
127
58
  const input = buildGenerationInputFromConfig({
128
- partnerA: partnerA as never,
129
- partnerB: partnerB as never,
130
- partnerAName,
131
- partnerBName,
132
- scenario: scenarioConfig as never,
133
- customPrompt: customPrompt || undefined,
134
- 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 || "",
135
66
  defaultPartnerAName: generationConfig.defaultPartnerAName,
136
67
  defaultPartnerBName: generationConfig.defaultPartnerBName,
137
- coupleFeatureSelection: selection as never,
68
+ coupleFeatureSelection: state.selection as never,
138
69
  visualStyles: generationConfig.visualStyleModifiers,
139
70
  customScenarioId: config.customScenarioId as string,
140
71
  });
141
72
  if (input) generate(input);
142
- }, [
143
- step,
144
- isProcessing,
145
- partnerA,
146
- partnerB,
147
- partnerAName,
148
- partnerBName,
149
- scenarioConfig,
150
- customPrompt,
151
- visualStyle,
152
- selection,
153
- config.steps.GENERATING,
154
- config.customScenarioId,
155
- generationConfig.defaultPartnerAName,
156
- generationConfig.defaultPartnerBName,
157
- generationConfig.visualStyleModifiers,
158
- generate,
159
- ]);
73
+ }, [step, isProcessing, state, config, generationConfig, generate]);
160
74
 
161
75
  const handleScenarioSelect = useCallback(
162
76
  (id: string) => {
@@ -182,16 +96,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
182
96
  } else {
183
97
  actions.setStep(config.steps.PARTNER_A);
184
98
  }
185
- }, [
186
- actions,
187
- config.steps.COUPLE_FEATURE_SELECTOR,
188
- config.steps.TEXT_INPUT,
189
- config.steps.PARTNER_A,
190
- config.customScenarioId,
191
- selectedFeature,
192
- selectedScenarioId,
193
- selectedScenarioData,
194
- ]);
99
+ }, [actions, config, selectedFeature, selectedScenarioId, selectedScenarioData]);
195
100
 
196
101
  const handlePartnerAContinue = useCallback(
197
102
  (image: UploadedImage, name: string) => {
@@ -203,18 +108,12 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
203
108
  );
204
109
 
205
110
  const handlePartnerABack = useCallback(() => {
206
- actions.setStep(
111
+ const targetStep =
207
112
  selectedScenarioId === config.customScenarioId
208
113
  ? config.steps.TEXT_INPUT
209
- : config.steps.SCENARIO_PREVIEW,
210
- );
211
- }, [
212
- actions,
213
- config.customScenarioId,
214
- config.steps.TEXT_INPUT,
215
- config.steps.SCENARIO_PREVIEW,
216
- selectedScenarioId,
217
- ]);
114
+ : config.steps.SCENARIO_PREVIEW;
115
+ actions.setStep(targetStep);
116
+ }, [actions, config, selectedScenarioId]);
218
117
 
219
118
  const handlePartnerBContinue = useCallback(
220
119
  (image: UploadedImage, name: string) => {
@@ -242,7 +141,7 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
242
141
  actions.startGeneration();
243
142
  }
244
143
  },
245
- [actions, config.customScenarioId, config.steps.PARTNER_A, selectedScenarioId],
144
+ [actions, config, selectedScenarioId],
246
145
  );
247
146
 
248
147
  const handleMagicPromptBack = useCallback(