@umituz/react-native-ai-generation-content 1.72.29 → 1.72.31
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/application/generation-strategy.factory.ts +0 -4
- package/src/domains/generation/wizard/configs/image-to-video.config.ts +6 -1
- package/src/domains/generation/wizard/configs/text-to-video.config.ts +6 -1
- package/src/domains/generation/wizard/domain/entities/wizard-step.types.ts +1 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +0 -2
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +0 -2
- package/src/domains/generation/wizard/infrastructure/strategies/wizard-strategy.types.ts +0 -2
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderSelectionStep.tsx +1 -0
- package/src/domains/generation/wizard/presentation/screens/SelectionScreen.tsx +6 -6
- package/src/domains/generation/wizard/presentation/screens/SelectionScreen.types.ts +1 -0
- package/src/domains/image-to-video/presentation/hooks/imageToVideoStrategy.ts +0 -1
- package/src/domains/text-to-image/presentation/hooks/useGeneration.ts +0 -2
- package/src/domains/text-to-video/presentation/hooks/textToVideoStrategy.ts +0 -1
- package/src/presentation/hooks/ai-feature-callbacks-execution.hooks.ts +2 -7
- package/src/presentation/hooks/ai-feature-callbacks.types.ts +0 -1
- package/src/presentation/hooks/generation/useDualImageGeneration.ts +0 -2
- package/src/presentation/hooks/generation/useImageGeneration.ts +0 -2
- package/src/presentation/hooks/generation/useVideoGeneration.ts +0 -2
- package/src/presentation/hooks/useAIFeatureCallbacks.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.72.
|
|
3
|
+
"version": "1.72.31",
|
|
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",
|
|
@@ -61,10 +61,6 @@ export function createGenerationStrategy(
|
|
|
61
61
|
return result.data;
|
|
62
62
|
},
|
|
63
63
|
|
|
64
|
-
getCreditCost: () => {
|
|
65
|
-
return featureConfig.creditCost;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
64
|
save: async (result: unknown, uid: string) => {
|
|
69
65
|
if (!repository) {
|
|
70
66
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -31,7 +31,12 @@ export const IMAGE_TO_VIDEO_WIZARD_CONFIG: WizardFeatureConfig = {
|
|
|
31
31
|
type: "selection",
|
|
32
32
|
titleKey: "generation.duration.title",
|
|
33
33
|
selectionType: "duration",
|
|
34
|
-
|
|
34
|
+
layout: "list",
|
|
35
|
+
options: [
|
|
36
|
+
{ id: "4s", label: "4 seconds", value: 4 },
|
|
37
|
+
{ id: "5s", label: "5 seconds", value: 5 },
|
|
38
|
+
{ id: "6s", label: "6 seconds", value: 6 },
|
|
39
|
+
],
|
|
35
40
|
required: true,
|
|
36
41
|
defaultValue: "4s",
|
|
37
42
|
},
|
|
@@ -49,7 +49,12 @@ export const TEXT_TO_VIDEO_WIZARD_CONFIG: WizardFeatureConfig = {
|
|
|
49
49
|
type: "selection",
|
|
50
50
|
titleKey: "generation.duration.title",
|
|
51
51
|
selectionType: "duration",
|
|
52
|
-
|
|
52
|
+
layout: "list",
|
|
53
|
+
options: [
|
|
54
|
+
{ id: "4s", label: "4 seconds", value: 4 },
|
|
55
|
+
{ id: "5s", label: "5 seconds", value: 5 },
|
|
56
|
+
{ id: "6s", label: "6 seconds", value: 6 },
|
|
57
|
+
],
|
|
53
58
|
required: true,
|
|
54
59
|
defaultValue: "4s",
|
|
55
60
|
},
|
|
@@ -15,6 +15,4 @@ export interface WizardStrategy {
|
|
|
15
15
|
execute: (input: unknown) => Promise<{ imageUrl?: string; videoUrl?: string }>;
|
|
16
16
|
/** Submit to queue for background processing - returns immediately with requestId */
|
|
17
17
|
submitToQueue?: (input: unknown) => Promise<QueueSubmissionResult>;
|
|
18
|
-
/** Get credit cost for this generation */
|
|
19
|
-
getCreditCost: () => number;
|
|
20
18
|
}
|
|
@@ -134,7 +134,7 @@ export const SelectionScreen: React.FC<SelectionScreenProps> = ({
|
|
|
134
134
|
<ScreenLayout scrollable={true} edges={["left", "right"]} hideScrollIndicator={true} contentContainerStyle={styles.scrollContent}>
|
|
135
135
|
<AtomicText type="headlineMedium" color="textPrimary" style={styles.title}>{translations.title}</AtomicText>
|
|
136
136
|
{translations.subtitle ? <AtomicText type="bodyMedium" color="textSecondary" style={styles.subtitle}>{translations.subtitle}</AtomicText> : null}
|
|
137
|
-
<View style={styles.optionsGrid}>{options.map(renderOption)}</View>
|
|
137
|
+
<View style={[styles.optionsGrid, config?.layout === "grid" && { flexDirection: "row", flexWrap: "wrap" }]}>{options.map(renderOption)}</View>
|
|
138
138
|
</ScreenLayout>
|
|
139
139
|
</View>
|
|
140
140
|
);
|
|
@@ -145,19 +145,19 @@ const createStyles = (tokens: DesignTokens) =>
|
|
|
145
145
|
scrollContent: { paddingHorizontal: tokens.spacing.lg, paddingBottom: 40 },
|
|
146
146
|
title: { marginBottom: tokens.spacing.sm },
|
|
147
147
|
subtitle: { marginBottom: tokens.spacing.lg },
|
|
148
|
-
optionsGrid: {
|
|
148
|
+
optionsGrid: { gap: tokens.spacing.sm },
|
|
149
149
|
optionCard: {
|
|
150
150
|
flex: 1,
|
|
151
|
-
|
|
151
|
+
width: "100%",
|
|
152
152
|
padding: tokens.spacing.md,
|
|
153
153
|
borderWidth: 2,
|
|
154
154
|
borderRadius: tokens.borders.radius.md,
|
|
155
|
+
flexDirection: "row",
|
|
155
156
|
alignItems: "center",
|
|
156
|
-
|
|
157
|
-
gap: tokens.spacing.xs,
|
|
157
|
+
gap: tokens.spacing.md,
|
|
158
158
|
position: "relative",
|
|
159
159
|
},
|
|
160
|
-
optionLabel: { textAlign: "
|
|
160
|
+
optionLabel: { flex: 1, textAlign: "left" },
|
|
161
161
|
checkmark: {
|
|
162
162
|
position: "absolute",
|
|
163
163
|
top: tokens.spacing.xs,
|
|
@@ -66,7 +66,6 @@ export const createImageToVideoStrategy = (
|
|
|
66
66
|
thumbnailUrl: result.thumbnailUrl,
|
|
67
67
|
};
|
|
68
68
|
},
|
|
69
|
-
getCreditCost: () => config.creditCost ?? 0,
|
|
70
69
|
save: async (result) => {
|
|
71
70
|
if (result.success && result.videoUrl && creationIdRef.current) {
|
|
72
71
|
await callbacks?.onCreationSave?.({
|
|
@@ -65,7 +65,6 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
65
65
|
}
|
|
66
66
|
return result.imageUrls;
|
|
67
67
|
},
|
|
68
|
-
getCreditCost: () => totalCost,
|
|
69
68
|
}),
|
|
70
69
|
[callbacks, totalCost],
|
|
71
70
|
);
|
|
@@ -74,7 +73,6 @@ export function useGeneration(options: UseGenerationOptions): UseGenerationRetur
|
|
|
74
73
|
const { generate, isGenerating, error } = useGenerationOrchestrator(strategy, {
|
|
75
74
|
userId: userId ?? undefined,
|
|
76
75
|
alertMessages: DEFAULT_ALERT_MESSAGES,
|
|
77
|
-
onCreditsExhausted: () => callbacks.onCreditsRequired?.(totalCost),
|
|
78
76
|
onSuccess: (result) => {
|
|
79
77
|
const imageUrls = result as string[];
|
|
80
78
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -65,7 +65,6 @@ export const createTextToVideoStrategy = (
|
|
|
65
65
|
thumbnailUrl: result.thumbnailUrl,
|
|
66
66
|
};
|
|
67
67
|
},
|
|
68
|
-
getCreditCost: () => config.creditCost,
|
|
69
68
|
save: async (result) => {
|
|
70
69
|
if (result.success && result.videoUrl && creationIdRef.current) {
|
|
71
70
|
await callbacks.onCreationSave?.({
|
|
@@ -14,7 +14,6 @@ export interface UseExecutionCallbackParams<TRequest, TResult> {
|
|
|
14
14
|
imageUrl?: string;
|
|
15
15
|
imageUrls?: string[];
|
|
16
16
|
}>;
|
|
17
|
-
deductCredits?: (amount: number) => Promise<void>;
|
|
18
17
|
creditCostPerUnit: number;
|
|
19
18
|
onSuccess?: (result: TResult) => void;
|
|
20
19
|
onError?: (error: string) => void;
|
|
@@ -30,17 +29,13 @@ export interface ExecutionCallbacks<TRequest> {
|
|
|
30
29
|
export function useExecutionCallback<TRequest = unknown, TResult = unknown>(
|
|
31
30
|
params: UseExecutionCallbackParams<TRequest, TResult>,
|
|
32
31
|
): ExecutionCallbacks<TRequest> {
|
|
33
|
-
const { executor,
|
|
32
|
+
const { executor, creditCostPerUnit, onSuccess, onError } = params;
|
|
34
33
|
|
|
35
34
|
const executeGeneration = useCallback(
|
|
36
35
|
async (request: TRequest): Promise<AIFeatureGenerationResult> => {
|
|
37
36
|
try {
|
|
38
37
|
const result = await executor(request);
|
|
39
38
|
|
|
40
|
-
if (result.success && deductCredits) {
|
|
41
|
-
await deductCredits(creditCostPerUnit);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
39
|
if (result.success && result.data) {
|
|
45
40
|
onSuccess?.(result.data);
|
|
46
41
|
} else if (!result.success && result.error) {
|
|
@@ -57,7 +52,7 @@ export function useExecutionCallback<TRequest = unknown, TResult = unknown>(
|
|
|
57
52
|
return { success: false, error: message };
|
|
58
53
|
}
|
|
59
54
|
},
|
|
60
|
-
[executor,
|
|
55
|
+
[executor, creditCostPerUnit, onSuccess, onError],
|
|
61
56
|
);
|
|
62
57
|
|
|
63
58
|
return {
|
|
@@ -28,7 +28,6 @@ export interface AIFeatureCallbacksConfig<TRequest = unknown, TResult = unknown>
|
|
|
28
28
|
// Actions from app - showAuthModal accepts callback for post-auth resume
|
|
29
29
|
showAuthModal: (callback?: () => void) => void;
|
|
30
30
|
openPaywall: () => void;
|
|
31
|
-
deductCredits?: (amount: number) => Promise<void>;
|
|
32
31
|
|
|
33
32
|
// Optional callbacks
|
|
34
33
|
onSuccess?: (result: TResult) => void;
|
|
@@ -64,7 +64,6 @@ export const useDualImageGeneration = (
|
|
|
64
64
|
|
|
65
65
|
return result.imageUrl;
|
|
66
66
|
},
|
|
67
|
-
getCreditCost: () => creditCost,
|
|
68
67
|
}),
|
|
69
68
|
[model, getPrompt, creditCost],
|
|
70
69
|
);
|
|
@@ -73,7 +72,6 @@ export const useDualImageGeneration = (
|
|
|
73
72
|
const orchestrator = useGenerationOrchestrator(strategy, {
|
|
74
73
|
userId,
|
|
75
74
|
alertMessages,
|
|
76
|
-
onCreditsExhausted,
|
|
77
75
|
onSuccess: (result) => onSuccess?.(result as string),
|
|
78
76
|
onError: (error) => onError?.(error.message),
|
|
79
77
|
});
|
|
@@ -72,7 +72,6 @@ export const useImageGeneration = <TInput extends ImageGenerationInput, TResult>
|
|
|
72
72
|
|
|
73
73
|
return processResult(result.imageUrl, input);
|
|
74
74
|
},
|
|
75
|
-
getCreditCost: () => creditCost,
|
|
76
75
|
save: buildCreation
|
|
77
76
|
? async (result, uid) => {
|
|
78
77
|
const creation = buildCreation(result, lastInputRef.current ?? ({} as TInput));
|
|
@@ -90,7 +89,6 @@ export const useImageGeneration = <TInput extends ImageGenerationInput, TResult>
|
|
|
90
89
|
return useGenerationOrchestrator(strategy, {
|
|
91
90
|
userId,
|
|
92
91
|
alertMessages,
|
|
93
|
-
onCreditsExhausted,
|
|
94
92
|
onSuccess: onSuccess as (result: unknown) => void,
|
|
95
93
|
onError: handleError,
|
|
96
94
|
});
|
|
@@ -82,7 +82,6 @@ export const useVideoGeneration = <TResult>(
|
|
|
82
82
|
|
|
83
83
|
return processResult(result.videoUrl, input);
|
|
84
84
|
},
|
|
85
|
-
getCreditCost: () => creditCost,
|
|
86
85
|
save: buildCreation
|
|
87
86
|
? async (result, uid) => {
|
|
88
87
|
const creation = buildCreation(result, lastInputRef.current ?? {} as DualImageVideoInput);
|
|
@@ -105,7 +104,6 @@ export const useVideoGeneration = <TResult>(
|
|
|
105
104
|
return useGenerationOrchestrator(strategy, {
|
|
106
105
|
userId,
|
|
107
106
|
alertMessages,
|
|
108
|
-
onCreditsExhausted,
|
|
109
107
|
onSuccess: onSuccess as (result: unknown) => void,
|
|
110
108
|
onError: handleError,
|
|
111
109
|
});
|
|
@@ -42,7 +42,6 @@ export function useAIFeatureCallbacks<TRequest = unknown, TResult = unknown>(
|
|
|
42
42
|
executor,
|
|
43
43
|
showAuthModal,
|
|
44
44
|
openPaywall,
|
|
45
|
-
deductCredits,
|
|
46
45
|
onSuccess,
|
|
47
46
|
onError,
|
|
48
47
|
} = config;
|
|
@@ -64,7 +63,6 @@ export function useAIFeatureCallbacks<TRequest = unknown, TResult = unknown>(
|
|
|
64
63
|
// Execution callback
|
|
65
64
|
const executionCallbacks = useExecutionCallback({
|
|
66
65
|
executor,
|
|
67
|
-
deductCredits,
|
|
68
66
|
creditCostPerUnit,
|
|
69
67
|
onSuccess,
|
|
70
68
|
onError,
|