@umituz/react-native-ai-generation-content 1.25.13 → 1.25.15
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.25.
|
|
3
|
+
"version": "1.25.15",
|
|
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",
|
|
@@ -69,24 +69,43 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
69
69
|
});
|
|
70
70
|
}, [featureConfig, renderPreview, renderGenerating]);
|
|
71
71
|
|
|
72
|
-
// Initialize flow
|
|
72
|
+
// Initialize flow and destructure to prevent infinite loops
|
|
73
73
|
const flow = useFlow({
|
|
74
74
|
steps: flowSteps,
|
|
75
75
|
initialStepIndex: 0,
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
+
// Destructure flow to get stable references for useCallback dependencies
|
|
79
|
+
const {
|
|
80
|
+
currentStep,
|
|
81
|
+
currentStepIndex,
|
|
82
|
+
customData,
|
|
83
|
+
generationProgress,
|
|
84
|
+
generationResult,
|
|
85
|
+
nextStep,
|
|
86
|
+
previousStep,
|
|
87
|
+
setCustomData,
|
|
88
|
+
updateProgress,
|
|
89
|
+
} = flow;
|
|
90
|
+
|
|
91
|
+
// Handle progress change - memoized to prevent infinite loops
|
|
92
|
+
const handleProgressChange = useCallback(
|
|
93
|
+
(progress: number) => {
|
|
94
|
+
updateProgress(progress);
|
|
95
|
+
},
|
|
96
|
+
[updateProgress],
|
|
97
|
+
);
|
|
98
|
+
|
|
78
99
|
// Generation hook - handles AI generation automatically
|
|
79
100
|
const generationHook = useWizardGeneration({
|
|
80
101
|
scenario: scenario || { id: featureConfig.id, aiPrompt: "" },
|
|
81
|
-
wizardData:
|
|
102
|
+
wizardData: customData,
|
|
82
103
|
userId,
|
|
83
|
-
isGeneratingStep:
|
|
104
|
+
isGeneratingStep: currentStep?.type === StepType.GENERATING,
|
|
84
105
|
alertMessages,
|
|
85
106
|
onSuccess: onGenerationComplete,
|
|
86
107
|
onError: onGenerationError,
|
|
87
|
-
onProgressChange:
|
|
88
|
-
flow.updateProgress(progress);
|
|
89
|
-
},
|
|
108
|
+
onProgressChange: handleProgressChange,
|
|
90
109
|
onCreditsExhausted,
|
|
91
110
|
});
|
|
92
111
|
|
|
@@ -97,9 +116,9 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
97
116
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
98
117
|
console.log("[GenericWizardFlow] Render", {
|
|
99
118
|
featureId: featureConfig.id,
|
|
100
|
-
currentStepId:
|
|
101
|
-
currentStepType:
|
|
102
|
-
stepIndex:
|
|
119
|
+
currentStepId: currentStep?.id,
|
|
120
|
+
currentStepType: currentStep?.type,
|
|
121
|
+
stepIndex: currentStepIndex,
|
|
103
122
|
totalSteps: flowSteps.length,
|
|
104
123
|
});
|
|
105
124
|
}
|
|
@@ -107,72 +126,72 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
107
126
|
// Notify parent when step changes
|
|
108
127
|
// Only call onStepChange when step ID actually changes (not on every object reference change)
|
|
109
128
|
useEffect(() => {
|
|
110
|
-
if (
|
|
111
|
-
const currentStepId =
|
|
129
|
+
if (currentStep && onStepChange) {
|
|
130
|
+
const currentStepId = currentStep.id;
|
|
112
131
|
// Only notify if step ID changed
|
|
113
132
|
if (prevStepIdRef.current !== currentStepId) {
|
|
114
133
|
prevStepIdRef.current = currentStepId;
|
|
115
134
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
116
135
|
console.log("[GenericWizardFlow] Step changed", {
|
|
117
|
-
stepId:
|
|
118
|
-
stepType:
|
|
136
|
+
stepId: currentStep.id,
|
|
137
|
+
stepType: currentStep.type,
|
|
119
138
|
});
|
|
120
139
|
}
|
|
121
|
-
onStepChange(
|
|
140
|
+
onStepChange(currentStep.id, currentStep.type);
|
|
122
141
|
}
|
|
123
142
|
}
|
|
124
|
-
}, [
|
|
143
|
+
}, [currentStep, currentStepIndex, onStepChange]);
|
|
125
144
|
|
|
126
145
|
// Handle step continue
|
|
127
146
|
const handleStepContinue = useCallback(
|
|
128
147
|
(stepData: Record<string, unknown>) => {
|
|
129
148
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
130
149
|
console.log("[GenericWizardFlow] Step continue", {
|
|
131
|
-
stepId:
|
|
150
|
+
stepId: currentStep?.id,
|
|
132
151
|
data: stepData,
|
|
133
152
|
});
|
|
134
153
|
}
|
|
135
154
|
|
|
136
155
|
// Store step data in custom data
|
|
137
156
|
Object.entries(stepData).forEach(([key, value]) => {
|
|
138
|
-
|
|
157
|
+
setCustomData(key, value);
|
|
139
158
|
});
|
|
140
159
|
|
|
141
160
|
// Check if this is the last step before generating
|
|
142
|
-
if (
|
|
161
|
+
if (currentStepIndex === flowSteps.length - 2) {
|
|
143
162
|
// Next step is GENERATING
|
|
144
163
|
// Notify parent and provide callback to proceed to generating
|
|
145
164
|
// Parent will call proceedToGenerating() after feature gate passes
|
|
146
165
|
if (onGenerationStart) {
|
|
147
|
-
onGenerationStart(
|
|
166
|
+
onGenerationStart(customData, () => {
|
|
148
167
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
149
168
|
console.log("[GenericWizardFlow] Proceeding to GENERATING step");
|
|
150
169
|
}
|
|
151
|
-
|
|
170
|
+
nextStep();
|
|
152
171
|
});
|
|
153
172
|
}
|
|
154
|
-
// DON'T call
|
|
173
|
+
// DON'T call nextStep() here - parent will call it via proceedToGenerating callback
|
|
155
174
|
return;
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
// Move to next step (for all non-generation steps)
|
|
159
|
-
|
|
178
|
+
nextStep();
|
|
160
179
|
},
|
|
161
|
-
[
|
|
180
|
+
[currentStep, currentStepIndex, customData, setCustomData, nextStep, flowSteps.length, onGenerationStart],
|
|
162
181
|
);
|
|
163
182
|
|
|
164
183
|
// Handle back
|
|
165
184
|
const handleBack = useCallback(() => {
|
|
166
|
-
if (
|
|
185
|
+
if (currentStepIndex === 0) {
|
|
167
186
|
onBack?.();
|
|
168
187
|
} else {
|
|
169
|
-
|
|
188
|
+
previousStep();
|
|
170
189
|
}
|
|
171
|
-
}, [
|
|
190
|
+
}, [currentStepIndex, previousStep, onBack]);
|
|
172
191
|
|
|
173
192
|
// Render current step
|
|
174
193
|
const renderCurrentStep = useCallback(() => {
|
|
175
|
-
const step =
|
|
194
|
+
const step = currentStep;
|
|
176
195
|
if (!step) {
|
|
177
196
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
178
197
|
console.warn("[GenericWizardFlow] No current step!");
|
|
@@ -191,13 +210,13 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
191
210
|
switch (step.type) {
|
|
192
211
|
case StepType.SCENARIO_PREVIEW:
|
|
193
212
|
// Preview continues to next step automatically
|
|
194
|
-
return renderPreview?.(
|
|
213
|
+
return renderPreview?.(nextStep) || null;
|
|
195
214
|
|
|
196
215
|
case StepType.GENERATING:
|
|
197
|
-
return renderGenerating?.(
|
|
216
|
+
return renderGenerating?.(generationProgress) || null;
|
|
198
217
|
|
|
199
218
|
case StepType.RESULT_PREVIEW:
|
|
200
|
-
return renderResult?.(
|
|
219
|
+
return renderResult?.(generationResult) || null;
|
|
201
220
|
|
|
202
221
|
default:
|
|
203
222
|
// Use generic step renderer
|
|
@@ -210,9 +229,10 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
210
229
|
});
|
|
211
230
|
}
|
|
212
231
|
}, [
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
232
|
+
currentStep,
|
|
233
|
+
generationProgress,
|
|
234
|
+
generationResult,
|
|
235
|
+
nextStep,
|
|
216
236
|
renderPreview,
|
|
217
237
|
renderGenerating,
|
|
218
238
|
renderResult,
|