@umituz/react-native-ai-generation-content 1.34.0 → 1.34.2
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 +1 -1
- package/src/domains/generation/wizard/presentation/components/GenericWizardFlow.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/WizardStepRenderer.tsx +4 -2
- package/src/domains/scenarios/domain/Scenario.ts +2 -1
- package/src/domains/scenarios/index.ts +10 -0
- package/src/domains/scenarios/infrastructure/ScenariosData.ts +8 -4
- package/src/domains/scenarios/infrastructure/scenario-helpers.ts +122 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.2",
|
|
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",
|
|
@@ -66,7 +66,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
66
66
|
const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
|
|
67
67
|
const [showRatingPicker, setShowRatingPicker] = useState(false);
|
|
68
68
|
const [hasRated, setHasRated] = useState(false);
|
|
69
|
-
const [
|
|
69
|
+
const [, setIsGeneratingDismissed] = useState(false);
|
|
70
70
|
const prevStepIdRef = useRef<string | undefined>(undefined);
|
|
71
71
|
|
|
72
72
|
const repository = useMemo(() => createCreationsRepository("creations"), []);
|
|
@@ -167,7 +167,8 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
|
|
|
167
167
|
onBack={onBack}
|
|
168
168
|
onContinue={(text) => {
|
|
169
169
|
// Store text in a structure compatible with existing handlers
|
|
170
|
-
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
+
onPhotoContinue(step.id, { uri: text, text, previewUrl: "" } as unknown as any);
|
|
171
172
|
}}
|
|
172
173
|
/>
|
|
173
174
|
);
|
|
@@ -204,7 +205,8 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
|
|
|
204
205
|
onBack={onBack}
|
|
205
206
|
onContinue={(value) => {
|
|
206
207
|
// Store selection value
|
|
207
|
-
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
|
+
onPhotoContinue(step.id, { uri: String(value), selection: value, previewUrl: "" } as unknown as any);
|
|
208
210
|
}}
|
|
209
211
|
/>
|
|
210
212
|
);
|
|
@@ -573,7 +573,8 @@ export interface Scenario {
|
|
|
573
573
|
storyTemplate: string;
|
|
574
574
|
requiresPhoto?: boolean;
|
|
575
575
|
hidden?: boolean;
|
|
576
|
-
|
|
576
|
+
/** Output type - optional, apps should configure via createScenariosForApp() */
|
|
577
|
+
outputType?: ScenarioOutputType;
|
|
577
578
|
model?: string; // AI model from app config
|
|
578
579
|
enabled?: boolean;
|
|
579
580
|
// Optional custom generating screen messages
|
|
@@ -11,6 +11,16 @@ export type { Scenario } from "./domain/Scenario";
|
|
|
11
11
|
// Scenario Data
|
|
12
12
|
export { SCENARIOS } from "./infrastructure/ScenariosData";
|
|
13
13
|
|
|
14
|
+
// Scenario Helpers - For app-level configuration
|
|
15
|
+
export {
|
|
16
|
+
createScenariosForApp,
|
|
17
|
+
filterScenariosByOutputType,
|
|
18
|
+
filterScenariosByCategory,
|
|
19
|
+
getScenarioCategories,
|
|
20
|
+
findScenarioById,
|
|
21
|
+
} from "./infrastructure/scenario-helpers";
|
|
22
|
+
export type { AppScenarioConfig } from "./infrastructure/scenario-helpers";
|
|
23
|
+
|
|
14
24
|
// Utils
|
|
15
25
|
export { createStoryTemplate } from "./infrastructure/utils/scenario-utils";
|
|
16
26
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Generic for all AI generation apps (image/video)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Scenario, ScenarioCategory
|
|
7
|
+
import { Scenario, ScenarioCategory } from "../domain/Scenario";
|
|
8
8
|
import { TIME_BASED_SCENARIOS } from "./data/time-based-scenarios";
|
|
9
9
|
import { FAMILY_SCENARIOS } from "./data/family-scenarios";
|
|
10
10
|
import { LIFESTYLE_SCENARIOS } from "./data/lifestyle-scenarios";
|
|
@@ -78,11 +78,15 @@ import { UNDERWATER_SCENARIOS } from "./data/underwater-scenarios";
|
|
|
78
78
|
import { ARABIAN_NIGHTS_SCENARIOS } from "./data/arabian-nights-scenarios";
|
|
79
79
|
import { PREHISTORIC_WORLD_SCENARIOS } from "./data/prehistoric-world-scenarios";
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Assigns category to scenarios
|
|
83
|
+
* Note: outputType is NOT assigned here - apps configure via createScenariosForApp()
|
|
84
|
+
*/
|
|
85
|
+
const assignCategory = (scenarios: Omit<Scenario, 'category'>[], category: ScenarioCategory) =>
|
|
86
|
+
scenarios.map((s) => ({ ...s, category }));
|
|
83
87
|
|
|
84
88
|
export const SCENARIOS: Scenario[] = [
|
|
85
|
-
{ ...CUSTOM_SCENARIO, category: ScenarioCategory.FANTASY
|
|
89
|
+
{ ...CUSTOM_SCENARIO, category: ScenarioCategory.FANTASY },
|
|
86
90
|
|
|
87
91
|
// Time & Future
|
|
88
92
|
...assignCategory(TIME_BASED_SCENARIOS, ScenarioCategory.TIME_TRAVEL),
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scenario Helpers
|
|
3
|
+
* Utilities for configuring scenarios in apps
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Scenario, ScenarioOutputType } from "../domain/Scenario";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for creating app-specific scenarios
|
|
10
|
+
*/
|
|
11
|
+
export interface AppScenarioConfig {
|
|
12
|
+
/** Output type for all scenarios (image or video) */
|
|
13
|
+
readonly outputType: ScenarioOutputType;
|
|
14
|
+
/** Optional AI model to assign to all scenarios */
|
|
15
|
+
readonly model?: string;
|
|
16
|
+
/** Optional filter to exclude certain scenarios by ID */
|
|
17
|
+
readonly excludeIds?: readonly string[];
|
|
18
|
+
/** Optional filter to include only certain category IDs */
|
|
19
|
+
readonly includeCategories?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates app-configured scenarios from package scenarios
|
|
24
|
+
* Apps use this to set their desired outputType and model
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Video generation app
|
|
28
|
+
* const scenarios = createScenariosForApp(SCENARIOS, {
|
|
29
|
+
* outputType: "video",
|
|
30
|
+
* model: "fal-ai/veo3/image-to-video"
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Image generation app
|
|
35
|
+
* const scenarios = createScenariosForApp(SCENARIOS, {
|
|
36
|
+
* outputType: "image",
|
|
37
|
+
* model: "fal-ai/nano-banana/edit",
|
|
38
|
+
* excludeIds: ["custom"]
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
41
|
+
export const createScenariosForApp = (
|
|
42
|
+
scenarios: readonly Scenario[],
|
|
43
|
+
config: AppScenarioConfig,
|
|
44
|
+
): Scenario[] => {
|
|
45
|
+
const { outputType, model, excludeIds, includeCategories } = config;
|
|
46
|
+
|
|
47
|
+
return scenarios
|
|
48
|
+
.filter((scenario) => {
|
|
49
|
+
// Filter by excluded IDs
|
|
50
|
+
if (excludeIds?.includes(scenario.id)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
// Filter by included categories
|
|
54
|
+
if (
|
|
55
|
+
includeCategories &&
|
|
56
|
+
includeCategories.length > 0 &&
|
|
57
|
+
scenario.category &&
|
|
58
|
+
!includeCategories.includes(scenario.category)
|
|
59
|
+
) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
})
|
|
64
|
+
.map((scenario) => ({
|
|
65
|
+
...scenario,
|
|
66
|
+
outputType,
|
|
67
|
+
...(model && { model }),
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Filters scenarios by output type (if they have one set)
|
|
73
|
+
* Useful for apps that have mixed scenarios with different output types
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const videoScenarios = filterScenariosByOutputType(scenarios, "video");
|
|
77
|
+
*/
|
|
78
|
+
export const filterScenariosByOutputType = (
|
|
79
|
+
scenarios: readonly Scenario[],
|
|
80
|
+
outputType: ScenarioOutputType,
|
|
81
|
+
): Scenario[] => scenarios.filter((s) => s.outputType === outputType);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Filters scenarios by category
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const weddingScenarios = filterScenariosByCategory(scenarios, "wedding");
|
|
88
|
+
*/
|
|
89
|
+
export const filterScenariosByCategory = (
|
|
90
|
+
scenarios: readonly Scenario[],
|
|
91
|
+
category: string,
|
|
92
|
+
): Scenario[] => scenarios.filter((s) => s.category === category);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Gets unique categories from scenarios
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const categories = getScenarioCategories(scenarios);
|
|
99
|
+
* // ["wedding", "fantasy", "adventure", ...]
|
|
100
|
+
*/
|
|
101
|
+
export const getScenarioCategories = (
|
|
102
|
+
scenarios: readonly Scenario[],
|
|
103
|
+
): string[] => {
|
|
104
|
+
const categories = new Set<string>();
|
|
105
|
+
scenarios.forEach((s) => {
|
|
106
|
+
if (s.category) {
|
|
107
|
+
categories.add(s.category);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return Array.from(categories);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Finds a scenario by ID
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const scenario = findScenarioById(scenarios, "beach_wedding");
|
|
118
|
+
*/
|
|
119
|
+
export const findScenarioById = (
|
|
120
|
+
scenarios: readonly Scenario[],
|
|
121
|
+
id: string,
|
|
122
|
+
): Scenario | undefined => scenarios.find((s) => s.id === id);
|