@umituz/react-native-ai-generation-content 1.34.2 → 1.35.0
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.
|
|
3
|
+
"version": "1.35.0",
|
|
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",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic Wizard Flow Component
|
|
3
3
|
* Config-driven wizard for AI generation features
|
|
4
|
+
* Supports both scenario object and scenarioId (resolved from provider)
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import React, { useMemo, useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -19,12 +20,16 @@ import { useResultActions } from "../../../../result-preview/presentation/hooks/
|
|
|
19
20
|
import { validateScenario } from "../utilities/validateScenario";
|
|
20
21
|
import { WizardStepRenderer } from "./WizardStepRenderer";
|
|
21
22
|
import { StarRatingPicker } from "../../../../result-preview/presentation/components/StarRatingPicker";
|
|
23
|
+
import { useGenerationConfig } from "../../../../../infrastructure/providers";
|
|
22
24
|
|
|
23
25
|
declare const __DEV__: boolean;
|
|
24
26
|
|
|
25
27
|
export interface GenericWizardFlowProps {
|
|
26
28
|
readonly featureConfig: WizardFeatureConfig;
|
|
29
|
+
/** Full scenario object - use this OR scenarioId */
|
|
27
30
|
readonly scenario?: WizardScenarioData;
|
|
31
|
+
/** Scenario ID - resolved from GenerationConfigProvider's scenarios */
|
|
32
|
+
readonly scenarioId?: string;
|
|
28
33
|
readonly userId?: string;
|
|
29
34
|
readonly alertMessages?: AlertMessages;
|
|
30
35
|
readonly skipResultStep?: boolean;
|
|
@@ -44,7 +49,8 @@ export interface GenericWizardFlowProps {
|
|
|
44
49
|
|
|
45
50
|
export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
46
51
|
featureConfig,
|
|
47
|
-
scenario,
|
|
52
|
+
scenario: scenarioProp,
|
|
53
|
+
scenarioId,
|
|
48
54
|
userId,
|
|
49
55
|
alertMessages,
|
|
50
56
|
skipResultStep = false,
|
|
@@ -63,12 +69,51 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
63
69
|
}) => {
|
|
64
70
|
const tokens = useAppDesignTokens();
|
|
65
71
|
const alert = useAlert();
|
|
72
|
+
const { getScenarioById, defaultOutputType } = useGenerationConfig();
|
|
66
73
|
const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
|
|
67
74
|
const [showRatingPicker, setShowRatingPicker] = useState(false);
|
|
68
75
|
const [hasRated, setHasRated] = useState(false);
|
|
69
76
|
const [, setIsGeneratingDismissed] = useState(false);
|
|
70
77
|
const prevStepIdRef = useRef<string | undefined>(undefined);
|
|
71
78
|
|
|
79
|
+
// Resolve scenario: use prop directly OR lookup by scenarioId from provider
|
|
80
|
+
const scenario = useMemo<WizardScenarioData | undefined>(() => {
|
|
81
|
+
// If scenario prop is provided, use it directly
|
|
82
|
+
if (scenarioProp) {
|
|
83
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
84
|
+
console.log("[GenericWizardFlow] Using scenario from prop:", {
|
|
85
|
+
id: scenarioProp.id,
|
|
86
|
+
outputType: scenarioProp.outputType,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return scenarioProp;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// If scenarioId is provided, lookup from provider
|
|
93
|
+
if (scenarioId) {
|
|
94
|
+
const found = getScenarioById(scenarioId);
|
|
95
|
+
if (found) {
|
|
96
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
97
|
+
console.log("[GenericWizardFlow] Resolved scenario from provider:", {
|
|
98
|
+
id: found.id,
|
|
99
|
+
outputType: found.outputType,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return found as unknown as WizardScenarioData;
|
|
103
|
+
}
|
|
104
|
+
// Scenario not found in provider - create minimal with default outputType
|
|
105
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
106
|
+
console.warn("[GenericWizardFlow] Scenario not found in provider:", scenarioId);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
id: scenarioId,
|
|
110
|
+
outputType: defaultOutputType,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return undefined;
|
|
115
|
+
}, [scenarioProp, scenarioId, getScenarioById, defaultOutputType]);
|
|
116
|
+
|
|
72
117
|
const repository = useMemo(() => createCreationsRepository("creations"), []);
|
|
73
118
|
|
|
74
119
|
const flowSteps = useMemo<StepDefinition[]>(() => {
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generation Config Provider
|
|
3
3
|
* Provides app-specific configuration to the package
|
|
4
|
-
* NO hard-coded models, everything comes from app!
|
|
4
|
+
* NO hard-coded models/scenarios, everything comes from app!
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React, { createContext, useContext, type ReactNode } from "react";
|
|
7
|
+
import React, { createContext, useContext, useMemo, type ReactNode } from "react";
|
|
8
|
+
import type { Scenario, ScenarioOutputType } from "../../domains/scenarios/domain/Scenario";
|
|
8
9
|
|
|
9
10
|
declare const __DEV__: boolean;
|
|
10
11
|
|
|
@@ -35,11 +36,23 @@ export interface GenerationModels {
|
|
|
35
36
|
readonly textToVoice?: string;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/** Configured scenario from app */
|
|
40
|
+
export interface ConfiguredScenario extends Scenario {
|
|
41
|
+
/** Output type - REQUIRED when configured by app */
|
|
42
|
+
readonly outputType: ScenarioOutputType;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
export interface GenerationConfigValue {
|
|
39
46
|
/** AI models configuration from app */
|
|
40
47
|
readonly models: GenerationModels;
|
|
48
|
+
/** Configured scenarios from app (with outputType set) */
|
|
49
|
+
readonly scenarios: readonly ConfiguredScenario[];
|
|
50
|
+
/** Default output type for this app */
|
|
51
|
+
readonly defaultOutputType: ScenarioOutputType;
|
|
41
52
|
/** Get model for specific feature type */
|
|
42
53
|
readonly getModel: (featureType: keyof GenerationModels) => string;
|
|
54
|
+
/** Get scenario by ID from configured scenarios */
|
|
55
|
+
readonly getScenarioById: (id: string) => ConfiguredScenario | undefined;
|
|
43
56
|
}
|
|
44
57
|
|
|
45
58
|
// ============================================================================
|
|
@@ -54,24 +67,29 @@ const GenerationConfigContext = createContext<GenerationConfigValue | null>(null
|
|
|
54
67
|
|
|
55
68
|
export interface GenerationConfigProviderProps {
|
|
56
69
|
readonly children: ReactNode;
|
|
70
|
+
/** AI models configuration */
|
|
57
71
|
readonly models: GenerationModels;
|
|
72
|
+
/** App-configured scenarios (optional - for scenario-based generation) */
|
|
73
|
+
readonly scenarios?: readonly ConfiguredScenario[];
|
|
74
|
+
/** Default output type for this app (default: "video") */
|
|
75
|
+
readonly defaultOutputType?: ScenarioOutputType;
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
export const GenerationConfigProvider: React.FC<GenerationConfigProviderProps> = ({
|
|
61
79
|
children,
|
|
62
80
|
models,
|
|
81
|
+
scenarios = [],
|
|
82
|
+
defaultOutputType = "video",
|
|
63
83
|
}) => {
|
|
64
84
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
65
85
|
const configuredModels = Object.entries(models)
|
|
66
86
|
.filter(([, value]) => !!value)
|
|
67
87
|
.map(([key]) => key);
|
|
68
88
|
|
|
69
|
-
console.log("[GenerationConfigProvider] Initialized
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
imageToVideo: models.imageToVideo || "not configured",
|
|
74
|
-
textToVideo: models.textToVideo || "not configured",
|
|
89
|
+
console.log("[GenerationConfigProvider] Initialized:", {
|
|
90
|
+
models: configuredModels,
|
|
91
|
+
scenariosCount: scenarios.length,
|
|
92
|
+
defaultOutputType,
|
|
75
93
|
});
|
|
76
94
|
}
|
|
77
95
|
|
|
@@ -91,9 +109,32 @@ export const GenerationConfigProvider: React.FC<GenerationConfigProviderProps> =
|
|
|
91
109
|
return model;
|
|
92
110
|
};
|
|
93
111
|
|
|
112
|
+
const scenarioMap = useMemo(() => {
|
|
113
|
+
const map = new Map<string, ConfiguredScenario>();
|
|
114
|
+
for (const scenario of scenarios) {
|
|
115
|
+
map.set(scenario.id, scenario);
|
|
116
|
+
}
|
|
117
|
+
return map;
|
|
118
|
+
}, [scenarios]);
|
|
119
|
+
|
|
120
|
+
const getScenarioById = (id: string): ConfiguredScenario | undefined => {
|
|
121
|
+
const found = scenarioMap.get(id);
|
|
122
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
123
|
+
console.log("[GenerationConfigProvider] getScenarioById:", {
|
|
124
|
+
id,
|
|
125
|
+
found: !!found,
|
|
126
|
+
outputType: found?.outputType,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return found;
|
|
130
|
+
};
|
|
131
|
+
|
|
94
132
|
const value: GenerationConfigValue = {
|
|
95
133
|
models,
|
|
134
|
+
scenarios,
|
|
135
|
+
defaultOutputType,
|
|
96
136
|
getModel,
|
|
137
|
+
getScenarioById,
|
|
97
138
|
};
|
|
98
139
|
|
|
99
140
|
return (
|