@umituz/react-native-ai-generation-content 1.22.6 → 1.22.8

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.22.6",
3
+ "version": "1.22.8",
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",
@@ -3,7 +3,7 @@
3
3
  * Complete wizard component for couple future generation flow
4
4
  */
5
5
 
6
- import React, { useCallback, useMemo, useEffect } from "react";
6
+ import React, { useCallback, useMemo } from "react";
7
7
  import { View, StyleSheet } from "react-native";
8
8
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
9
9
  import { useFlow, resetFlowStore } from "../../../../infrastructure/flow";
@@ -38,17 +38,15 @@ export const CoupleFutureWizard: React.FC<CoupleFutureWizardProps> = ({
38
38
  [config],
39
39
  );
40
40
 
41
- const flow = useFlow({ steps: stepDefinitions });
41
+ // Determine initial step: skip SCENARIO_SELECTION if scenario is pre-selected
42
+ const initialStepIndex = useMemo(() => {
43
+ return data.selectedScenario ? 1 : 0;
44
+ }, [data.selectedScenario]);
42
45
 
43
- // Auto-advance flow if scenario is pre-selected (from CategoryNavigationContainer)
44
- useEffect(() => {
45
- const isAtScenarioSelectionStep = flow.currentStep?.type === StepType.SCENARIO_SELECTION;
46
- const hasPreSelectedScenario = data.selectedScenario && !flow.selectedCategory;
47
-
48
- if (isAtScenarioSelectionStep && hasPreSelectedScenario) {
49
- flow.nextStep();
50
- }
51
- }, [flow, data.selectedScenario]);
46
+ const flow = useFlow({
47
+ steps: stepDefinitions,
48
+ initialStepIndex,
49
+ });
52
50
 
53
51
  const handleScenarioSelect = useCallback(
54
52
  (scenario: WizardScenarioData) => {
@@ -10,6 +10,7 @@ import type { FlowState, FlowActions, StepDefinition, FlowUploadedImageData } fr
10
10
  interface UseFlowConfig {
11
11
  steps: readonly StepDefinition[];
12
12
  initialStepId?: string;
13
+ initialStepIndex?: number;
13
14
  }
14
15
 
15
16
  interface UseFlowReturn extends FlowState, FlowActions {
@@ -31,7 +32,11 @@ export const useFlow = (config: UseFlowConfig): UseFlowReturn => {
31
32
 
32
33
  if (!storeRef.current) {
33
34
  if (!flowStoreInstance) {
34
- flowStoreInstance = createFlowStore(config);
35
+ flowStoreInstance = createFlowStore({
36
+ steps: config.steps,
37
+ initialStepId: config.initialStepId,
38
+ initialStepIndex: config.initialStepIndex,
39
+ });
35
40
  }
36
41
  storeRef.current = flowStoreInstance;
37
42
  }
@@ -36,11 +36,20 @@ const createInitialState = (): FlowState => ({
36
36
  interface FlowStoreConfig {
37
37
  steps: readonly StepDefinition[];
38
38
  initialStepId?: string;
39
+ initialStepIndex?: number;
39
40
  }
40
41
 
41
42
  export const createFlowStore = (config: FlowStoreConfig) => {
42
- const initialStepId = config.initialStepId ?? config.steps[0]?.id ?? "";
43
- const initialIndex = Math.max(0, config.steps.findIndex((s) => s.id === initialStepId));
43
+ // Support both initialStepId and initialStepIndex
44
+ let initialIndex = 0;
45
+
46
+ if (config.initialStepIndex !== undefined) {
47
+ initialIndex = Math.max(0, Math.min(config.initialStepIndex, config.steps.length - 1));
48
+ } else if (config.initialStepId) {
49
+ initialIndex = Math.max(0, config.steps.findIndex((s) => s.id === config.initialStepId));
50
+ }
51
+
52
+ const initialStepId = config.steps[initialIndex]?.id ?? "";
44
53
 
45
54
  const initialState: FlowStoreState = {
46
55
  ...createInitialState(),
@@ -8,19 +8,7 @@ import { useGenerationOrchestrator } from "./orchestrator";
8
8
  import { prepareImage } from "../../../infrastructure/utils";
9
9
  import type { AIFeatureId } from "../../screens/ai-feature/types";
10
10
  import type { ImageFeatureType, VideoFeatureType } from "../../../domain/interfaces";
11
-
12
- interface AlertMessages {
13
- success?: string;
14
- error?: string;
15
- network?: string;
16
- credits?: string;
17
- }
18
-
19
- interface GenerationError {
20
- type: string;
21
- message: string;
22
- originalError?: Error;
23
- }
11
+ import type { AlertMessages, GenerationError } from "./types";
24
12
 
25
13
  interface FeatureGenerationConfig {
26
14
  featureType: AIFeatureId;