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