@umituz/react-native-ai-generation-content 1.19.3 → 1.19.5

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.3",
3
+ "version": "1.19.5",
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",
@@ -99,30 +99,64 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
99
99
  alertMessages,
100
100
  });
101
101
 
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;
118
+
102
119
  useEffect(() => {
103
- if (state.step !== config.steps.GENERATING) {
120
+ if (step !== config.steps.GENERATING) {
104
121
  hasStarted.current = false;
105
122
  return;
106
123
  }
107
- if (!state.isProcessing || hasStarted.current) return;
124
+ if (!isProcessing || hasStarted.current) return;
108
125
  hasStarted.current = true;
109
126
 
110
127
  const input = buildGenerationInputFromConfig({
111
- partnerA: state.partnerA as never,
112
- partnerB: state.partnerB as never,
113
- partnerAName: state.partnerAName,
114
- partnerBName: state.partnerBName,
115
- scenario: state.scenarioConfig as never,
116
- customPrompt: state.customPrompt || undefined,
117
- visualStyle: state.visualStyle || "",
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 || "",
118
135
  defaultPartnerAName: generationConfig.defaultPartnerAName,
119
136
  defaultPartnerBName: generationConfig.defaultPartnerBName,
120
- coupleFeatureSelection: state.selection as never,
137
+ coupleFeatureSelection: selection as never,
121
138
  visualStyles: generationConfig.visualStyleModifiers,
122
139
  customScenarioId: config.customScenarioId as string,
123
140
  });
124
141
  if (input) generate(input);
125
- }, [state, config, generationConfig, generate]);
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
+ ]);
126
160
 
127
161
  const handleScenarioSelect = useCallback(
128
162
  (id: string) => {
@@ -138,17 +172,26 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
138
172
  );
139
173
 
140
174
  const handleScenarioPreviewContinue = useCallback(() => {
141
- if (state.selectedFeature) {
175
+ if (selectedFeature) {
142
176
  actions.setStep(config.steps.COUPLE_FEATURE_SELECTOR);
143
177
  } else if (
144
- state.selectedScenarioId === config.customScenarioId ||
145
- state.selectedScenarioData?.requiresPhoto === false
178
+ selectedScenarioId === config.customScenarioId ||
179
+ selectedScenarioData?.requiresPhoto === false
146
180
  ) {
147
181
  actions.setStep(config.steps.TEXT_INPUT);
148
182
  } else {
149
183
  actions.setStep(config.steps.PARTNER_A);
150
184
  }
151
- }, [actions, config, state]);
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
+ ]);
152
195
 
153
196
  const handlePartnerAContinue = useCallback(
154
197
  (image: UploadedImage, name: string) => {
@@ -161,11 +204,17 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
161
204
 
162
205
  const handlePartnerABack = useCallback(() => {
163
206
  actions.setStep(
164
- state.selectedScenarioId === config.customScenarioId
207
+ selectedScenarioId === config.customScenarioId
165
208
  ? config.steps.TEXT_INPUT
166
209
  : config.steps.SCENARIO_PREVIEW,
167
210
  );
168
- }, [actions, config, state.selectedScenarioId]);
211
+ }, [
212
+ actions,
213
+ config.customScenarioId,
214
+ config.steps.TEXT_INPUT,
215
+ config.steps.SCENARIO_PREVIEW,
216
+ selectedScenarioId,
217
+ ]);
169
218
 
170
219
  const handlePartnerBContinue = useCallback(
171
220
  (image: UploadedImage, name: string) => {
@@ -187,13 +236,13 @@ export const useCoupleFutureFlow = <TStep, TScenarioId, TResult>(
187
236
  (prompt: string, style: string) => {
188
237
  actions.setCustomPrompt(prompt);
189
238
  actions.setVisualStyle(style);
190
- if (state.selectedScenarioId === config.customScenarioId) {
239
+ if (selectedScenarioId === config.customScenarioId) {
191
240
  actions.setStep(config.steps.PARTNER_A);
192
241
  } else {
193
242
  actions.startGeneration();
194
243
  }
195
244
  },
196
- [actions, config, state.selectedScenarioId],
245
+ [actions, config.customScenarioId, config.steps.PARTNER_A, selectedScenarioId],
197
246
  );
198
247
 
199
248
  const handleMagicPromptBack = useCallback(